@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,442 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SelectPrimitive from "@radix-ui/react-select";
5
+ import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
6
+ import { cva } from "class-variance-authority";
7
+
8
+ import { cn } from "@brightlocal/ui-components/lib/utils";
9
+ import { Label } from "@brightlocal/ui-components/label";
10
+
11
+ // ============================================================================
12
+ // Types
13
+ // ============================================================================
14
+
15
+ interface SelectProps extends React.ComponentProps<
16
+ typeof SelectPrimitive.Root
17
+ > {
18
+ /** Label text displayed above the select */
19
+ label?: string;
20
+ /** Helper text displayed below the select */
21
+ description?: string;
22
+ /** Shows required indicator (*) next to label */
23
+ optional?: boolean;
24
+ /** Placeholder text when no value is selected */
25
+ placeholder?: string;
26
+ /** Children to render inside the select */
27
+ children?: React.ReactNode;
28
+ /** Accessible label for screen readers when no visible label is provided */
29
+ "aria-label"?: string;
30
+ }
31
+
32
+ // ============================================================================
33
+ // Main Select Component
34
+ // ============================================================================
35
+
36
+ /**
37
+ * Select component with optional label and description.
38
+ * Wraps Radix UI Select with additional accessibility and styling features.
39
+ * Error state should be managed via Form components (FormMessage).
40
+ */
41
+ function Select({
42
+ label,
43
+ description,
44
+ optional,
45
+ placeholder,
46
+ children,
47
+ "aria-label": ariaLabel,
48
+ ...props
49
+ }: SelectProps) {
50
+ // Generate unique IDs for accessibility
51
+ const id = React.useId();
52
+ const labelId = `${id}-label`;
53
+ const descriptionId = `${id}-description`;
54
+
55
+ const helperText = description;
56
+ const hasWrapper = label || helperText;
57
+
58
+ // Props to inject into SelectTrigger
59
+ const triggerProps = {
60
+ placeholder,
61
+ "aria-required": optional ? undefined : true,
62
+ "aria-label": ariaLabel,
63
+ };
64
+
65
+ // Add accessibility props when wrapped with label/description
66
+ const wrappedTriggerProps = {
67
+ ...triggerProps,
68
+ id,
69
+ };
70
+
71
+ // Helper function to clone SelectTrigger with props
72
+ const enhanceTrigger = (child: React.ReactNode, additionalProps: object) => {
73
+ if (React.isValidElement(child) && child.type === SelectTrigger) {
74
+ return React.cloneElement(
75
+ child as React.ReactElement<SelectTriggerProps>,
76
+ additionalProps
77
+ );
78
+ }
79
+ return child;
80
+ };
81
+
82
+ // Simple select without wrapper
83
+ if (!hasWrapper) {
84
+ return (
85
+ <SelectPrimitive.Root data-slot="select" {...props}>
86
+ {React.Children.map(children, (child) =>
87
+ enhanceTrigger(child, triggerProps)
88
+ )}
89
+ </SelectPrimitive.Root>
90
+ );
91
+ }
92
+
93
+ // Select with label and/or description wrapper
94
+ return (
95
+ <div className="flex flex-col gap-2">
96
+ {label && (
97
+ <Label htmlFor={id} id={labelId} optional={optional}>
98
+ {label}
99
+ </Label>
100
+ )}
101
+
102
+ <SelectPrimitive.Root data-slot="select" {...props}>
103
+ {React.Children.map(children, (child) =>
104
+ enhanceTrigger(child, wrappedTriggerProps)
105
+ )}
106
+ </SelectPrimitive.Root>
107
+
108
+ {helperText && (
109
+ <p className="text-muted-foreground text-sm" id={descriptionId}>
110
+ {helperText}
111
+ </p>
112
+ )}
113
+ </div>
114
+ );
115
+ }
116
+
117
+ /**
118
+ * SelectGroup - Groups related select options together
119
+ */
120
+ function SelectGroup(
121
+ props: React.ComponentProps<typeof SelectPrimitive.Group>
122
+ ) {
123
+ return <SelectPrimitive.Group data-slot="select-group" {...props} />;
124
+ }
125
+
126
+ /**
127
+ * SelectValue - Displays the selected value in the trigger
128
+ */
129
+ function SelectValue(
130
+ props: React.ComponentProps<typeof SelectPrimitive.Value>
131
+ ) {
132
+ return <SelectPrimitive.Value data-slot="select-value" {...props} />;
133
+ }
134
+
135
+ // ============================================================================
136
+ // Styles
137
+ // ============================================================================
138
+
139
+ const selectTriggerVariants = cva([
140
+ // Base layout
141
+ "relative flex w-full h-9 items-center justify-between gap-2",
142
+ "px-3 py-2",
143
+
144
+ // Base appearance
145
+ "border border-border rounded-lg outline-none transition-all",
146
+ "bg-neutral-50 border-neutral-300",
147
+ "dark:bg-white/5 dark:border-white/15",
148
+
149
+ // Typography
150
+ "text-sm font-normal font-sans text-foreground",
151
+
152
+ // Text truncation for long content (shadcn default behavior)
153
+ "[&>span]:block [&>span]:truncate",
154
+
155
+ // Placeholder state
156
+ "data-[placeholder]:text-muted-foreground",
157
+
158
+ // Focus state (keyboard navigation only - not on click)
159
+ "focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background",
160
+ "focus-visible:shadow-default",
161
+
162
+ // Open dropdown state
163
+ "data-[state=open]:border-ring",
164
+
165
+ // Disabled state
166
+ "disabled:cursor-not-allowed disabled:opacity-50",
167
+
168
+ // Icon styles (chevron and custom icons)
169
+ "[&_svg]:pointer-events-none [&_svg]:shrink-0",
170
+ "[&_svg:not([class*='size-'])]:size-4",
171
+ "[&_svg:not([class*='text-'])]:text-muted-foreground",
172
+ ]);
173
+
174
+ interface SelectTriggerProps extends React.ComponentProps<
175
+ typeof SelectPrimitive.Trigger
176
+ > {
177
+ /** Placeholder text when no value is selected */
178
+ placeholder?: string;
179
+ /** Data hook for testing and automation */
180
+ dataHook?: string;
181
+ }
182
+
183
+ // ============================================================================
184
+ // Select Components
185
+ // ============================================================================
186
+
187
+ /**
188
+ * SelectTrigger - The button that opens the select dropdown
189
+ */
190
+ function SelectTrigger({
191
+ className,
192
+ children,
193
+ placeholder,
194
+ dataHook,
195
+ ...props
196
+ }: SelectTriggerProps) {
197
+ // Parse aria attributes
198
+ const isError =
199
+ props["aria-invalid"] === true || props["aria-invalid"] === "true";
200
+ const isRequired =
201
+ props["aria-required"] === true || props["aria-required"] === "true";
202
+
203
+ // Provide fallback label for accessibility
204
+ const ariaLabel = props["aria-label"] || placeholder || "Select an option";
205
+
206
+ const errorStyles = isError
207
+ ? "border-destructive dark:border-destructive " +
208
+ "focus-visible:border-destructive focus-visible:shadow-destructive"
209
+ : "";
210
+
211
+ return (
212
+ <SelectPrimitive.Trigger
213
+ {...props}
214
+ aria-invalid={isError ? "true" : undefined}
215
+ aria-label={ariaLabel}
216
+ aria-required={isRequired ? "true" : undefined}
217
+ className={cn(selectTriggerVariants(), errorStyles, className)}
218
+ data-hook={dataHook}
219
+ data-slot="select-trigger"
220
+ >
221
+ {/* Select value or placeholder */}
222
+ {children}
223
+
224
+ {/* Dropdown chevron (right side) */}
225
+ <SelectPrimitive.Icon asChild>
226
+ <ChevronDownIcon className="text-muted-foreground size-4" />
227
+ </SelectPrimitive.Icon>
228
+ </SelectPrimitive.Trigger>
229
+ );
230
+ }
231
+
232
+ /**
233
+ * SelectContent - The dropdown container for select options
234
+ */
235
+ function SelectContent({
236
+ className,
237
+ children,
238
+ position = "popper",
239
+ ...props
240
+ }: React.ComponentProps<typeof SelectPrimitive.Content>) {
241
+ const baseStyles = cn(
242
+ // Base appearance
243
+ "relative z-50 overflow-hidden",
244
+ "min-w-[8rem]",
245
+ "rounded-md border border-border bg-popover shadow-md",
246
+ "text-popover-foreground",
247
+
248
+ // Size constraints using Radix CSS variables
249
+ "max-h-[var(--radix-select-content-available-height)]",
250
+ "origin-[var(--radix-select-content-transform-origin)]",
251
+
252
+ // Animations
253
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
254
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
255
+ "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
256
+ "data-[side=bottom]:slide-in-from-top-2",
257
+ "data-[side=left]:slide-in-from-right-2",
258
+ "data-[side=right]:slide-in-from-left-2",
259
+ "data-[side=top]:slide-in-from-bottom-2"
260
+ );
261
+
262
+ const popperStyles =
263
+ position === "popper" &&
264
+ cn(
265
+ "data-[side=bottom]:translate-y-1",
266
+ "data-[side=left]:-translate-x-1",
267
+ "data-[side=right]:translate-x-1",
268
+ "data-[side=top]:-translate-y-1"
269
+ );
270
+
271
+ return (
272
+ <SelectPrimitive.Portal>
273
+ <SelectPrimitive.Content
274
+ className={cn(baseStyles, popperStyles, className)}
275
+ data-slot="select-content"
276
+ position={position}
277
+ {...props}
278
+ >
279
+ <SelectScrollUpButton />
280
+ <SelectPrimitive.Viewport
281
+ className={cn(
282
+ "p-1",
283
+ position === "popper" &&
284
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
285
+ )}
286
+ >
287
+ {children}
288
+ </SelectPrimitive.Viewport>
289
+ <SelectScrollDownButton />
290
+ </SelectPrimitive.Content>
291
+ </SelectPrimitive.Portal>
292
+ );
293
+ }
294
+
295
+ /**
296
+ * SelectLabel - Label for a group of select options
297
+ */
298
+ function SelectLabel({
299
+ className,
300
+ ...props
301
+ }: React.ComponentProps<typeof SelectPrimitive.Label>) {
302
+ return (
303
+ <SelectPrimitive.Label
304
+ className={cn(
305
+ "text-muted-foreground px-2 py-1.5 text-xs font-medium",
306
+ className
307
+ )}
308
+ data-slot="select-label"
309
+ {...props}
310
+ />
311
+ );
312
+ }
313
+
314
+ /**
315
+ * SelectItem - Individual selectable option in the dropdown
316
+ *
317
+ * Usage:
318
+ * 1. Simple text: <SelectItem value="apple">Apple</SelectItem>
319
+ * 2. With icon (appears in trigger):
320
+ * <SelectItem value="apple">
321
+ * <div className="flex items-center gap-2">
322
+ * <AppleIcon className="size-4" />
323
+ * Apple
324
+ * </div>
325
+ * </SelectItem>
326
+ */
327
+ function SelectItem({
328
+ className,
329
+ children,
330
+ ...props
331
+ }: React.ComponentProps<typeof SelectPrimitive.Item>) {
332
+ const itemStyles = cn(
333
+ // Base layout
334
+ "relative flex w-full cursor-default select-none items-center gap-2",
335
+ "rounded py-1.5 pl-2 pr-8",
336
+
337
+ // Typography
338
+ "text-sm font-normal leading-5 text-popover-foreground",
339
+
340
+ // Interactive states
341
+ "focus:bg-accent focus:text-accent-foreground",
342
+ "hover:bg-accent/50 hover:text-accent-foreground",
343
+ "outline-none focus:outline-none",
344
+
345
+ // Disabled state
346
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
347
+
348
+ // Icon styles
349
+ "[&_svg]:pointer-events-none [&_svg]:shrink-0",
350
+ "[&_svg:not([class*='size-'])]:size-4",
351
+ "[&_svg:not([class*='text-'])]:text-foreground"
352
+ );
353
+
354
+ return (
355
+ <SelectPrimitive.Item
356
+ className={cn(itemStyles, className)}
357
+ data-slot="select-item"
358
+ {...props}
359
+ >
360
+ <span className="absolute right-2 flex size-4 items-center justify-center">
361
+ <SelectPrimitive.ItemIndicator>
362
+ <CheckIcon className="size-4" />
363
+ </SelectPrimitive.ItemIndicator>
364
+ </span>
365
+
366
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
367
+ </SelectPrimitive.Item>
368
+ );
369
+ }
370
+
371
+ /**
372
+ * SelectSeparator - Visual separator between select items or groups
373
+ */
374
+ function SelectSeparator({
375
+ className,
376
+ ...props
377
+ }: React.ComponentProps<typeof SelectPrimitive.Separator>) {
378
+ return (
379
+ <SelectPrimitive.Separator
380
+ className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
381
+ data-slot="select-separator"
382
+ {...props}
383
+ />
384
+ );
385
+ }
386
+
387
+ /**
388
+ * SelectScrollUpButton - Button to scroll up in the dropdown (when content overflows)
389
+ */
390
+ function SelectScrollUpButton({
391
+ className,
392
+ ...props
393
+ }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
394
+ return (
395
+ <SelectPrimitive.ScrollUpButton
396
+ className={cn(
397
+ "flex cursor-default items-center justify-center py-1",
398
+ className
399
+ )}
400
+ data-slot="select-scroll-up-button"
401
+ {...props}
402
+ >
403
+ <ChevronUpIcon className="size-4" />
404
+ </SelectPrimitive.ScrollUpButton>
405
+ );
406
+ }
407
+
408
+ /**
409
+ * SelectScrollDownButton - Button to scroll down in the dropdown (when content overflows)
410
+ */
411
+ function SelectScrollDownButton({
412
+ className,
413
+ ...props
414
+ }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
415
+ return (
416
+ <SelectPrimitive.ScrollDownButton
417
+ className={cn(
418
+ "flex cursor-default items-center justify-center py-1",
419
+ className
420
+ )}
421
+ data-slot="select-scroll-down-button"
422
+ {...props}
423
+ >
424
+ <ChevronDownIcon className="size-4" />
425
+ </SelectPrimitive.ScrollDownButton>
426
+ );
427
+ }
428
+
429
+ export {
430
+ Select,
431
+ SelectContent,
432
+ SelectGroup,
433
+ SelectItem,
434
+ SelectLabel,
435
+ SelectScrollDownButton,
436
+ SelectScrollUpButton,
437
+ SelectSeparator,
438
+ SelectTrigger,
439
+ SelectValue,
440
+ };
441
+
442
+ export type { SelectProps, SelectTriggerProps };
@@ -0,0 +1,53 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
5
+
6
+ import { cn } from "@brightlocal/ui-components/lib/utils";
7
+
8
+ export enum SeparatorOrientation {
9
+ HORIZONTAL = "horizontal",
10
+ VERTICAL = "vertical",
11
+ }
12
+
13
+ function Separator({
14
+ className,
15
+ orientation = SeparatorOrientation.HORIZONTAL,
16
+ decorative = true,
17
+ ...props
18
+ }: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
19
+ return (
20
+ <SeparatorPrimitive.Root
21
+ className={cn(
22
+ "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
23
+ className
24
+ )}
25
+ data-slot="separator-root"
26
+ decorative={decorative}
27
+ orientation={orientation}
28
+ {...props}
29
+ />
30
+ );
31
+ }
32
+
33
+ interface SeparatorWithTextProps {
34
+ className?: string;
35
+ children: React.ReactNode;
36
+ }
37
+
38
+ function SeparatorWithText({ className, children }: SeparatorWithTextProps) {
39
+ return (
40
+ <div
41
+ className={cn("flex items-center gap-2", className)}
42
+ data-slot="separator-with-text"
43
+ >
44
+ <Separator className="flex-1" />
45
+ <span className="text-sidebar-foreground shrink-0 text-sm leading-none font-medium whitespace-nowrap">
46
+ {children}
47
+ </span>
48
+ <Separator className="flex-1" />
49
+ </div>
50
+ );
51
+ }
52
+
53
+ export { Separator, SeparatorWithText };
@@ -0,0 +1,220 @@
1
+ import * as React from "react";
2
+ import * as SheetPrimitive from "@radix-ui/react-dialog";
3
+ import { cva, type VariantProps } from "class-variance-authority";
4
+ import { XIcon } from "lucide-react";
5
+
6
+ import { cn } from "@brightlocal/ui-components/lib/utils";
7
+
8
+ /**
9
+ * Available sheet side variants
10
+ */
11
+ export enum SheetSide {
12
+ /** Sheet slides in from the top */
13
+ TOP = "top",
14
+ /** Sheet slides in from the right (default) */
15
+ RIGHT = "right",
16
+ /** Sheet slides in from the bottom */
17
+ BOTTOM = "bottom",
18
+ /** Sheet slides in from the left */
19
+ LEFT = "left",
20
+ }
21
+
22
+ const sheetContentVariants = cva(
23
+ [
24
+ "bg-background",
25
+ "data-[state=open]:animate-in",
26
+ "data-[state=closed]:animate-out",
27
+ "fixed",
28
+ "z-50",
29
+ "flex",
30
+ "flex-col",
31
+ "gap-4",
32
+ "p-6",
33
+ "shadow-lg",
34
+ "transition",
35
+ "ease-in-out",
36
+ "data-[state=closed]:duration-300",
37
+ "data-[state=open]:duration-500",
38
+ ],
39
+ {
40
+ variants: {
41
+ side: {
42
+ top: [
43
+ "data-[state=closed]:slide-out-to-top",
44
+ "data-[state=open]:slide-in-from-top",
45
+ "inset-x-0",
46
+ "top-0",
47
+ "h-auto",
48
+ "border-b",
49
+ ],
50
+ right: [
51
+ "data-[state=closed]:slide-out-to-right",
52
+ "data-[state=open]:slide-in-from-right",
53
+ "inset-y-0",
54
+ "right-0",
55
+ "h-full",
56
+ "w-3/4",
57
+ "border-l",
58
+ "sm:max-w-sm",
59
+ ],
60
+ bottom: [
61
+ "data-[state=closed]:slide-out-to-bottom",
62
+ "data-[state=open]:slide-in-from-bottom",
63
+ "inset-x-0",
64
+ "bottom-0",
65
+ "h-auto",
66
+ "border-t",
67
+ ],
68
+ left: [
69
+ "data-[state=closed]:slide-out-to-left",
70
+ "data-[state=open]:slide-in-from-left",
71
+ "inset-y-0",
72
+ "left-0",
73
+ "h-full",
74
+ "w-3/4",
75
+ "border-r",
76
+ "sm:max-w-sm",
77
+ ],
78
+ },
79
+ },
80
+ defaultVariants: {
81
+ side: "right",
82
+ },
83
+ }
84
+ );
85
+
86
+ function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
87
+ return <SheetPrimitive.Root data-slot="sheet" modal={true} {...props} />;
88
+ }
89
+
90
+ function SheetTrigger({
91
+ ...props
92
+ }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
93
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
94
+ }
95
+
96
+ function SheetClose({
97
+ ...props
98
+ }: React.ComponentProps<typeof SheetPrimitive.Close>) {
99
+ return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
100
+ }
101
+
102
+ function SheetPortal({
103
+ ...props
104
+ }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
105
+ return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
106
+ }
107
+
108
+ function SheetOverlay({
109
+ className,
110
+ ...props
111
+ }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
112
+ return (
113
+ <SheetPrimitive.Overlay
114
+ className={cn(
115
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
116
+ className
117
+ )}
118
+ data-slot="sheet-overlay"
119
+ {...props}
120
+ />
121
+ );
122
+ }
123
+
124
+ interface SheetContentProps
125
+ extends
126
+ React.ComponentProps<typeof SheetPrimitive.Content>,
127
+ VariantProps<typeof sheetContentVariants> {
128
+ /**
129
+ * Side from which the sheet slides in
130
+ */
131
+ side?: SheetSide;
132
+ }
133
+
134
+ function SheetContent({
135
+ className,
136
+ children,
137
+ side,
138
+ ...props
139
+ }: SheetContentProps) {
140
+ return (
141
+ <SheetPortal>
142
+ <SheetOverlay />
143
+ <SheetPrimitive.Content
144
+ className={cn(sheetContentVariants({ side }), className)}
145
+ data-slot="sheet-content"
146
+ {...props}
147
+ >
148
+ {children}
149
+ <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
150
+ <XIcon />
151
+ <span className="sr-only">Close</span>
152
+ </SheetPrimitive.Close>
153
+ </SheetPrimitive.Content>
154
+ </SheetPortal>
155
+ );
156
+ }
157
+
158
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
159
+ return (
160
+ <div
161
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
162
+ data-slot="sheet-header"
163
+ {...props}
164
+ />
165
+ );
166
+ }
167
+
168
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
169
+ return (
170
+ <div
171
+ className={cn(
172
+ "mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",
173
+ className
174
+ )}
175
+ data-slot="sheet-footer"
176
+ {...props}
177
+ />
178
+ );
179
+ }
180
+
181
+ function SheetTitle({
182
+ className,
183
+ ...props
184
+ }: React.ComponentProps<typeof SheetPrimitive.Title>) {
185
+ return (
186
+ <SheetPrimitive.Title
187
+ className={cn("text-foreground text-lg font-semibold", className)}
188
+ data-slot="sheet-title"
189
+ {...props}
190
+ />
191
+ );
192
+ }
193
+
194
+ function SheetDescription({
195
+ className,
196
+ ...props
197
+ }: React.ComponentProps<typeof SheetPrimitive.Description>) {
198
+ return (
199
+ <SheetPrimitive.Description
200
+ className={cn("text-muted-foreground text-sm", className)}
201
+ data-slot="sheet-description"
202
+ {...props}
203
+ />
204
+ );
205
+ }
206
+
207
+ export {
208
+ Sheet,
209
+ SheetClose,
210
+ SheetContent,
211
+ SheetDescription,
212
+ SheetFooter,
213
+ SheetHeader,
214
+ SheetOverlay,
215
+ SheetPortal,
216
+ SheetTitle,
217
+ SheetTrigger,
218
+ };
219
+
220
+ export type { SheetContentProps };