@brightlocal/ui-components 0.1.2 → 0.1.4

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 (281) 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.cjs +1 -1
  10. package/dist/alert.d.ts +22 -1
  11. package/dist/alert.d.ts.map +1 -1
  12. package/dist/alert.js +1 -1
  13. package/dist/aspect-ratio.cjs +1 -1
  14. package/dist/aspect-ratio.d.ts +11 -1
  15. package/dist/aspect-ratio.d.ts.map +1 -1
  16. package/dist/aspect-ratio.js +16 -20
  17. package/dist/avatar.cjs +1 -1
  18. package/dist/avatar.d.ts +43 -3
  19. package/dist/avatar.d.ts.map +1 -1
  20. package/dist/avatar.js +18 -16
  21. package/dist/badge.cjs +1 -1
  22. package/dist/badge.d.ts +24 -9
  23. package/dist/badge.d.ts.map +1 -1
  24. package/dist/badge.js +34 -32
  25. package/dist/blocks/data-table.cjs +1 -1
  26. package/dist/blocks/data-table.d.ts.map +1 -1
  27. package/dist/blocks/data-table.js +177 -170
  28. package/dist/blocks/sidebar.cjs +1 -1
  29. package/dist/blocks/sidebar.d.ts +38 -307
  30. package/dist/blocks/sidebar.d.ts.map +1 -1
  31. package/dist/blocks/sidebar.js +411 -508
  32. package/dist/breadcrumb.cjs +1 -1
  33. package/dist/breadcrumb.d.ts +63 -8
  34. package/dist/breadcrumb.d.ts.map +1 -1
  35. package/dist/breadcrumb.js +97 -93
  36. package/dist/button.cjs +1 -1
  37. package/dist/button.d.ts +17 -45
  38. package/dist/button.d.ts.map +1 -1
  39. package/dist/button.js +49 -50
  40. package/dist/calendar.cjs +1 -1
  41. package/dist/calendar.d.ts +16 -1
  42. package/dist/calendar.d.ts.map +1 -1
  43. package/dist/calendar.js +31 -29
  44. package/dist/card.cjs +1 -1
  45. package/dist/card.d.ts +58 -18
  46. package/dist/card.d.ts.map +1 -1
  47. package/dist/card.js +60 -51
  48. package/dist/carousel.cjs +1 -1
  49. package/dist/carousel.d.ts +99 -9
  50. package/dist/carousel.d.ts.map +1 -1
  51. package/dist/carousel.js +142 -128
  52. package/dist/centred-layout.cjs +1 -1
  53. package/dist/centred-layout.d.ts +18 -15
  54. package/dist/centred-layout.d.ts.map +1 -1
  55. package/dist/centred-layout.js +44 -33
  56. package/dist/chart.cjs +4 -4
  57. package/dist/chart.d.ts +70 -7
  58. package/dist/chart.d.ts.map +1 -1
  59. package/dist/chart.js +71 -66
  60. package/dist/checkbox.cjs +1 -1
  61. package/dist/checkbox.d.ts +9 -5
  62. package/dist/checkbox.d.ts.map +1 -1
  63. package/dist/checkbox.js +61 -82
  64. package/dist/collapsible.cjs +1 -1
  65. package/dist/collapsible.d.ts +65 -8
  66. package/dist/collapsible.d.ts.map +1 -1
  67. package/dist/collapsible.js +41 -55
  68. package/dist/combobox.cjs +1 -1
  69. package/dist/combobox.d.ts +28 -18
  70. package/dist/combobox.d.ts.map +1 -1
  71. package/dist/combobox.js +191 -160
  72. package/dist/command.cjs +1 -1
  73. package/dist/command.d.ts +115 -9
  74. package/dist/command.d.ts.map +1 -1
  75. package/dist/command.js +176 -152
  76. package/dist/context-menu.cjs +1 -1
  77. package/dist/context-menu.d.ts +188 -20
  78. package/dist/context-menu.d.ts.map +1 -1
  79. package/dist/context-menu.js +120 -122
  80. package/dist/date-picker.cjs +1 -1
  81. package/dist/date-picker.d.ts +75 -9
  82. package/dist/date-picker.d.ts.map +1 -1
  83. package/dist/date-picker.js +221 -82
  84. package/dist/description.cjs +1 -0
  85. package/dist/description.d.ts +37 -0
  86. package/dist/description.d.ts.map +1 -0
  87. package/dist/description.js +25 -0
  88. package/dist/dialog.cjs +1 -1
  89. package/dist/dialog.d.ts +73 -9
  90. package/dist/dialog.d.ts.map +1 -1
  91. package/dist/dialog.js +103 -112
  92. package/dist/drawer.cjs +1 -1
  93. package/dist/drawer.d.ts +92 -0
  94. package/dist/drawer.d.ts.map +1 -1
  95. package/dist/drawer.js +67 -52
  96. package/dist/dropdown-menu.cjs +1 -1
  97. package/dist/dropdown-menu.d.ts +95 -11
  98. package/dist/dropdown-menu.d.ts.map +1 -1
  99. package/dist/dropdown-menu.js +146 -106
  100. package/dist/field.cjs +1 -1
  101. package/dist/field.d.ts +26 -6
  102. package/dist/field.d.ts.map +1 -1
  103. package/dist/field.js +55 -53
  104. package/dist/global-layout.cjs +1 -1
  105. package/dist/global-layout.d.ts +27 -17
  106. package/dist/global-layout.d.ts.map +1 -1
  107. package/dist/global-layout.js +86 -79
  108. package/dist/hover-card.cjs +1 -1
  109. package/dist/hover-card.d.ts +36 -6
  110. package/dist/hover-card.d.ts.map +1 -1
  111. package/dist/hover-card.js +44 -42
  112. package/dist/index.cjs +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +367 -386
  116. package/dist/input-group.cjs +1 -1
  117. package/dist/input-group.d.ts +21 -2
  118. package/dist/input-group.d.ts.map +1 -1
  119. package/dist/input-group.js +51 -41
  120. package/dist/input-otp.cjs +1 -1
  121. package/dist/input-otp.js +1 -1
  122. package/dist/input-password.cjs +1 -1
  123. package/dist/input-password.d.ts.map +1 -1
  124. package/dist/input-password.js +25 -26
  125. package/dist/input.cjs +1 -1
  126. package/dist/input.d.ts +38 -24
  127. package/dist/input.d.ts.map +1 -1
  128. package/dist/input.js +68 -136
  129. package/dist/label.cjs +1 -1
  130. package/dist/label.d.ts +20 -1
  131. package/dist/label.d.ts.map +1 -1
  132. package/dist/label.js +31 -18
  133. package/dist/link.cjs +1 -1
  134. package/dist/link.js +1 -1
  135. package/dist/logo.cjs +1 -1
  136. package/dist/logo.d.ts +9 -4
  137. package/dist/logo.d.ts.map +1 -1
  138. package/dist/logo.js +20 -21
  139. package/dist/menubar.cjs +1 -1
  140. package/dist/menubar.d.ts +43 -6
  141. package/dist/menubar.d.ts.map +1 -1
  142. package/dist/menubar.js +100 -78
  143. package/dist/navigation-menu.cjs +1 -1
  144. package/dist/navigation-menu.d.ts +6 -54
  145. package/dist/navigation-menu.d.ts.map +1 -1
  146. package/dist/navigation-menu.js +73 -84
  147. package/dist/pagination.cjs +1 -1
  148. package/dist/pagination.d.ts +8 -10
  149. package/dist/pagination.d.ts.map +1 -1
  150. package/dist/pagination.js +78 -86
  151. package/dist/popover.cjs +1 -1
  152. package/dist/popover.d.ts +59 -4
  153. package/dist/popover.d.ts.map +1 -1
  154. package/dist/popover.js +42 -34
  155. package/dist/progress.cjs +1 -1
  156. package/dist/progress.d.ts +9 -2
  157. package/dist/progress.d.ts.map +1 -1
  158. package/dist/progress.js +71 -59
  159. package/dist/radio-group.cjs +1 -1
  160. package/dist/radio-group.d.ts +33 -10
  161. package/dist/radio-group.d.ts.map +1 -1
  162. package/dist/radio-group.js +56 -66
  163. package/dist/rating.d.ts +4 -0
  164. package/dist/rating.d.ts.map +1 -1
  165. package/dist/resizable.cjs +1 -1
  166. package/dist/resizable.d.ts +58 -6
  167. package/dist/resizable.d.ts.map +1 -1
  168. package/dist/resizable.js +38 -37
  169. package/dist/scroll-area.cjs +1 -1
  170. package/dist/scroll-area.d.ts +46 -5
  171. package/dist/scroll-area.d.ts.map +1 -1
  172. package/dist/scroll-area.js +42 -38
  173. package/dist/select.cjs +1 -1
  174. package/dist/select.d.ts +30 -0
  175. package/dist/select.d.ts.map +1 -1
  176. package/dist/select.js +64 -54
  177. package/dist/separator.cjs +1 -1
  178. package/dist/separator.d.ts +52 -5
  179. package/dist/separator.d.ts.map +1 -1
  180. package/dist/separator.js +45 -35
  181. package/dist/sheet.cjs +1 -1
  182. package/dist/sheet.d.ts +85 -19
  183. package/dist/sheet.d.ts.map +1 -1
  184. package/dist/sheet.js +117 -115
  185. package/dist/skeleton.cjs +1 -1
  186. package/dist/skeleton.d.ts +24 -2
  187. package/dist/skeleton.d.ts.map +1 -1
  188. package/dist/skeleton.js +15 -9
  189. package/dist/slider.cjs +1 -1
  190. package/dist/slider.d.ts +18 -4
  191. package/dist/slider.d.ts.map +1 -1
  192. package/dist/slider.js +72 -66
  193. package/dist/sonner.cjs +1 -1
  194. package/dist/sonner.d.ts +21 -22
  195. package/dist/sonner.d.ts.map +1 -1
  196. package/dist/sonner.js +46 -48
  197. package/dist/split-layout.d.ts +4 -1
  198. package/dist/split-layout.d.ts.map +1 -1
  199. package/dist/switch.cjs +1 -1
  200. package/dist/switch.d.ts +2 -12
  201. package/dist/switch.d.ts.map +1 -1
  202. package/dist/switch.js +37 -41
  203. package/dist/table.cjs +1 -1
  204. package/dist/table.d.ts +16 -12
  205. package/dist/table.d.ts.map +1 -1
  206. package/dist/table.js +56 -58
  207. package/dist/tabs.d.ts +27 -3
  208. package/dist/tabs.d.ts.map +1 -1
  209. package/dist/toggle-group.cjs +1 -1
  210. package/dist/toggle-group.d.ts +57 -7
  211. package/dist/toggle-group.d.ts.map +1 -1
  212. package/dist/toggle-group.js +60 -67
  213. package/dist/toggle.cjs +1 -1
  214. package/dist/toggle.d.ts +12 -26
  215. package/dist/toggle.d.ts.map +1 -1
  216. package/dist/toggle.js +16 -20
  217. package/package.json +9 -3
  218. package/src/blocks/data-table.tsx +43 -33
  219. package/src/blocks/sidebar.tsx +158 -541
  220. package/src/components/accordion.tsx +164 -78
  221. package/src/components/alert-dialog.tsx +156 -111
  222. package/src/components/alert.tsx +27 -14
  223. package/src/components/aspect-ratio.tsx +25 -16
  224. package/src/components/avatar.tsx +56 -8
  225. package/src/components/badge.tsx +65 -42
  226. package/src/components/breadcrumb.tsx +159 -83
  227. package/src/components/button.tsx +42 -63
  228. package/src/components/calendar.tsx +22 -6
  229. package/src/components/card.tsx +92 -40
  230. package/src/components/carousel.tsx +240 -115
  231. package/src/components/centred-layout.tsx +68 -49
  232. package/src/components/chart.tsx +118 -47
  233. package/src/components/checkbox.tsx +43 -79
  234. package/src/components/collapsible.tsx +95 -26
  235. package/src/components/combobox.tsx +243 -153
  236. package/src/components/command.tsx +295 -121
  237. package/src/components/context-menu.tsx +279 -82
  238. package/src/components/date-picker.tsx +282 -31
  239. package/src/components/description.tsx +60 -0
  240. package/src/components/dialog.tsx +163 -87
  241. package/src/components/drawer.tsx +76 -2
  242. package/src/components/dropdown-menu.tsx +143 -37
  243. package/src/components/field.tsx +38 -11
  244. package/src/components/global-layout.tsx +116 -77
  245. package/src/components/hover-card.tsx +54 -14
  246. package/src/components/input-group.tsx +56 -18
  247. package/src/components/input-otp.tsx +1 -1
  248. package/src/components/input-password.tsx +4 -5
  249. package/src/components/input.tsx +93 -186
  250. package/src/components/label.tsx +56 -15
  251. package/src/components/link.tsx +1 -1
  252. package/src/components/logo.tsx +12 -7
  253. package/src/components/menubar.tsx +61 -5
  254. package/src/components/navigation-menu.tsx +37 -99
  255. package/src/components/pagination.tsx +13 -19
  256. package/src/components/popover.tsx +103 -20
  257. package/src/components/progress.tsx +82 -60
  258. package/src/components/radio-group.tsx +44 -25
  259. package/src/components/rating.tsx +4 -0
  260. package/src/components/resizable.tsx +88 -38
  261. package/src/components/scroll-area.tsx +123 -56
  262. package/src/components/select.tsx +22 -2
  263. package/src/components/separator.tsx +101 -24
  264. package/src/components/sheet.tsx +186 -90
  265. package/src/components/skeleton.tsx +40 -10
  266. package/src/components/slider.tsx +83 -57
  267. package/src/components/sonner.tsx +34 -34
  268. package/src/components/split-layout.tsx +4 -1
  269. package/src/components/switch.figma.tsx +7 -11
  270. package/src/components/switch.tsx +9 -19
  271. package/src/components/table.tsx +23 -18
  272. package/src/components/tabs.tsx +27 -3
  273. package/src/components/toggle-group.tsx +115 -86
  274. package/src/components/toggle.figma.tsx +13 -19
  275. package/src/components/toggle.tsx +20 -34
  276. package/src/index.ts +1 -1
  277. package/dist/input-base.cjs +0 -1
  278. package/dist/input-base.d.ts +0 -28
  279. package/dist/input-base.d.ts.map +0 -1
  280. package/dist/input-base.js +0 -56
  281. package/src/components/input-base.tsx +0 -86
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ExternalLink } from "lucide-react";
2
+ import { ExternalLink } from "@brightlocal/icons";
3
3
  import { Slot } from "@radix-ui/react-slot";
4
4
  import { cva, type VariantProps } from "class-variance-authority";
5
5
 
@@ -1,10 +1,12 @@
1
1
  import { cva, VariantProps } from "class-variance-authority";
2
2
  import { cn } from "@brightlocal/ui-components/lib/utils";
3
3
 
4
- export enum LogoVariant {
5
- LOGOTYPE = "logotype",
6
- MARK = "mark",
7
- }
4
+ /**
5
+ * Visual style variants for the Logo component.
6
+ * - `logotype`: Full BrightLocal logo with text
7
+ * - `mark`: Icon-only logo mark
8
+ */
9
+ export type LogoVariant = "logotype" | "mark";
8
10
 
9
11
  const logoVariants = cva("inline-flex [&_path]:fill-primary", {
10
12
  variants: {
@@ -14,7 +16,7 @@ const logoVariants = cva("inline-flex [&_path]:fill-primary", {
14
16
  },
15
17
  },
16
18
  defaultVariants: {
17
- variant: LogoVariant.LOGOTYPE,
19
+ variant: "logotype",
18
20
  },
19
21
  });
20
22
 
@@ -49,12 +51,13 @@ function Logo({
49
51
  aria-label="BrightLocal Logo"
50
52
  className={cn(logoVariants({ variant }), className)}
51
53
  data-hook={dataHook}
54
+ data-slot="logo"
52
55
  data-tracking-el={trackingEl}
53
56
  data-tracking-label={trackingLabel}
54
57
  role="img"
55
58
  {...props}
56
59
  >
57
- {variant === LogoVariant.LOGOTYPE && (
60
+ {variant === "logotype" && (
58
61
  <svg
59
62
  fill="none"
60
63
  height="30"
@@ -72,7 +75,7 @@ function Logo({
72
75
  </defs>
73
76
  </svg>
74
77
  )}
75
- {variant === LogoVariant.MARK && (
78
+ {variant === "mark" && (
76
79
  <svg
77
80
  fill="none"
78
81
  height="21"
@@ -94,4 +97,6 @@ function Logo({
94
97
  );
95
98
  }
96
99
 
100
+ Logo.displayName = "Logo";
101
+
97
102
  export { Logo };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  import * as MenubarPrimitive from "@radix-ui/react-menubar";
4
- import { Check, ChevronRight, Circle } from "lucide-react";
4
+ import { Check, ChevronRight, Circle } from "@brightlocal/icons";
5
5
 
6
6
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
7
 
@@ -25,12 +25,17 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
25
25
  function Menubar({
26
26
  className,
27
27
  dataHook,
28
+ defaultValue,
28
29
  ...props
29
30
  }: React.ComponentProps<typeof MenubarPrimitive.Root> & {
30
31
  /**
31
32
  * Required data-hook attribute for testing and analytics
32
33
  */
33
34
  dataHook: string;
35
+ /**
36
+ * The value of the menu that should be open when initially rendered (uncontrolled)
37
+ */
38
+ defaultValue?: string;
34
39
  }) {
35
40
  return (
36
41
  <MenubarPrimitive.Root
@@ -42,18 +47,29 @@ function Menubar({
42
47
  data-slot="menubar"
43
48
  data-tracking-el="menubar"
44
49
  data-tracking-label={dataHook}
50
+ defaultValue={defaultValue}
45
51
  {...props}
46
52
  />
47
53
  );
48
54
  }
49
55
 
56
+ Menubar.displayName = "Menubar";
57
+
50
58
  /**
51
59
  * MenubarMenu - Individual menu within the menubar
52
60
  */
53
61
  function MenubarMenu({
62
+ value,
54
63
  ...props
55
- }: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
56
- return <MenubarPrimitive.Menu data-slot="menubar-menu" {...props} />;
64
+ }: React.ComponentProps<typeof MenubarPrimitive.Menu> & {
65
+ /**
66
+ * A unique value that associates the menu with the menubar's defaultValue/value
67
+ */
68
+ value?: string;
69
+ }) {
70
+ return (
71
+ <MenubarPrimitive.Menu data-slot="menubar-menu" value={value} {...props} />
72
+ );
57
73
  }
58
74
 
59
75
  /**
@@ -113,9 +129,14 @@ function MenubarContent({
113
129
  */
114
130
  function MenubarItem({
115
131
  className,
132
+ disabled,
116
133
  inset,
117
134
  ...props
118
135
  }: React.ComponentProps<typeof MenubarPrimitive.Item> & {
136
+ /**
137
+ * Whether the menu item is disabled
138
+ */
139
+ disabled?: boolean;
119
140
  /**
120
141
  * Adds left padding for alignment with items that have icons
121
142
  */
@@ -132,6 +153,7 @@ function MenubarItem({
132
153
  className
133
154
  )}
134
155
  data-slot="menubar-item"
156
+ disabled={disabled}
135
157
  {...props}
136
158
  />
137
159
  );
@@ -141,20 +163,31 @@ function MenubarItem({
141
163
  * MenubarCheckboxItem - Menu item with checkbox
142
164
  */
143
165
  function MenubarCheckboxItem({
166
+ checked,
144
167
  children,
145
168
  className,
146
169
  closeOnSelect = true,
170
+ onCheckedChange,
147
171
  onSelect,
148
172
  ...props
149
173
  }: React.ComponentProps<typeof MenubarPrimitive.CheckboxItem> & {
174
+ /**
175
+ * The controlled checked state of the checkbox
176
+ */
177
+ checked?: boolean;
150
178
  /**
151
179
  * Whether to close the menu when the item is selected
152
180
  * @default true
153
181
  */
154
182
  closeOnSelect?: boolean;
183
+ /**
184
+ * Callback fired when the checked state changes
185
+ */
186
+ onCheckedChange?: (checked: boolean) => void;
155
187
  }) {
156
188
  return (
157
189
  <MenubarPrimitive.CheckboxItem
190
+ checked={checked}
158
191
  className={cn(
159
192
  "text-foreground relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors outline-none",
160
193
  "hover:bg-accent hover:text-foreground",
@@ -163,6 +196,7 @@ function MenubarCheckboxItem({
163
196
  className
164
197
  )}
165
198
  data-slot="menubar-checkbox-item"
199
+ onCheckedChange={onCheckedChange}
166
200
  onSelect={(event) => {
167
201
  if (!closeOnSelect) {
168
202
  event.preventDefault();
@@ -185,10 +219,26 @@ function MenubarCheckboxItem({
185
219
  * MenubarRadioGroup - Container for radio menu items
186
220
  */
187
221
  function MenubarRadioGroup({
222
+ onValueChange,
223
+ value,
188
224
  ...props
189
- }: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
225
+ }: React.ComponentProps<typeof MenubarPrimitive.RadioGroup> & {
226
+ /**
227
+ * Callback fired when the selected value changes
228
+ */
229
+ onValueChange?: (value: string) => void;
230
+ /**
231
+ * The controlled value of the selected radio item
232
+ */
233
+ value?: string;
234
+ }) {
190
235
  return (
191
- <MenubarPrimitive.RadioGroup data-slot="menubar-radio-group" {...props} />
236
+ <MenubarPrimitive.RadioGroup
237
+ data-slot="menubar-radio-group"
238
+ value={value}
239
+ onValueChange={onValueChange}
240
+ {...props}
241
+ />
192
242
  );
193
243
  }
194
244
 
@@ -200,6 +250,7 @@ function MenubarRadioItem({
200
250
  className,
201
251
  closeOnSelect = true,
202
252
  onSelect,
253
+ value,
203
254
  ...props
204
255
  }: React.ComponentProps<typeof MenubarPrimitive.RadioItem> & {
205
256
  /**
@@ -207,6 +258,10 @@ function MenubarRadioItem({
207
258
  * @default true
208
259
  */
209
260
  closeOnSelect?: boolean;
261
+ /**
262
+ * The unique value of the radio item
263
+ */
264
+ value: string;
210
265
  }) {
211
266
  return (
212
267
  <MenubarPrimitive.RadioItem
@@ -218,6 +273,7 @@ function MenubarRadioItem({
218
273
  className
219
274
  )}
220
275
  data-slot="menubar-radio-item"
276
+ value={value}
221
277
  onSelect={(event) => {
222
278
  if (!closeOnSelect) {
223
279
  event.preventDefault();
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as React from "react";
4
4
  import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
5
- import { ChevronDown } from "lucide-react";
5
+ import { ChevronDown } from "@brightlocal/icons";
6
6
 
7
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
8
8
 
@@ -78,25 +78,9 @@ NavigationMenuItem.displayName = "NavigationMenuItem";
78
78
  /**
79
79
  * Props for NavigationMenuTrigger component
80
80
  */
81
- interface NavigationMenuTriggerProps extends React.ComponentPropsWithoutRef<
81
+ type NavigationMenuTriggerProps = React.ComponentPropsWithoutRef<
82
82
  typeof NavigationMenuPrimitive.Trigger
83
- > {
84
- /**
85
- * Data hook for automated testing (REQUIRED)
86
- * Used to identify component in tests and E2E automation
87
- */
88
- dataHook: string;
89
- /**
90
- * Tracking element identifier for analytics
91
- * Defaults to component name if not provided
92
- */
93
- trackingEl?: string;
94
- /**
95
- * Tracking label for analytics context
96
- * Additional context for tracking events
97
- */
98
- trackingLabel?: string;
99
- }
83
+ >;
100
84
 
101
85
  /**
102
86
  * Trigger button that opens a dropdown menu
@@ -105,67 +89,43 @@ interface NavigationMenuTriggerProps extends React.ComponentPropsWithoutRef<
105
89
  const NavigationMenuTrigger = React.forwardRef<
106
90
  React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
107
91
  NavigationMenuTriggerProps
108
- >(
109
- (
110
- { className, children, dataHook, trackingEl, trackingLabel, ...props },
111
- ref
112
- ) => (
113
- <NavigationMenuPrimitive.Trigger
114
- ref={ref}
115
- className={cn(
116
- [
117
- "group inline-flex h-9 w-max items-center justify-center gap-1",
118
- "rounded-md px-4 py-2",
119
- "text-sm font-medium",
120
- "text-foreground",
121
- "transition-colors",
122
- "hover:bg-accent hover:text-accent-foreground",
123
- "focus:bg-accent focus:text-accent-foreground",
124
- "focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
125
- "disabled:pointer-events-none disabled:opacity-50",
126
- "data-[state=open]:bg-accent/50",
127
- ],
128
- className
129
- )}
130
- data-hook={dataHook}
131
- data-slot="navigation-menu-trigger"
132
- data-tracking-el={trackingEl || "navigation-menu-trigger"}
133
- data-tracking-label={trackingLabel}
134
- {...props}
135
- >
136
- {children}
137
- <ChevronDown
138
- aria-hidden="true"
139
- className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
140
- />
141
- </NavigationMenuPrimitive.Trigger>
142
- )
143
- );
92
+ >(({ className, children, ...props }, ref) => (
93
+ <NavigationMenuPrimitive.Trigger
94
+ ref={ref}
95
+ className={cn(
96
+ [
97
+ "group inline-flex h-9 w-max items-center justify-center gap-1",
98
+ "rounded-md px-4 py-2",
99
+ "text-sm font-medium",
100
+ "text-foreground",
101
+ "transition-colors",
102
+ "hover:bg-accent hover:text-accent-foreground",
103
+ "focus:bg-accent focus:text-accent-foreground",
104
+ "focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
105
+ "disabled:pointer-events-none disabled:opacity-50",
106
+ "data-[state=open]:bg-accent/50",
107
+ ],
108
+ className
109
+ )}
110
+ data-slot="navigation-menu-trigger"
111
+ {...props}
112
+ >
113
+ {children}
114
+ <ChevronDown
115
+ aria-hidden="true"
116
+ className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
117
+ />
118
+ </NavigationMenuPrimitive.Trigger>
119
+ ));
144
120
 
145
121
  NavigationMenuTrigger.displayName = "NavigationMenuTrigger";
146
122
 
147
123
  /**
148
124
  * Props for NavigationMenuContent component
149
125
  */
150
- interface NavigationMenuContentProps extends React.ComponentPropsWithoutRef<
126
+ type NavigationMenuContentProps = React.ComponentPropsWithoutRef<
151
127
  typeof NavigationMenuPrimitive.Content
152
- > {
153
- /**
154
- * Data hook for automated testing (REQUIRED)
155
- * Used to identify component in tests and E2E automation
156
- */
157
- dataHook: string;
158
- /**
159
- * Tracking element identifier for analytics
160
- * Defaults to component name if not provided
161
- */
162
- trackingEl?: string;
163
- /**
164
- * Tracking label for analytics context
165
- * Additional context for tracking events
166
- */
167
- trackingLabel?: string;
168
- }
128
+ >;
169
129
 
170
130
  /**
171
131
  * Dropdown content container
@@ -174,7 +134,7 @@ interface NavigationMenuContentProps extends React.ComponentPropsWithoutRef<
174
134
  const NavigationMenuContent = React.forwardRef<
175
135
  React.ElementRef<typeof NavigationMenuPrimitive.Content>,
176
136
  NavigationMenuContentProps
177
- >(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
137
+ >(({ className, ...props }, ref) => (
178
138
  <NavigationMenuPrimitive.Content
179
139
  ref={ref}
180
140
  className={cn(
@@ -187,10 +147,7 @@ const NavigationMenuContent = React.forwardRef<
187
147
  ],
188
148
  className
189
149
  )}
190
- data-hook={dataHook}
191
150
  data-slot="navigation-menu-content"
192
- data-tracking-el={trackingEl || "navigation-menu-content"}
193
- data-tracking-label={trackingLabel}
194
151
  {...props}
195
152
  />
196
153
  ));
@@ -200,25 +157,9 @@ NavigationMenuContent.displayName = "NavigationMenuContent";
200
157
  /**
201
158
  * Props for NavigationMenuLink component
202
159
  */
203
- interface NavigationMenuLinkProps extends React.ComponentPropsWithoutRef<
160
+ type NavigationMenuLinkProps = React.ComponentPropsWithoutRef<
204
161
  typeof NavigationMenuPrimitive.Link
205
- > {
206
- /**
207
- * Data hook for automated testing (REQUIRED)
208
- * Used to identify component in tests and E2E automation
209
- */
210
- dataHook: string;
211
- /**
212
- * Tracking element identifier for analytics
213
- * Defaults to component name if not provided
214
- */
215
- trackingEl?: string;
216
- /**
217
- * Tracking label for analytics context
218
- * Additional context for tracking events
219
- */
220
- trackingLabel?: string;
221
- }
162
+ >;
222
163
 
223
164
  /**
224
165
  * Navigation link within the menu
@@ -227,7 +168,7 @@ interface NavigationMenuLinkProps extends React.ComponentPropsWithoutRef<
227
168
  const NavigationMenuLink = React.forwardRef<
228
169
  React.ElementRef<typeof NavigationMenuPrimitive.Link>,
229
170
  NavigationMenuLinkProps
230
- >(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
171
+ >(({ className, ...props }, ref) => (
231
172
  <NavigationMenuPrimitive.Link
232
173
  ref={ref}
233
174
  className={cn(
@@ -240,10 +181,7 @@ const NavigationMenuLink = React.forwardRef<
240
181
  ],
241
182
  className
242
183
  )}
243
- data-hook={dataHook}
244
184
  data-slot="navigation-menu-link"
245
- data-tracking-el={trackingEl || "navigation-menu-link"}
246
- data-tracking-label={trackingLabel}
247
185
  {...props}
248
186
  />
249
187
  ));
@@ -3,23 +3,18 @@ import {
3
3
  ChevronLeftIcon,
4
4
  ChevronRightIcon,
5
5
  MoreHorizontalIcon,
6
- } from "lucide-react";
6
+ } from "@brightlocal/icons";
7
7
  import { cva, type VariantProps } from "class-variance-authority";
8
8
  import { cn } from "@brightlocal/ui-components/lib/utils";
9
9
 
10
10
  /**
11
11
  * Pagination item variants
12
+ * - `previous`: Previous navigation button
13
+ * - `next`: Next navigation button
14
+ * - `link`: Page number link
15
+ * - `ellipsis`: Ellipsis indicator for skipped pages
12
16
  */
13
- export enum PaginationVariant {
14
- /** Previous navigation button */
15
- PREVIOUS = "previous",
16
- /** Next navigation button */
17
- NEXT = "next",
18
- /** Page number link */
19
- LINK = "link",
20
- /** Ellipsis indicator for skipped pages */
21
- ELLIPSIS = "ellipsis",
22
- }
17
+ export type PaginationVariant = "previous" | "next" | "link" | "ellipsis";
23
18
 
24
19
  /**
25
20
  * Pagination hook parameters
@@ -167,7 +162,7 @@ const paginationItemVariants = cva(
167
162
  },
168
163
  },
169
164
  defaultVariants: {
170
- variant: PaginationVariant.LINK,
165
+ variant: "link",
171
166
  },
172
167
  }
173
168
  );
@@ -205,6 +200,8 @@ function Pagination({
205
200
  );
206
201
  }
207
202
 
203
+ Pagination.displayName = "Pagination";
204
+
208
205
  function PaginationContent({
209
206
  className,
210
207
  ...props
@@ -270,7 +267,7 @@ const PaginationPrevious = React.forwardRef<
270
267
  aria-label="Go to previous page"
271
268
  className={className}
272
269
  disabled={disabled}
273
- variant={PaginationVariant.PREVIOUS}
270
+ variant="previous"
274
271
  {...props}
275
272
  >
276
273
  <ChevronLeftIcon className="size-4" />
@@ -294,7 +291,7 @@ const PaginationNext = React.forwardRef<HTMLButtonElement, PaginationNextProps>(
294
291
  aria-label="Go to next page"
295
292
  className={className}
296
293
  disabled={disabled}
297
- variant={PaginationVariant.NEXT}
294
+ variant="next"
298
295
  {...props}
299
296
  >
300
297
  <ChevronRightIcon className="size-4" />
@@ -318,7 +315,7 @@ const PaginationLink = React.forwardRef<HTMLButtonElement, PaginationLinkProps>(
318
315
  aria-label={`Go to page ${page}`}
319
316
  className={className}
320
317
  isActive={isActive}
321
- variant={PaginationVariant.LINK}
318
+ variant="link"
322
319
  {...props}
323
320
  >
324
321
  {page}
@@ -336,10 +333,7 @@ function PaginationEllipsis({
336
333
  return (
337
334
  <span
338
335
  aria-hidden="true"
339
- className={cn(
340
- paginationItemVariants({ variant: PaginationVariant.ELLIPSIS }),
341
- className
342
- )}
336
+ className={cn(paginationItemVariants({ variant: "ellipsis" }), className)}
343
337
  data-slot="pagination-ellipsis"
344
338
  {...props}
345
339
  >
@@ -1,46 +1,129 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
  import * as PopoverPrimitive from "@radix-ui/react-popover";
3
5
 
4
6
  import { cn } from "@brightlocal/ui-components/lib/utils";
5
7
 
6
- function Popover({
7
- ...props
8
- }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
8
+ export interface PopoverProps extends React.ComponentProps<
9
+ typeof PopoverPrimitive.Root
10
+ > {
11
+ /** The open state when initially rendered. Use when you do not need to control the open state. */
12
+ defaultOpen?: boolean;
13
+ /** The controlled open state of the popover. */
14
+ open?: boolean;
15
+ /** Event handler called when the open state of the popover changes. */
16
+ onOpenChange?: (open: boolean) => void;
17
+ /** When true, interaction with outside elements is disabled and only popover content is visible to screen readers. */
18
+ modal?: boolean;
19
+ }
20
+
21
+ /**
22
+ * Contains all the parts of a popover.
23
+ */
24
+ function Popover({ ...props }: PopoverProps) {
9
25
  return <PopoverPrimitive.Root data-slot="popover" {...props} />;
10
26
  }
27
+ Popover.displayName = "Popover";
28
+
29
+ export interface PopoverTriggerProps extends React.ComponentProps<
30
+ typeof PopoverPrimitive.Trigger
31
+ > {
32
+ /** Change the default rendered element for the one passed as a child, merging their props and behavior. */
33
+ asChild?: boolean;
34
+ /** Test hook identifier for testing purposes. */
35
+ dataHook?: string;
36
+ }
37
+
38
+ /**
39
+ * The button that toggles the popover.
40
+ */
41
+ const PopoverTrigger = React.forwardRef<
42
+ React.ComponentRef<typeof PopoverPrimitive.Trigger>,
43
+ PopoverTriggerProps
44
+ >(({ dataHook, ...props }, ref) => (
45
+ <PopoverPrimitive.Trigger
46
+ ref={ref}
47
+ data-hook={dataHook}
48
+ data-slot="popover-trigger"
49
+ {...props}
50
+ />
51
+ ));
52
+ PopoverTrigger.displayName = "PopoverTrigger";
11
53
 
12
- function PopoverTrigger({
13
- ...props
14
- }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
15
- return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
54
+ export interface PopoverContentProps extends React.ComponentProps<
55
+ typeof PopoverPrimitive.Content
56
+ > {
57
+ /** Test hook identifier for testing purposes. */
58
+ dataHook?: string;
59
+ /** The preferred side of the anchor to render against. Will be reversed when collisions occur. */
60
+ side?: "top" | "right" | "bottom" | "left";
61
+ /** The distance in pixels from the anchor. */
62
+ sideOffset?: number;
63
+ /** The preferred alignment against the anchor. May change when collisions occur. */
64
+ align?: "start" | "center" | "end";
65
+ /** An offset in pixels from the "start" or "end" alignment options. */
66
+ alignOffset?: number;
67
+ /** When true, overrides side and align to prevent collisions with boundary edges. */
68
+ avoidCollisions?: boolean;
69
+ /** The sticky behavior on the align axis. "partial" keeps content in boundary as long as trigger is at least partially in boundary. */
70
+ sticky?: "partial" | "always";
71
+ /** Whether to hide content when the trigger becomes fully occluded. */
72
+ hideWhenDetached?: boolean;
16
73
  }
17
74
 
18
- function PopoverContent({
19
- className,
20
- align = "center",
21
- sideOffset = 4,
22
- ...props
23
- }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
24
- return (
75
+ /**
76
+ * The component that pops out when the popover is open.
77
+ */
78
+ const PopoverContent = React.forwardRef<
79
+ React.ComponentRef<typeof PopoverPrimitive.Content>,
80
+ PopoverContentProps
81
+ >(
82
+ (
83
+ { className, align = "center", sideOffset = 4, dataHook, ...props },
84
+ ref
85
+ ) => (
25
86
  <PopoverPrimitive.Portal>
26
87
  <PopoverPrimitive.Content
88
+ ref={ref}
27
89
  align={align}
28
90
  className={cn(
29
91
  "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
30
92
  className
31
93
  )}
94
+ data-hook={dataHook}
32
95
  data-slot="popover-content"
33
96
  sideOffset={sideOffset}
34
97
  {...props}
35
98
  />
36
99
  </PopoverPrimitive.Portal>
37
- );
38
- }
100
+ )
101
+ );
102
+ PopoverContent.displayName = "PopoverContent";
39
103
 
40
- function PopoverAnchor({
41
- ...props
42
- }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
43
- return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;
104
+ export interface PopoverAnchorProps extends React.ComponentProps<
105
+ typeof PopoverPrimitive.Anchor
106
+ > {
107
+ /** Change the default rendered element for the one passed as a child, merging their props and behavior. */
108
+ asChild?: boolean;
109
+ /** Test hook identifier for testing purposes. */
110
+ dataHook?: string;
44
111
  }
45
112
 
113
+ /**
114
+ * An optional element to position the popover against. If not used, the popover will position against the trigger.
115
+ */
116
+ const PopoverAnchor = React.forwardRef<
117
+ React.ComponentRef<typeof PopoverPrimitive.Anchor>,
118
+ PopoverAnchorProps
119
+ >(({ dataHook, ...props }, ref) => (
120
+ <PopoverPrimitive.Anchor
121
+ ref={ref}
122
+ data-hook={dataHook}
123
+ data-slot="popover-anchor"
124
+ {...props}
125
+ />
126
+ ));
127
+ PopoverAnchor.displayName = "PopoverAnchor";
128
+
46
129
  export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };