@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,368 @@
1
+ import * as React from "react";
2
+ import {
3
+ ChevronLeftIcon,
4
+ ChevronRightIcon,
5
+ MoreHorizontalIcon,
6
+ } from "lucide-react";
7
+ import { cva, type VariantProps } from "class-variance-authority";
8
+ import { cn } from "@brightlocal/ui-components/lib/utils";
9
+
10
+ /**
11
+ * Pagination item variants
12
+ */
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
+ }
23
+
24
+ /**
25
+ * Pagination hook parameters
26
+ */
27
+ export interface UsePaginationParams {
28
+ /** Current page number (1-indexed) */
29
+ page: number;
30
+ /** Total number of pages */
31
+ totalPages: number;
32
+ /** Number of siblings to show on each side of current page */
33
+ siblingCount?: number;
34
+ /** Number of boundary pages to show at start and end */
35
+ boundaryCount?: number;
36
+ }
37
+
38
+ /**
39
+ * Pagination item type - can be a page number, "previous", "next", or "ellipsis"
40
+ */
41
+ type PaginationItemType = number | "previous" | "next" | "ellipsis";
42
+
43
+ /**
44
+ * Custom hook for pagination logic
45
+ * Returns an ordered list of pagination items to render
46
+ *
47
+ * @example
48
+ * const items = usePagination({ page: 5, totalPages: 10, siblingCount: 1, boundaryCount: 1 });
49
+ * // Returns: ["previous", 1, "ellipsis", 4, 5, 6, "ellipsis", 10, "next"]
50
+ */
51
+ export function usePagination({
52
+ page,
53
+ totalPages,
54
+ siblingCount = 1,
55
+ boundaryCount = 1,
56
+ }: UsePaginationParams): PaginationItemType[] {
57
+ const items: PaginationItemType[] = React.useMemo(() => {
58
+ const result: PaginationItemType[] = [];
59
+
60
+ // Add previous button
61
+ result.push("previous");
62
+
63
+ // Calculate ranges
64
+ const leftSiblingIndex = Math.max(page - siblingCount, boundaryCount + 1);
65
+ const rightSiblingIndex = Math.min(
66
+ page + siblingCount,
67
+ totalPages - boundaryCount
68
+ );
69
+
70
+ const showLeftEllipsis = leftSiblingIndex > boundaryCount + 2;
71
+ const showRightEllipsis =
72
+ rightSiblingIndex < totalPages - boundaryCount - 1;
73
+
74
+ // Add first boundary pages
75
+ for (let i = 1; i <= Math.min(boundaryCount, totalPages); i++) {
76
+ result.push(i);
77
+ }
78
+
79
+ // Add left ellipsis if needed
80
+ if (showLeftEllipsis) {
81
+ result.push("ellipsis");
82
+ } else if (boundaryCount + 1 < leftSiblingIndex) {
83
+ // Add pages between boundary and left sibling
84
+ for (let i = boundaryCount + 1; i < leftSiblingIndex; i++) {
85
+ result.push(i);
86
+ }
87
+ }
88
+
89
+ // Add sibling pages around current page
90
+ for (let i = leftSiblingIndex; i <= rightSiblingIndex; i++) {
91
+ if (i > boundaryCount && i <= totalPages - boundaryCount) {
92
+ result.push(i);
93
+ }
94
+ }
95
+
96
+ // Add right ellipsis if needed
97
+ if (showRightEllipsis) {
98
+ result.push("ellipsis");
99
+ } else if (rightSiblingIndex < totalPages - boundaryCount) {
100
+ // Add pages between right sibling and boundary
101
+ for (
102
+ let i = rightSiblingIndex + 1;
103
+ i < totalPages - boundaryCount + 1;
104
+ i++
105
+ ) {
106
+ result.push(i);
107
+ }
108
+ }
109
+
110
+ // Add last boundary pages
111
+ for (
112
+ let i = Math.max(totalPages - boundaryCount + 1, boundaryCount + 1);
113
+ i <= totalPages;
114
+ i++
115
+ ) {
116
+ if (i > boundaryCount) {
117
+ result.push(i);
118
+ }
119
+ }
120
+
121
+ // Add next button
122
+ result.push("next");
123
+
124
+ return result;
125
+ }, [page, totalPages, siblingCount, boundaryCount]);
126
+
127
+ return items;
128
+ }
129
+
130
+ const paginationItemVariants = cva(
131
+ [
132
+ // Base styles - circular button
133
+ "inline-flex items-center justify-center",
134
+ "h-9 w-9",
135
+ "rounded-full",
136
+ "text-sm font-medium",
137
+ "transition-colors",
138
+ "focus-visible:outline-none focus-visible:shadow-default",
139
+ ],
140
+ {
141
+ variants: {
142
+ variant: {
143
+ previous: [
144
+ "text-foreground",
145
+ "hover:bg-accent",
146
+ "aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none",
147
+ ],
148
+ next: [
149
+ "text-foreground",
150
+ "hover:bg-accent",
151
+ "aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none",
152
+ ],
153
+ link: [
154
+ "text-foreground",
155
+ "hover:bg-accent hover:text-accent-foreground",
156
+ // Active state: white background with border (light), input/30 background (dark)
157
+ "aria-[current=page]:bg-background aria-[current=page]:border aria-[current=page]:border-input",
158
+ "dark:aria-[current=page]:bg-input/30",
159
+ // Active + Hover: accent background with border
160
+ "aria-[current=page]:hover:bg-accent",
161
+ // Active + Focus: darker border (handled by shadow-default from base)
162
+ "aria-[current=page]:focus-visible:border-ring",
163
+ // Disabled state
164
+ "aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none",
165
+ ],
166
+ ellipsis: ["cursor-default", "text-foreground", "pointer-events-none"],
167
+ },
168
+ },
169
+ defaultVariants: {
170
+ variant: PaginationVariant.LINK,
171
+ },
172
+ }
173
+ );
174
+
175
+ interface PaginationProps extends React.ComponentProps<"nav"> {
176
+ /** Data hook for automated testing (REQUIRED) */
177
+ dataHook: string;
178
+ /** Tracking element identifier for analytics */
179
+ trackingEl?: string;
180
+ /** Tracking label for analytics context */
181
+ trackingLabel?: string;
182
+ /** Accessible label for the pagination navigation (for unique landmark identification) */
183
+ ariaLabel?: string;
184
+ }
185
+
186
+ function Pagination({
187
+ className,
188
+ dataHook,
189
+ trackingEl,
190
+ trackingLabel,
191
+ ariaLabel = "Pagination",
192
+ ...props
193
+ }: PaginationProps) {
194
+ return (
195
+ <nav
196
+ aria-label={ariaLabel}
197
+ className={cn("mx-auto flex w-full justify-center", className)}
198
+ data-hook={dataHook}
199
+ data-slot="pagination"
200
+ data-tracking-el={trackingEl || "pagination"}
201
+ data-tracking-label={trackingLabel}
202
+ role="navigation"
203
+ {...props}
204
+ />
205
+ );
206
+ }
207
+
208
+ function PaginationContent({
209
+ className,
210
+ ...props
211
+ }: React.ComponentProps<"ul">) {
212
+ return (
213
+ <ul
214
+ className={cn("flex flex-row items-center gap-2", className)}
215
+ data-slot="pagination-content"
216
+ {...props}
217
+ />
218
+ );
219
+ }
220
+
221
+ function PaginationItem(props: React.ComponentProps<"li">) {
222
+ return <li data-slot="pagination-item" {...props} />;
223
+ }
224
+
225
+ interface PaginationButtonProps
226
+ extends
227
+ Omit<React.ComponentProps<"button">, "variant">,
228
+ VariantProps<typeof paginationItemVariants> {
229
+ /** Whether this page is the current page */
230
+ isActive?: boolean;
231
+ }
232
+
233
+ const PaginationButton = React.forwardRef<
234
+ HTMLButtonElement,
235
+ PaginationButtonProps
236
+ >(({ className, variant, isActive, children, ...props }, ref) => {
237
+ return (
238
+ <button
239
+ ref={ref}
240
+ aria-current={isActive ? "page" : undefined}
241
+ className={cn(paginationItemVariants({ variant }), className)}
242
+ data-active={isActive}
243
+ data-slot="pagination-button"
244
+ type="button"
245
+ {...props}
246
+ >
247
+ {children}
248
+ </button>
249
+ );
250
+ });
251
+
252
+ PaginationButton.displayName = "PaginationButton";
253
+
254
+ interface PaginationPreviousProps extends Omit<
255
+ PaginationButtonProps,
256
+ "variant"
257
+ > {
258
+ /** Whether the previous button is disabled (on first page) */
259
+ disabled?: boolean;
260
+ }
261
+
262
+ const PaginationPrevious = React.forwardRef<
263
+ HTMLButtonElement,
264
+ PaginationPreviousProps
265
+ >(({ className, disabled, ...props }, ref) => {
266
+ return (
267
+ <PaginationButton
268
+ ref={ref}
269
+ aria-disabled={disabled}
270
+ aria-label="Go to previous page"
271
+ className={className}
272
+ disabled={disabled}
273
+ variant={PaginationVariant.PREVIOUS}
274
+ {...props}
275
+ >
276
+ <ChevronLeftIcon className="size-4" />
277
+ </PaginationButton>
278
+ );
279
+ });
280
+
281
+ PaginationPrevious.displayName = "PaginationPrevious";
282
+
283
+ interface PaginationNextProps extends Omit<PaginationButtonProps, "variant"> {
284
+ /** Whether the next button is disabled (on last page) */
285
+ disabled?: boolean;
286
+ }
287
+
288
+ const PaginationNext = React.forwardRef<HTMLButtonElement, PaginationNextProps>(
289
+ ({ className, disabled, ...props }, ref) => {
290
+ return (
291
+ <PaginationButton
292
+ ref={ref}
293
+ aria-disabled={disabled}
294
+ aria-label="Go to next page"
295
+ className={className}
296
+ disabled={disabled}
297
+ variant={PaginationVariant.NEXT}
298
+ {...props}
299
+ >
300
+ <ChevronRightIcon className="size-4" />
301
+ </PaginationButton>
302
+ );
303
+ }
304
+ );
305
+
306
+ PaginationNext.displayName = "PaginationNext";
307
+
308
+ interface PaginationLinkProps extends Omit<PaginationButtonProps, "variant"> {
309
+ /** Page number to display */
310
+ page: number;
311
+ }
312
+
313
+ const PaginationLink = React.forwardRef<HTMLButtonElement, PaginationLinkProps>(
314
+ ({ className, page, isActive, ...props }, ref) => {
315
+ return (
316
+ <PaginationButton
317
+ ref={ref}
318
+ aria-label={`Go to page ${page}`}
319
+ className={className}
320
+ isActive={isActive}
321
+ variant={PaginationVariant.LINK}
322
+ {...props}
323
+ >
324
+ {page}
325
+ </PaginationButton>
326
+ );
327
+ }
328
+ );
329
+
330
+ PaginationLink.displayName = "PaginationLink";
331
+
332
+ function PaginationEllipsis({
333
+ className,
334
+ ...props
335
+ }: React.ComponentProps<"span">) {
336
+ return (
337
+ <span
338
+ aria-hidden="true"
339
+ className={cn(
340
+ paginationItemVariants({ variant: PaginationVariant.ELLIPSIS }),
341
+ className
342
+ )}
343
+ data-slot="pagination-ellipsis"
344
+ {...props}
345
+ >
346
+ <MoreHorizontalIcon className="size-4" />
347
+ <span className="sr-only">More pages</span>
348
+ </span>
349
+ );
350
+ }
351
+
352
+ export type { PaginationItemType };
353
+
354
+ export {
355
+ Pagination,
356
+ PaginationContent,
357
+ PaginationItem,
358
+ PaginationButton,
359
+ PaginationLink,
360
+ PaginationPrevious,
361
+ PaginationNext,
362
+ PaginationEllipsis,
363
+ type PaginationProps,
364
+ type PaginationButtonProps,
365
+ type PaginationLinkProps,
366
+ type PaginationPreviousProps,
367
+ type PaginationNextProps,
368
+ };
@@ -0,0 +1,46 @@
1
+ import * as React from "react";
2
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
3
+
4
+ import { cn } from "@brightlocal/ui-components/lib/utils";
5
+
6
+ function Popover({
7
+ ...props
8
+ }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
9
+ return <PopoverPrimitive.Root data-slot="popover" {...props} />;
10
+ }
11
+
12
+ function PopoverTrigger({
13
+ ...props
14
+ }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
15
+ return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
16
+ }
17
+
18
+ function PopoverContent({
19
+ className,
20
+ align = "center",
21
+ sideOffset = 4,
22
+ ...props
23
+ }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
24
+ return (
25
+ <PopoverPrimitive.Portal>
26
+ <PopoverPrimitive.Content
27
+ align={align}
28
+ className={cn(
29
+ "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
+ className
31
+ )}
32
+ data-slot="popover-content"
33
+ sideOffset={sideOffset}
34
+ {...props}
35
+ />
36
+ </PopoverPrimitive.Portal>
37
+ );
38
+ }
39
+
40
+ function PopoverAnchor({
41
+ ...props
42
+ }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
43
+ return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;
44
+ }
45
+
46
+ export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
@@ -0,0 +1,100 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as ProgressPrimitive from "@radix-ui/react-progress";
5
+ import { motion } from "framer-motion";
6
+
7
+ import { cn } from "@brightlocal/ui-components/lib/utils";
8
+
9
+ interface ProgressProps extends React.ComponentProps<
10
+ typeof ProgressPrimitive.Root
11
+ > {
12
+ /**
13
+ * Required data-hook attribute for testing and component identification
14
+ */
15
+ dataHook: string;
16
+ /**
17
+ * Optional tracking element identifier for analytics
18
+ */
19
+ trackingEl?: string;
20
+ /**
21
+ * Optional tracking label for analytics
22
+ */
23
+ trackingLabel?: string;
24
+ /**
25
+ * Accessible label for the progress bar for screen readers
26
+ * Defaults to "Progress" if not provided
27
+ */
28
+ ariaLabel?: string;
29
+ /**
30
+ * Optional visible label text displayed above the progress bar
31
+ */
32
+ label?: string;
33
+ }
34
+
35
+ function Progress({
36
+ className,
37
+ value,
38
+ dataHook,
39
+ trackingEl,
40
+ trackingLabel,
41
+ ariaLabel = "Progress",
42
+ label,
43
+ ...props
44
+ }: ProgressProps) {
45
+ const labelId = React.useId();
46
+ const hasVisibleLabel = !!label;
47
+
48
+ const progressBar = (
49
+ <ProgressPrimitive.Root
50
+ aria-label={hasVisibleLabel ? undefined : ariaLabel}
51
+ aria-labelledby={hasVisibleLabel ? labelId : undefined}
52
+ className={cn(
53
+ "relative h-2 w-full overflow-hidden rounded-full",
54
+ "bg-primary/20",
55
+ className
56
+ )}
57
+ data-hook={dataHook}
58
+ data-slot="progress"
59
+ data-tracking-el={trackingEl}
60
+ data-tracking-label={trackingLabel}
61
+ {...props}
62
+ >
63
+ <ProgressPrimitive.Indicator asChild>
64
+ <motion.div
65
+ animate={{
66
+ transform: `translateX(-${100 - (value || 0)}%)`,
67
+ }}
68
+ className="h-full w-full flex-1 bg-green-400"
69
+ data-slot="progress-indicator"
70
+ initial={false}
71
+ transition={{
72
+ type: "spring",
73
+ stiffness: 80,
74
+ damping: 20,
75
+ mass: 1,
76
+ }}
77
+ />
78
+ </ProgressPrimitive.Indicator>
79
+ </ProgressPrimitive.Root>
80
+ );
81
+
82
+ if (!label) {
83
+ return progressBar;
84
+ }
85
+
86
+ return (
87
+ <div className="flex w-full items-center gap-2">
88
+ <span
89
+ className="text-foreground text-sm leading-normal font-medium"
90
+ id={labelId}
91
+ >
92
+ {label}
93
+ </span>
94
+ {progressBar}
95
+ </div>
96
+ );
97
+ }
98
+
99
+ export { Progress };
100
+ export type { ProgressProps };