@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,109 @@
1
+ import * as React from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { ChevronRight, MoreHorizontal } from "lucide-react";
4
+
5
+ import { cn } from "@brightlocal/ui-components/lib/utils";
6
+
7
+ function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
8
+ return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />;
9
+ }
10
+
11
+ function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
12
+ return (
13
+ <ol
14
+ className={cn(
15
+ "text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",
16
+ className
17
+ )}
18
+ data-slot="breadcrumb-list"
19
+ {...props}
20
+ />
21
+ );
22
+ }
23
+
24
+ function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
25
+ return (
26
+ <li
27
+ className={cn("inline-flex items-center gap-1.5", className)}
28
+ data-slot="breadcrumb-item"
29
+ {...props}
30
+ />
31
+ );
32
+ }
33
+
34
+ function BreadcrumbLink({
35
+ asChild,
36
+ className,
37
+ ...props
38
+ }: React.ComponentProps<"a"> & {
39
+ asChild?: boolean;
40
+ }) {
41
+ const Comp = asChild ? Slot : "a";
42
+
43
+ return (
44
+ <Comp
45
+ className={cn("hover:text-foreground transition-colors", className)}
46
+ data-slot="breadcrumb-link"
47
+ {...props}
48
+ />
49
+ );
50
+ }
51
+
52
+ function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
53
+ return (
54
+ <span
55
+ aria-current="page"
56
+ aria-disabled="true"
57
+ className={cn("text-foreground font-normal", className)}
58
+ data-slot="breadcrumb-page"
59
+ role="link"
60
+ {...props}
61
+ />
62
+ );
63
+ }
64
+
65
+ function BreadcrumbSeparator({
66
+ children,
67
+ className,
68
+ ...props
69
+ }: React.ComponentProps<"li">) {
70
+ return (
71
+ <li
72
+ aria-hidden="true"
73
+ className={cn("[&>svg]:size-3.5", className)}
74
+ data-slot="breadcrumb-separator"
75
+ role="presentation"
76
+ {...props}
77
+ >
78
+ {children ?? <ChevronRight />}
79
+ </li>
80
+ );
81
+ }
82
+
83
+ function BreadcrumbEllipsis({
84
+ className,
85
+ ...props
86
+ }: React.ComponentProps<"span">) {
87
+ return (
88
+ <span
89
+ aria-hidden="true"
90
+ className={cn("flex size-9 items-center justify-center", className)}
91
+ data-slot="breadcrumb-ellipsis"
92
+ role="presentation"
93
+ {...props}
94
+ >
95
+ <MoreHorizontal className="size-4" />
96
+ <span className="sr-only">More</span>
97
+ </span>
98
+ );
99
+ }
100
+
101
+ export {
102
+ Breadcrumb,
103
+ BreadcrumbList,
104
+ BreadcrumbItem,
105
+ BreadcrumbLink,
106
+ BreadcrumbPage,
107
+ BreadcrumbSeparator,
108
+ BreadcrumbEllipsis,
109
+ };
@@ -0,0 +1,296 @@
1
+ import * as React from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { cva } from "class-variance-authority";
4
+ import { Loader2 } from "lucide-react";
5
+
6
+ import { cn } from "@brightlocal/ui-components/lib/utils";
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
+ // Shared constants
57
+ const BUTTON_SPINNER_SIZE = 16;
58
+
59
+ type ButtonVariantProps = {
60
+ variant?: ButtonVariant;
61
+ size?: ButtonSize;
62
+ };
63
+
64
+ const ButtonVariants = cva(
65
+ [
66
+ "rounded-full",
67
+ "inline-flex",
68
+ "font-semibold",
69
+ "items-center",
70
+ "justify-center",
71
+ "gap-2",
72
+ "whitespace-nowrap",
73
+ "transition-all",
74
+ "cursor-pointer",
75
+ "disabled:pointer-events-none",
76
+ "disabled:cursor-not-allowed",
77
+ "disabled:opacity-50",
78
+ "aria-disabled:opacity-50",
79
+ "[&_svg]:pointer-events-none",
80
+ "shrink-0",
81
+ "outline-none",
82
+ "aria-invalid:ring-destructive/20",
83
+ "dark:aria-invalid:ring-destructive/40",
84
+ "aria-invalid:border-destructive",
85
+ ],
86
+ {
87
+ variants: {
88
+ variant: {
89
+ default: [
90
+ "bg-primary",
91
+ "dark:bg-green-400",
92
+ "text-primary-foreground",
93
+ "dark:text-[var(--ds-colors-primary-foreground-light)]",
94
+ "hover:bg-primary/90",
95
+ "focus-visible:shadow-default",
96
+ ],
97
+ destructive: [
98
+ "bg-destructive",
99
+ "dark:bg-red-400/90",
100
+ "hover:bg-destructive/90",
101
+ "dark:hover:bg-red-400/90",
102
+ "text-destructive-foreground",
103
+ "focus-visible:shadow-destructive",
104
+ ],
105
+ outline: [
106
+ "border",
107
+ "border-border",
108
+ "border-solid",
109
+ "bg-background",
110
+ "hover:bg-accent",
111
+ "hover:text-accent-foreground",
112
+ "dark:bg-input/30",
113
+ "dark:border-input",
114
+ "dark:hover:bg-input/80",
115
+ "dark:hover:border-input",
116
+ "focus-visible:shadow-default",
117
+ ],
118
+ secondary: [
119
+ "bg-secondary",
120
+ "text-secondary-foreground",
121
+ "hover:bg-secondary/80",
122
+ "focus-visible:shadow-default",
123
+ ],
124
+ ghost: [
125
+ "bg-transparent",
126
+ "text-foreground",
127
+ "hover:bg-accent",
128
+ "data-[state=open]:bg-accent",
129
+ "focus-visible:shadow-default",
130
+ ],
131
+ warning: [
132
+ "bg-warning-light",
133
+ "text-warning-foreground",
134
+ "hover:bg-warning-light/90",
135
+ "focus-visible:shadow-default",
136
+ ],
137
+ },
138
+ size: {
139
+ default: "px-4 py-2 h-9 text-sm [&_svg:not([class*='size-'])]:size-4",
140
+ sm: "py-2 px-3 h-8 text-xs [&_svg:not([class*='size-'])]:size-4",
141
+ lg: "py-2 px-8 h-10 text-sm [&_svg:not([class*='size-'])]:size-5",
142
+ },
143
+ state: {
144
+ default: "",
145
+ loading: "pointer-events-none",
146
+ disabled: "pointer-events-none opacity-50",
147
+ },
148
+ fullWidth: {
149
+ false: "",
150
+ true: "w-full",
151
+ },
152
+ },
153
+ defaultVariants: {
154
+ variant: ButtonVariant.DEFAULT,
155
+ size: ButtonSize.DEFAULT,
156
+ state: ButtonState.Default,
157
+ fullWidth: false,
158
+ },
159
+ }
160
+ );
161
+
162
+ /**
163
+ * Props for the Button component
164
+ */
165
+ type NativeButtonProps = Omit<React.ComponentProps<"button">, "type">;
166
+
167
+ type ButtonProps = NativeButtonProps &
168
+ ButtonVariantProps & {
169
+ ariaLabel?: string;
170
+ asChild?: boolean;
171
+ dataHook: string;
172
+ type?: ButtonType;
173
+ fullWidth?: boolean;
174
+ loading?: boolean;
175
+ trackingEl?: string;
176
+ trackingLabel?: string;
177
+ };
178
+
179
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
180
+ (
181
+ {
182
+ className,
183
+ variant = ButtonVariant.DEFAULT,
184
+ size = ButtonSize.DEFAULT,
185
+ fullWidth = false,
186
+ asChild = false,
187
+ dataHook,
188
+ trackingEl,
189
+ trackingLabel,
190
+ loading = false,
191
+ ariaLabel,
192
+ disabled = false,
193
+ children,
194
+ ...props
195
+ },
196
+ ref
197
+ ) => {
198
+ const Comp = asChild ? Slot : "button";
199
+
200
+ // Determine actual disabled state
201
+ const isDisabled = disabled || loading;
202
+
203
+ // Determine content to display
204
+ const displayChildren = children;
205
+ let isSingleIconOnly = false;
206
+ if (
207
+ React.Children.count(children) === 1 &&
208
+ React.isValidElement(children)
209
+ ) {
210
+ const onlyChild = children as React.ReactElement<{
211
+ children?: React.ReactNode;
212
+ }>;
213
+ isSingleIconOnly = onlyChild.props?.children == null;
214
+ }
215
+ const showLoadingSpinner = loading && !asChild;
216
+
217
+ // 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;
221
+
222
+ // Ensure we always have an accessible label
223
+ const effectiveAriaLabel =
224
+ ariaLabel ??
225
+ (loading ? `Loading: ${displayChildren || "Please wait"}` : undefined);
226
+
227
+ // When asChild is used, render a simplified version that only forwards props
228
+ if (asChild) {
229
+ return (
230
+ <Comp
231
+ ref={ref}
232
+ className={cn(
233
+ ButtonVariants({
234
+ variant,
235
+ size,
236
+ state: visualState,
237
+ fullWidth,
238
+ }),
239
+ isSingleIconOnly && "size-9 p-0",
240
+ className
241
+ )}
242
+ data-hook={dataHook}
243
+ data-slot="button"
244
+ data-tracking-el={trackingEl || `button-${variant}`}
245
+ data-tracking-label={trackingLabel}
246
+ {...props}
247
+ >
248
+ {children}
249
+ </Comp>
250
+ );
251
+ }
252
+
253
+ // When NOT asChild, render the full button with all features
254
+ return (
255
+ <Comp
256
+ ref={ref}
257
+ aria-busy={loading ? "true" : undefined}
258
+ aria-disabled={isDisabled ? "true" : undefined}
259
+ aria-label={effectiveAriaLabel}
260
+ className={cn(
261
+ ButtonVariants({
262
+ variant,
263
+ size,
264
+ state: visualState,
265
+ fullWidth,
266
+ }),
267
+ isSingleIconOnly && "size-9 p-0",
268
+ className
269
+ )}
270
+ data-hook={dataHook}
271
+ data-slot="button"
272
+ data-tracking-el={trackingEl || `button-${variant}`}
273
+ data-tracking-label={trackingLabel}
274
+ disabled={isDisabled}
275
+ type={props.type ?? ButtonType.BUTTON}
276
+ {...props}
277
+ >
278
+ {showLoadingSpinner && (
279
+ <div
280
+ className="pointer-events-none flex items-center justify-center"
281
+ data-slot="button-loading-icon"
282
+ >
283
+ <Loader2 className="animate-spin" size={BUTTON_SPINNER_SIZE} />
284
+ </div>
285
+ )}
286
+ {typeof displayChildren !== "undefined" && displayChildren}
287
+ </Comp>
288
+ );
289
+ }
290
+ );
291
+
292
+ Button.displayName = "Button";
293
+
294
+ export { Button, ButtonVariants };
295
+
296
+ export type { ButtonProps };
@@ -0,0 +1,234 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
5
+ import {
6
+ DayButton,
7
+ DayPicker,
8
+ getDefaultClassNames,
9
+ type DayPickerProps,
10
+ } from "react-day-picker";
11
+
12
+ import { cn } from "@brightlocal/ui-components/lib/utils";
13
+
14
+ export type CalendarProps = DayPickerProps & {
15
+ /**
16
+ * Number of months to display (1-3)
17
+ * @default 1
18
+ */
19
+ numberOfMonths?: 1 | 2 | 3;
20
+ /**
21
+ * Data hook for testing and analytics
22
+ */
23
+ dataHook: string;
24
+ /**
25
+ * Tracking element identifier
26
+ */
27
+ trackingEl?: string;
28
+ /**
29
+ * Tracking label for analytics
30
+ */
31
+ trackingLabel?: string;
32
+ };
33
+
34
+ const navButtonStyles = cn(
35
+ "inline-flex items-center justify-center rounded-md bg-background",
36
+ "hover:bg-accent hover:text-accent-foreground",
37
+ "focus-visible:outline-none focus-visible:shadow-default",
38
+ "h-8 w-8 p-0 opacity-50 hover:opacity-100"
39
+ );
40
+
41
+ function CalendarDayButton({
42
+ className,
43
+ day,
44
+ modifiers,
45
+ ...props
46
+ }: React.ComponentProps<typeof DayButton>) {
47
+ const defaultClassNames = getDefaultClassNames();
48
+ const ref = React.useRef<HTMLButtonElement>(null);
49
+
50
+ React.useEffect(() => {
51
+ if (modifiers.focused) ref.current?.focus();
52
+ }, [modifiers.focused]);
53
+
54
+ return (
55
+ <button
56
+ ref={ref}
57
+ className={cn(
58
+ "text-foreground h-8 w-8 rounded-md p-0 font-sans text-sm leading-5 font-normal",
59
+ "hover:bg-accent hover:text-accent-foreground",
60
+ "focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:outline-none",
61
+ "group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10",
62
+ "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[selected-single=true]:rounded-md",
63
+ "data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-start=true]:rounded-md",
64
+ "data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-end=true]:rounded-md",
65
+ "data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground",
66
+ defaultClassNames.day,
67
+ className
68
+ )}
69
+ data-day={day.date.toLocaleDateString()}
70
+ data-range-end={modifiers.range_end}
71
+ data-range-middle={modifiers.range_middle}
72
+ data-range-start={modifiers.range_start}
73
+ data-selected-single={
74
+ modifiers.selected &&
75
+ !modifiers.range_start &&
76
+ !modifiers.range_end &&
77
+ !modifiers.range_middle
78
+ }
79
+ type="button"
80
+ {...props}
81
+ />
82
+ );
83
+ }
84
+
85
+ function Calendar({
86
+ className,
87
+ classNames,
88
+ showOutsideDays = true,
89
+ numberOfMonths = 1,
90
+ captionLayout,
91
+ fixedWeeks = true,
92
+ dataHook,
93
+ trackingEl,
94
+ trackingLabel,
95
+ components,
96
+ formatters,
97
+ ...props
98
+ }: CalendarProps) {
99
+ const defaultClassNames = getDefaultClassNames();
100
+
101
+ return (
102
+ <DayPicker
103
+ captionLayout={captionLayout}
104
+ className={cn(
105
+ "bg-background border-border group/calendar relative rounded-lg border p-3 shadow-sm",
106
+ className
107
+ )}
108
+ classNames={{
109
+ months: cn("flex flex-col sm:flex-row gap-4", defaultClassNames.months),
110
+ month: cn("flex flex-col gap-4", defaultClassNames.month),
111
+ month_caption: cn(
112
+ "flex justify-center relative items-center w-full h-8",
113
+ defaultClassNames.month_caption
114
+ ),
115
+ caption_label: cn(
116
+ "text-sm font-sans leading-5 text-foreground select-none",
117
+ captionLayout === "dropdown" ? "font-normal" : "font-medium",
118
+ "[&>svg]:text-muted-foreground [&>svg]:size-4",
119
+ "flex h-[34px] items-center gap-1 rounded-md pl-2 pr-1",
120
+ defaultClassNames.caption_label
121
+ ),
122
+ dropdowns: cn(
123
+ "flex w-full items-center justify-center gap-1.5 text-sm font-normal",
124
+ defaultClassNames.dropdowns
125
+ ),
126
+ dropdown_root: cn(
127
+ "relative rounded-md border border-input shadow-xs h-[34px]",
128
+ "has-focus:shadow-default",
129
+ defaultClassNames.dropdown_root
130
+ ),
131
+ dropdown: cn(
132
+ "absolute inset-0 z-10 opacity-0 cursor-pointer",
133
+ defaultClassNames.dropdown
134
+ ),
135
+ months_dropdown: cn("w-[58px]", defaultClassNames.months_dropdown),
136
+ years_dropdown: cn("w-[69px]", defaultClassNames.years_dropdown),
137
+ nav: cn(
138
+ "absolute top-3 left-3 right-3 flex items-center justify-between z-10",
139
+ defaultClassNames.nav
140
+ ),
141
+ button_previous: cn(navButtonStyles, defaultClassNames.button_previous),
142
+ button_next: cn(navButtonStyles, defaultClassNames.button_next),
143
+ month_grid: cn(
144
+ "w-full border-collapse flex flex-col",
145
+ defaultClassNames.month_grid
146
+ ),
147
+ weekdays: cn("flex", defaultClassNames.weekdays),
148
+ weekday: cn(
149
+ "text-muted-foreground rounded-md w-8 h-5 flex items-center justify-center font-normal font-sans text-xs leading-4",
150
+ defaultClassNames.weekday
151
+ ),
152
+ week: cn(defaultClassNames.week, "flex w-full mt-2"),
153
+ day: cn(
154
+ "relative w-full h-full p-0 text-center text-sm focus-within:relative focus-within:z-20 group/day select-none",
155
+ "[&:first-child[data-selected=true]_button]:!rounded-l-md",
156
+ "[&:last-child[data-selected=true]_button]:!rounded-r-md",
157
+ defaultClassNames.day
158
+ ),
159
+ range_start: cn(
160
+ "rounded-l-md bg-accent",
161
+ defaultClassNames.range_start
162
+ ),
163
+ range_middle: cn(
164
+ "rounded-none bg-accent",
165
+ "first:rounded-l-md last:rounded-r-md",
166
+ defaultClassNames.range_middle
167
+ ),
168
+ range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
169
+ today: cn(
170
+ "bg-accent text-accent-foreground rounded-md",
171
+ defaultClassNames.today
172
+ ),
173
+ outside: cn(
174
+ "text-muted-foreground opacity-50 aria-selected:text-muted-foreground aria-selected:opacity-50",
175
+ defaultClassNames.outside
176
+ ),
177
+ disabled: cn(
178
+ "text-foreground opacity-50 cursor-not-allowed",
179
+ defaultClassNames.disabled
180
+ ),
181
+ hidden: cn(defaultClassNames.hidden),
182
+ ...classNames,
183
+ }}
184
+ components={{
185
+ Chevron: ({
186
+ orientation,
187
+ className: chevronClassName,
188
+ ...iconProps
189
+ }) => {
190
+ if (orientation === "left") {
191
+ return (
192
+ <ChevronLeft
193
+ className={cn("size-4", chevronClassName)}
194
+ {...iconProps}
195
+ />
196
+ );
197
+ }
198
+ if (orientation === "right") {
199
+ return (
200
+ <ChevronRight
201
+ className={cn("size-4", chevronClassName)}
202
+ {...iconProps}
203
+ />
204
+ );
205
+ }
206
+ return (
207
+ <ChevronDown
208
+ className={cn("size-4", chevronClassName)}
209
+ {...iconProps}
210
+ />
211
+ );
212
+ },
213
+ DayButton: CalendarDayButton,
214
+ ...components,
215
+ }}
216
+ data-hook={dataHook}
217
+ data-tracking-el={trackingEl}
218
+ data-tracking-label={trackingLabel}
219
+ fixedWeeks={fixedWeeks}
220
+ formatters={{
221
+ formatMonthDropdown: (date) =>
222
+ date.toLocaleString("default", { month: "short" }),
223
+ ...formatters,
224
+ }}
225
+ numberOfMonths={numberOfMonths}
226
+ showOutsideDays={showOutsideDays}
227
+ {...props}
228
+ />
229
+ );
230
+ }
231
+
232
+ Calendar.displayName = "Calendar";
233
+
234
+ export { Calendar, CalendarDayButton };