@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.
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.d.ts +74 -4
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +100 -105
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +30 -10
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +129 -132
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +22 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +1 -1
- package/dist/aspect-ratio.cjs +1 -1
- package/dist/aspect-ratio.d.ts +11 -1
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/aspect-ratio.js +16 -20
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.d.ts +43 -3
- package/dist/avatar.d.ts.map +1 -1
- package/dist/avatar.js +18 -16
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +24 -9
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +34 -32
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +177 -170
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +38 -307
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +411 -508
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +63 -8
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +97 -93
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +17 -45
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +49 -50
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +16 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +31 -29
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +58 -18
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +60 -51
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +99 -9
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +142 -128
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +18 -15
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +44 -33
- package/dist/chart.cjs +4 -4
- package/dist/chart.d.ts +70 -7
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +71 -66
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts +9 -5
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +61 -82
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.d.ts +65 -8
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/collapsible.js +41 -55
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +28 -18
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +191 -160
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +115 -9
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +176 -152
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts +188 -20
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +120 -122
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +75 -9
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +221 -82
- package/dist/description.cjs +1 -0
- package/dist/description.d.ts +37 -0
- package/dist/description.d.ts.map +1 -0
- package/dist/description.js +25 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +73 -9
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +103 -112
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +92 -0
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +67 -52
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +95 -11
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +146 -106
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +26 -6
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +55 -53
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +27 -17
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +86 -79
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +36 -6
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +44 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +367 -386
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +21 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +51 -41
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +25 -26
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +38 -24
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +68 -136
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts +20 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +31 -18
- package/dist/link.cjs +1 -1
- package/dist/link.js +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +9 -4
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +20 -21
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +43 -6
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +100 -78
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts +6 -54
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +73 -84
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +8 -10
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +78 -86
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts +59 -4
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +42 -34
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +9 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +71 -59
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +33 -10
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +56 -66
- package/dist/rating.d.ts +4 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +58 -6
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +38 -37
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +46 -5
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +42 -38
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +30 -0
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +64 -54
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +52 -5
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +45 -35
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +85 -19
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +117 -115
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +24 -2
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +15 -9
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +18 -4
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +72 -66
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +21 -22
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +46 -48
- package/dist/split-layout.d.ts +4 -1
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts +2 -12
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +37 -41
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +16 -12
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +56 -58
- package/dist/tabs.d.ts +27 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.d.ts +57 -7
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +60 -67
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts +12 -26
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +16 -20
- package/package.json +9 -3
- package/src/blocks/data-table.tsx +43 -33
- package/src/blocks/sidebar.tsx +158 -541
- package/src/components/accordion.tsx +164 -78
- package/src/components/alert-dialog.tsx +156 -111
- package/src/components/alert.tsx +27 -14
- package/src/components/aspect-ratio.tsx +25 -16
- package/src/components/avatar.tsx +56 -8
- package/src/components/badge.tsx +65 -42
- package/src/components/breadcrumb.tsx +159 -83
- package/src/components/button.tsx +42 -63
- package/src/components/calendar.tsx +22 -6
- package/src/components/card.tsx +92 -40
- package/src/components/carousel.tsx +240 -115
- package/src/components/centred-layout.tsx +68 -49
- package/src/components/chart.tsx +118 -47
- package/src/components/checkbox.tsx +43 -79
- package/src/components/collapsible.tsx +95 -26
- package/src/components/combobox.tsx +243 -153
- package/src/components/command.tsx +295 -121
- package/src/components/context-menu.tsx +279 -82
- package/src/components/date-picker.tsx +282 -31
- package/src/components/description.tsx +60 -0
- package/src/components/dialog.tsx +163 -87
- package/src/components/drawer.tsx +76 -2
- package/src/components/dropdown-menu.tsx +143 -37
- package/src/components/field.tsx +38 -11
- package/src/components/global-layout.tsx +116 -77
- package/src/components/hover-card.tsx +54 -14
- package/src/components/input-group.tsx +56 -18
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +4 -5
- package/src/components/input.tsx +93 -186
- package/src/components/label.tsx +56 -15
- package/src/components/link.tsx +1 -1
- package/src/components/logo.tsx +12 -7
- package/src/components/menubar.tsx +61 -5
- package/src/components/navigation-menu.tsx +37 -99
- package/src/components/pagination.tsx +13 -19
- package/src/components/popover.tsx +103 -20
- package/src/components/progress.tsx +82 -60
- package/src/components/radio-group.tsx +44 -25
- package/src/components/rating.tsx +4 -0
- package/src/components/resizable.tsx +88 -38
- package/src/components/scroll-area.tsx +123 -56
- package/src/components/select.tsx +22 -2
- package/src/components/separator.tsx +101 -24
- package/src/components/sheet.tsx +186 -90
- package/src/components/skeleton.tsx +40 -10
- package/src/components/slider.tsx +83 -57
- package/src/components/sonner.tsx +34 -34
- package/src/components/split-layout.tsx +4 -1
- package/src/components/switch.figma.tsx +7 -11
- package/src/components/switch.tsx +9 -19
- package/src/components/table.tsx +23 -18
- package/src/components/tabs.tsx +27 -3
- package/src/components/toggle-group.tsx +115 -86
- package/src/components/toggle.figma.tsx +13 -19
- package/src/components/toggle.tsx +20 -34
- package/src/index.ts +1 -1
- package/dist/input-base.cjs +0 -1
- package/dist/input-base.d.ts +0 -28
- package/dist/input-base.d.ts.map +0 -1
- package/dist/input-base.js +0 -56
- package/src/components/input-base.tsx +0 -86
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
5
|
-
import { Check, ChevronRight, Circle } from "
|
|
5
|
+
import { Check, ChevronRight, Circle, ChevronsUpDown } from "@brightlocal/icons";
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
@@ -28,18 +28,38 @@ function DropdownMenuPortal({
|
|
|
28
28
|
|
|
29
29
|
DropdownMenuPortal.displayName = "DropdownMenuPortal";
|
|
30
30
|
|
|
31
|
+
type DropdownMenuTriggerProps = React.ComponentPropsWithoutRef<
|
|
32
|
+
typeof DropdownMenuPrimitive.Trigger
|
|
33
|
+
> & {
|
|
34
|
+
/**
|
|
35
|
+
* Data hook for automated testing (optional)
|
|
36
|
+
*/
|
|
37
|
+
dataHook?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Tracking element identifier for analytics
|
|
40
|
+
*/
|
|
41
|
+
trackingEl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Tracking label for analytics context
|
|
44
|
+
*/
|
|
45
|
+
trackingLabel?: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
31
48
|
/**
|
|
32
49
|
* Trigger button that opens the dropdown menu
|
|
33
50
|
*/
|
|
34
51
|
const DropdownMenuTrigger = React.forwardRef<
|
|
35
|
-
React.
|
|
36
|
-
|
|
37
|
-
>(({ className, ...props }, ref) => {
|
|
52
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,
|
|
53
|
+
DropdownMenuTriggerProps
|
|
54
|
+
>(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
38
55
|
return (
|
|
39
56
|
<DropdownMenuPrimitive.Trigger
|
|
40
57
|
ref={ref}
|
|
41
58
|
className={className}
|
|
59
|
+
data-hook={dataHook}
|
|
42
60
|
data-slot="dropdown-menu-trigger"
|
|
61
|
+
data-tracking-el={trackingEl}
|
|
62
|
+
data-tracking-label={trackingLabel}
|
|
43
63
|
{...props}
|
|
44
64
|
/>
|
|
45
65
|
);
|
|
@@ -68,7 +88,7 @@ type DropdownMenuContentProps = React.ComponentPropsWithoutRef<
|
|
|
68
88
|
* Dropdown menu content container (popup)
|
|
69
89
|
*/
|
|
70
90
|
const DropdownMenuContent = React.forwardRef<
|
|
71
|
-
React.
|
|
91
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Content>,
|
|
72
92
|
DropdownMenuContentProps
|
|
73
93
|
>(
|
|
74
94
|
(
|
|
@@ -150,29 +170,17 @@ type DropdownMenuItemProps = React.ComponentPropsWithoutRef<
|
|
|
150
170
|
* Indent the item (for hierarchical menus)
|
|
151
171
|
*/
|
|
152
172
|
inset?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Visual variant for destructive actions
|
|
155
|
-
*/
|
|
156
|
-
variant?: "default" | "destructive";
|
|
157
173
|
};
|
|
158
174
|
|
|
159
175
|
/**
|
|
160
176
|
* Individual dropdown menu item
|
|
161
177
|
*/
|
|
162
178
|
const DropdownMenuItem = React.forwardRef<
|
|
163
|
-
React.
|
|
179
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Item>,
|
|
164
180
|
DropdownMenuItemProps
|
|
165
181
|
>(
|
|
166
182
|
(
|
|
167
|
-
{
|
|
168
|
-
className,
|
|
169
|
-
inset,
|
|
170
|
-
variant = "default",
|
|
171
|
-
dataHook,
|
|
172
|
-
trackingEl,
|
|
173
|
-
trackingLabel,
|
|
174
|
-
...props
|
|
175
|
-
},
|
|
183
|
+
{ className, inset, dataHook, trackingEl, trackingLabel, ...props },
|
|
176
184
|
ref
|
|
177
185
|
) => {
|
|
178
186
|
return (
|
|
@@ -180,22 +188,18 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
180
188
|
ref={ref}
|
|
181
189
|
className={cn(
|
|
182
190
|
[
|
|
183
|
-
"relative flex cursor-default items-center gap-2 select-none",
|
|
184
|
-
"rounded-sm px-2 py-1.5 text-sm outline-hidden",
|
|
191
|
+
"relative flex cursor-default items-center gap-2 self-stretch select-none",
|
|
192
|
+
"rounded-sm px-2 py-1.5 text-sm leading-normal outline-hidden",
|
|
193
|
+
// Text truncation for child text elements
|
|
194
|
+
"[&>span]:overflow-hidden [&>span]:text-ellipsis [&>span]:whitespace-nowrap",
|
|
185
195
|
"focus:bg-accent focus:text-accent-foreground",
|
|
186
196
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
187
197
|
// Inset (indentation)
|
|
188
198
|
"data-[inset]:pl-8",
|
|
189
|
-
// Variant: destructive
|
|
190
|
-
"data-[variant=destructive]:text-destructive",
|
|
191
|
-
"data-[variant=destructive]:focus:bg-destructive/10",
|
|
192
|
-
"dark:data-[variant=destructive]:focus:bg-destructive/20",
|
|
193
|
-
"data-[variant=destructive]:focus:text-destructive",
|
|
194
|
-
"data-[variant=destructive]:*:[svg]:!text-destructive",
|
|
195
199
|
// Icon styling
|
|
196
|
-
"[&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
197
200
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
198
201
|
"[&_svg:not([class*='size-'])]:size-4",
|
|
202
|
+
"[&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
199
203
|
],
|
|
200
204
|
className
|
|
201
205
|
)}
|
|
@@ -204,7 +208,6 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
204
208
|
data-slot="dropdown-menu-item"
|
|
205
209
|
data-tracking-el={trackingEl}
|
|
206
210
|
data-tracking-label={trackingLabel}
|
|
207
|
-
data-variant={variant}
|
|
208
211
|
{...props}
|
|
209
212
|
/>
|
|
210
213
|
);
|
|
@@ -234,7 +237,7 @@ type DropdownMenuCheckboxItemProps = React.ComponentPropsWithoutRef<
|
|
|
234
237
|
* Checkbox menu item with check indicator
|
|
235
238
|
*/
|
|
236
239
|
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
237
|
-
React.
|
|
240
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
238
241
|
DropdownMenuCheckboxItemProps
|
|
239
242
|
>(
|
|
240
243
|
(
|
|
@@ -316,7 +319,7 @@ type DropdownMenuRadioItemProps = React.ComponentPropsWithoutRef<
|
|
|
316
319
|
* Radio menu item with circle indicator
|
|
317
320
|
*/
|
|
318
321
|
const DropdownMenuRadioItem = React.forwardRef<
|
|
319
|
-
React.
|
|
322
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
320
323
|
DropdownMenuRadioItemProps
|
|
321
324
|
>(
|
|
322
325
|
(
|
|
@@ -370,14 +373,17 @@ type DropdownMenuLabelProps = React.ComponentPropsWithoutRef<
|
|
|
370
373
|
* Label/header for menu sections
|
|
371
374
|
*/
|
|
372
375
|
const DropdownMenuLabel = React.forwardRef<
|
|
373
|
-
React.
|
|
376
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Label>,
|
|
374
377
|
DropdownMenuLabelProps
|
|
375
378
|
>(({ className, inset, ...props }, ref) => {
|
|
376
379
|
return (
|
|
377
380
|
<DropdownMenuPrimitive.Label
|
|
378
381
|
ref={ref}
|
|
379
382
|
className={cn(
|
|
380
|
-
[
|
|
383
|
+
[
|
|
384
|
+
"px-2 py-1.5 text-sm leading-normal font-semibold",
|
|
385
|
+
"data-[inset]:pl-8",
|
|
386
|
+
],
|
|
381
387
|
className
|
|
382
388
|
)}
|
|
383
389
|
data-inset={inset}
|
|
@@ -393,7 +399,7 @@ DropdownMenuLabel.displayName = "DropdownMenuLabel";
|
|
|
393
399
|
* Separator/divider between menu sections
|
|
394
400
|
*/
|
|
395
401
|
const DropdownMenuSeparator = React.forwardRef<
|
|
396
|
-
React.
|
|
402
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,
|
|
397
403
|
React.ComponentProps<typeof DropdownMenuPrimitive.Separator>
|
|
398
404
|
>(({ className, ...props }, ref) => {
|
|
399
405
|
return (
|
|
@@ -418,7 +424,7 @@ function DropdownMenuShortcut({
|
|
|
418
424
|
return (
|
|
419
425
|
<span
|
|
420
426
|
className={cn(
|
|
421
|
-
["text-
|
|
427
|
+
["text-popover-foreground ml-auto text-xs leading-normal opacity-60"],
|
|
422
428
|
className
|
|
423
429
|
)}
|
|
424
430
|
data-slot="dropdown-menu-shortcut"
|
|
@@ -465,7 +471,7 @@ type DropdownMenuSubTriggerProps = React.ComponentPropsWithoutRef<
|
|
|
465
471
|
* Trigger for opening sub-menu
|
|
466
472
|
*/
|
|
467
473
|
const DropdownMenuSubTrigger = React.forwardRef<
|
|
468
|
-
React.
|
|
474
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
469
475
|
DropdownMenuSubTriggerProps
|
|
470
476
|
>(
|
|
471
477
|
(
|
|
@@ -516,7 +522,7 @@ DropdownMenuSubTrigger.displayName = "DropdownMenuSubTrigger";
|
|
|
516
522
|
* Sub-menu content container
|
|
517
523
|
*/
|
|
518
524
|
const DropdownMenuSubContent = React.forwardRef<
|
|
519
|
-
React.
|
|
525
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
520
526
|
React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>
|
|
521
527
|
>(({ className, ...props }, ref) => {
|
|
522
528
|
return (
|
|
@@ -547,6 +553,103 @@ const DropdownMenuSubContent = React.forwardRef<
|
|
|
547
553
|
|
|
548
554
|
DropdownMenuSubContent.displayName = "DropdownMenuSubContent";
|
|
549
555
|
|
|
556
|
+
type DropdownMenuTriggerAvatarProps = React.ComponentPropsWithoutRef<
|
|
557
|
+
typeof DropdownMenuPrimitive.Trigger
|
|
558
|
+
> & {
|
|
559
|
+
/**
|
|
560
|
+
* Data hook for automated testing
|
|
561
|
+
*/
|
|
562
|
+
dataHook?: string;
|
|
563
|
+
/**
|
|
564
|
+
* Tracking element identifier for analytics
|
|
565
|
+
*/
|
|
566
|
+
trackingEl?: string;
|
|
567
|
+
/**
|
|
568
|
+
* Tracking label for analytics context
|
|
569
|
+
*/
|
|
570
|
+
trackingLabel?: string;
|
|
571
|
+
/**
|
|
572
|
+
* Avatar slot - expects an Avatar component
|
|
573
|
+
*/
|
|
574
|
+
avatar: React.ReactNode;
|
|
575
|
+
/**
|
|
576
|
+
* Main text/title displayed next to avatar
|
|
577
|
+
*/
|
|
578
|
+
title: string;
|
|
579
|
+
/**
|
|
580
|
+
* Description text displayed below title
|
|
581
|
+
*/
|
|
582
|
+
description?: string;
|
|
583
|
+
/**
|
|
584
|
+
* Accessible label for screen readers.
|
|
585
|
+
* Defaults to title if not provided.
|
|
586
|
+
*/
|
|
587
|
+
ariaLabel?: string;
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Avatar-style trigger button for dropdown menu with title and description
|
|
592
|
+
*/
|
|
593
|
+
const DropdownMenuTriggerAvatar = React.forwardRef<
|
|
594
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Trigger>,
|
|
595
|
+
DropdownMenuTriggerAvatarProps
|
|
596
|
+
>(
|
|
597
|
+
(
|
|
598
|
+
{
|
|
599
|
+
className,
|
|
600
|
+
dataHook,
|
|
601
|
+
trackingEl,
|
|
602
|
+
trackingLabel,
|
|
603
|
+
avatar,
|
|
604
|
+
title,
|
|
605
|
+
description,
|
|
606
|
+
disabled,
|
|
607
|
+
ariaLabel,
|
|
608
|
+
...props
|
|
609
|
+
},
|
|
610
|
+
ref
|
|
611
|
+
) => {
|
|
612
|
+
return (
|
|
613
|
+
<DropdownMenuPrimitive.Trigger
|
|
614
|
+
ref={ref}
|
|
615
|
+
aria-label={ariaLabel ?? title}
|
|
616
|
+
className={cn(
|
|
617
|
+
[
|
|
618
|
+
"flex items-center gap-2 rounded-lg border px-3 py-2",
|
|
619
|
+
"bg-popover shadow-sm",
|
|
620
|
+
"outline-none",
|
|
621
|
+
"hover:bg-accent",
|
|
622
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
623
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
624
|
+
],
|
|
625
|
+
className
|
|
626
|
+
)}
|
|
627
|
+
data-hook={dataHook}
|
|
628
|
+
data-slot="dropdown-menu-trigger-avatar"
|
|
629
|
+
data-tracking-el={trackingEl}
|
|
630
|
+
data-tracking-label={trackingLabel}
|
|
631
|
+
disabled={disabled}
|
|
632
|
+
{...props}
|
|
633
|
+
>
|
|
634
|
+
{avatar}
|
|
635
|
+
<div className="flex min-w-0 flex-1 flex-col items-start">
|
|
636
|
+
<span className="w-full overflow-hidden text-sm leading-normal font-semibold text-ellipsis whitespace-nowrap">
|
|
637
|
+
{title}
|
|
638
|
+
</span>
|
|
639
|
+
{description && (
|
|
640
|
+
<span className="text-muted-foreground w-full overflow-hidden text-xs leading-normal text-ellipsis whitespace-nowrap">
|
|
641
|
+
{description}
|
|
642
|
+
</span>
|
|
643
|
+
)}
|
|
644
|
+
</div>
|
|
645
|
+
<ChevronsUpDown className="text-muted-foreground size-4 opacity-50" />
|
|
646
|
+
</DropdownMenuPrimitive.Trigger>
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
DropdownMenuTriggerAvatar.displayName = "DropdownMenuTriggerAvatar";
|
|
652
|
+
|
|
550
653
|
export {
|
|
551
654
|
DropdownMenu,
|
|
552
655
|
DropdownMenuCheckboxItem,
|
|
@@ -563,13 +666,16 @@ export {
|
|
|
563
666
|
DropdownMenuSubContent,
|
|
564
667
|
DropdownMenuSubTrigger,
|
|
565
668
|
DropdownMenuTrigger,
|
|
669
|
+
DropdownMenuTriggerAvatar,
|
|
566
670
|
};
|
|
567
671
|
|
|
568
672
|
export type {
|
|
673
|
+
DropdownMenuTriggerProps,
|
|
569
674
|
DropdownMenuContentProps,
|
|
570
675
|
DropdownMenuItemProps,
|
|
571
676
|
DropdownMenuCheckboxItemProps,
|
|
572
677
|
DropdownMenuRadioItemProps,
|
|
573
678
|
DropdownMenuLabelProps,
|
|
574
679
|
DropdownMenuSubTriggerProps,
|
|
680
|
+
DropdownMenuTriggerAvatarProps,
|
|
575
681
|
};
|
package/src/components/field.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
2
|
|
|
3
3
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { Description } from "./description";
|
|
4
5
|
import { Label } from "@brightlocal/ui-components/label";
|
|
5
6
|
|
|
6
7
|
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
@@ -17,11 +18,23 @@ function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
|
17
18
|
);
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
FieldSet.displayName = "FieldSet";
|
|
22
|
+
|
|
23
|
+
interface FieldLegendProps extends React.ComponentProps<"legend"> {
|
|
24
|
+
/**
|
|
25
|
+
* Visual style variant of the legend
|
|
26
|
+
* @default "legend"
|
|
27
|
+
*/
|
|
28
|
+
variant?: "legend" | "label";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const fieldLegendVariants: FieldLegendProps["variant"][] = ["legend", "label"];
|
|
32
|
+
|
|
20
33
|
function FieldLegend({
|
|
21
34
|
className,
|
|
22
35
|
variant = "legend",
|
|
23
36
|
...props
|
|
24
|
-
}:
|
|
37
|
+
}: FieldLegendProps) {
|
|
25
38
|
return (
|
|
26
39
|
<legend
|
|
27
40
|
className={cn(
|
|
@@ -71,14 +84,27 @@ const fieldVariants = cva("group/field flex w-full gap-2", {
|
|
|
71
84
|
},
|
|
72
85
|
});
|
|
73
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Props for the Field component
|
|
89
|
+
*/
|
|
90
|
+
interface FieldProps
|
|
91
|
+
extends React.ComponentProps<"div">, VariantProps<typeof fieldVariants> {
|
|
92
|
+
/**
|
|
93
|
+
* Data hook for automated testing
|
|
94
|
+
*/
|
|
95
|
+
dataHook?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
74
98
|
function Field({
|
|
75
99
|
className,
|
|
76
100
|
orientation = "vertical",
|
|
101
|
+
dataHook,
|
|
77
102
|
...props
|
|
78
|
-
}:
|
|
103
|
+
}: FieldProps) {
|
|
79
104
|
return (
|
|
80
105
|
<div
|
|
81
106
|
className={cn(fieldVariants({ orientation }), className)}
|
|
107
|
+
data-hook={dataHook}
|
|
82
108
|
data-orientation={orientation}
|
|
83
109
|
data-slot="field"
|
|
84
110
|
role="group"
|
|
@@ -100,16 +126,14 @@ function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
100
126
|
);
|
|
101
127
|
}
|
|
102
128
|
|
|
103
|
-
|
|
104
|
-
className,
|
|
105
|
-
htmlFor,
|
|
106
|
-
...props
|
|
107
|
-
}: Omit<React.ComponentProps<typeof Label>, "htmlFor"> & {
|
|
129
|
+
interface FieldLabelProps extends React.ComponentProps<typeof Label> {
|
|
108
130
|
/**
|
|
109
131
|
* Required htmlFor attribute for linking label with input
|
|
110
132
|
*/
|
|
111
133
|
htmlFor: string;
|
|
112
|
-
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function FieldLabel({ className, htmlFor, ...props }: FieldLabelProps) {
|
|
113
137
|
return (
|
|
114
138
|
<Label
|
|
115
139
|
className={cn(
|
|
@@ -130,12 +154,12 @@ function FieldLabel({
|
|
|
130
154
|
|
|
131
155
|
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
132
156
|
return (
|
|
133
|
-
<
|
|
157
|
+
<Description
|
|
134
158
|
className={cn(
|
|
135
|
-
|
|
159
|
+
// Field-specific positioning and context styles
|
|
160
|
+
"mt-2",
|
|
136
161
|
"group-has-[[data-orientation=horizontal]]/field:text-balance",
|
|
137
162
|
"last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
|
|
138
|
-
"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
|
|
139
163
|
className
|
|
140
164
|
)}
|
|
141
165
|
data-slot="field-description"
|
|
@@ -150,6 +174,9 @@ export {
|
|
|
150
174
|
FieldDescription,
|
|
151
175
|
FieldGroup,
|
|
152
176
|
FieldLegend,
|
|
177
|
+
fieldLegendVariants,
|
|
153
178
|
FieldSet,
|
|
154
179
|
FieldContent,
|
|
155
180
|
};
|
|
181
|
+
|
|
182
|
+
export type { FieldProps };
|
|
@@ -18,59 +18,92 @@ const MAX_WIDTH = "1280px";
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
interface GlobalLayoutProps extends React.ComponentProps<"div"> {
|
|
21
|
+
/**
|
|
22
|
+
* Data hook for automated testing (required)
|
|
23
|
+
*/
|
|
24
|
+
dataHook: string;
|
|
25
|
+
/**
|
|
26
|
+
* Tracking element identifier for analytics
|
|
27
|
+
*/
|
|
28
|
+
trackingEl?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Tracking label for analytics context
|
|
31
|
+
*/
|
|
32
|
+
trackingLabel?: string;
|
|
21
33
|
/**
|
|
22
34
|
* Maximum width for the global container (default: 1280px)
|
|
23
35
|
*/
|
|
24
36
|
maxWidth?: string | number;
|
|
25
37
|
}
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
className,
|
|
43
|
+
maxWidth = MAX_WIDTH,
|
|
44
|
+
dataHook,
|
|
45
|
+
trackingEl,
|
|
46
|
+
trackingLabel,
|
|
47
|
+
children,
|
|
48
|
+
...props
|
|
49
|
+
},
|
|
50
|
+
ref
|
|
51
|
+
) => {
|
|
52
|
+
const maxWidthStyle =
|
|
53
|
+
typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
54
|
+
|
|
55
|
+
return (
|
|
42
56
|
<div
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
ref={ref}
|
|
58
|
+
className={cn(
|
|
59
|
+
"flex min-h-screen w-full flex-col px-4 md:px-6",
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
data-hook={dataHook}
|
|
63
|
+
data-slot="global-layout"
|
|
64
|
+
data-tracking-el={trackingEl}
|
|
65
|
+
data-tracking-label={trackingLabel}
|
|
66
|
+
{...props}
|
|
46
67
|
>
|
|
47
|
-
|
|
68
|
+
<div
|
|
69
|
+
className="mx-auto flex w-full flex-1 gap-4 md:gap-6"
|
|
70
|
+
data-slot="global-container"
|
|
71
|
+
style={{ maxWidth: maxWidthStyle }}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</div>
|
|
48
75
|
</div>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
GlobalLayout.displayName = "GlobalLayout";
|
|
52
81
|
|
|
53
82
|
// Matches 16rem (256px) and aligns with Figma design
|
|
54
83
|
const SIDEBAR_WIDTH = "256px";
|
|
55
84
|
|
|
56
85
|
interface GlobalLayoutSidebarProps extends React.ComponentProps<"aside"> {
|
|
86
|
+
/**
|
|
87
|
+
* Data hook for automated testing
|
|
88
|
+
*/
|
|
89
|
+
dataHook?: string;
|
|
57
90
|
/**
|
|
58
91
|
* Width of the sidebar (default: 256px)
|
|
59
92
|
*/
|
|
60
93
|
width?: string | number;
|
|
61
94
|
}
|
|
62
95
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
...props
|
|
68
|
-
}: GlobalLayoutSidebarProps) {
|
|
96
|
+
const GlobalLayoutSidebar = React.forwardRef<
|
|
97
|
+
HTMLElement,
|
|
98
|
+
GlobalLayoutSidebarProps
|
|
99
|
+
>(({ className, width = SIDEBAR_WIDTH, dataHook, children, ...props }, ref) => {
|
|
69
100
|
const widthStyle = typeof width === "number" ? `${width}px` : width;
|
|
70
101
|
|
|
71
102
|
return (
|
|
72
103
|
<aside
|
|
73
|
-
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("hidden shrink-0 self-stretch lg:block", className)}
|
|
106
|
+
data-hook={dataHook}
|
|
74
107
|
data-slot="sidebar-container"
|
|
75
108
|
style={{ width: widthStyle }}
|
|
76
109
|
{...props}
|
|
@@ -78,27 +111,23 @@ function GlobalLayoutSidebar({
|
|
|
78
111
|
{children}
|
|
79
112
|
</aside>
|
|
80
113
|
);
|
|
81
|
-
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
GlobalLayoutSidebar.displayName = "GlobalLayoutSidebar";
|
|
82
117
|
|
|
83
118
|
/**
|
|
84
119
|
* Content width variants for GlobalLayoutContent
|
|
120
|
+
* - "full": Full width of available space
|
|
121
|
+
* - "md": Medium width (768px max-width)
|
|
122
|
+
* - "sm": Small width (374px max-width)
|
|
85
123
|
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Full width of available space
|
|
89
|
-
*/
|
|
90
|
-
FULL = "full",
|
|
91
|
-
/**
|
|
92
|
-
* Medium width (768px max-width)
|
|
93
|
-
*/
|
|
94
|
-
MD = "md",
|
|
95
|
-
/**
|
|
96
|
-
* Small width (374px max-width)
|
|
97
|
-
*/
|
|
98
|
-
SM = "sm",
|
|
99
|
-
}
|
|
124
|
+
type ContentVariant = "full" | "md" | "sm";
|
|
100
125
|
|
|
101
126
|
interface GlobalLayoutContentProps extends React.ComponentProps<"div"> {
|
|
127
|
+
/**
|
|
128
|
+
* Data hook for automated testing
|
|
129
|
+
*/
|
|
130
|
+
dataHook?: string;
|
|
102
131
|
/**
|
|
103
132
|
* Content width variant:
|
|
104
133
|
* - "full": Full width of available space
|
|
@@ -112,42 +141,52 @@ interface GlobalLayoutContentProps extends React.ComponentProps<"div"> {
|
|
|
112
141
|
padding?: string;
|
|
113
142
|
}
|
|
114
143
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
className={cn("flex h-full min-h-0 min-w-0 flex-1", className)}
|
|
134
|
-
data-slot="content-wrapper"
|
|
135
|
-
{...props}
|
|
136
|
-
>
|
|
144
|
+
const GlobalLayoutContent = React.forwardRef<
|
|
145
|
+
HTMLDivElement,
|
|
146
|
+
GlobalLayoutContentProps
|
|
147
|
+
>(
|
|
148
|
+
(
|
|
149
|
+
{ className, variant = "full", padding, dataHook, children, ...props },
|
|
150
|
+
ref
|
|
151
|
+
) => {
|
|
152
|
+
// Aligned with Figma design and Tailwind breakpoints
|
|
153
|
+
// md: 768px - matches Tailwind's max-w-3xl
|
|
154
|
+
// sm: 374px - optimized for mobile content
|
|
155
|
+
const contentMaxWidth: Record<ContentVariant, string> = {
|
|
156
|
+
full: "100%",
|
|
157
|
+
md: "768px",
|
|
158
|
+
sm: "374px",
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
return (
|
|
137
162
|
<div
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}}
|
|
163
|
+
ref={ref}
|
|
164
|
+
className={cn("flex min-h-0 min-w-0 flex-1 self-stretch", className)}
|
|
165
|
+
data-hook={dataHook}
|
|
166
|
+
data-slot="content-wrapper"
|
|
167
|
+
{...props}
|
|
144
168
|
>
|
|
145
|
-
|
|
169
|
+
<div
|
|
170
|
+
className={cn("mx-auto w-full")}
|
|
171
|
+
data-slot="content-container"
|
|
172
|
+
style={{
|
|
173
|
+
maxWidth: contentMaxWidth[variant],
|
|
174
|
+
padding,
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
{children}
|
|
178
|
+
</div>
|
|
146
179
|
</div>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
GlobalLayoutContent.displayName = "GlobalLayoutContent";
|
|
150
185
|
|
|
151
186
|
export { GlobalLayout, GlobalLayoutSidebar, GlobalLayoutContent };
|
|
152
187
|
|
|
153
|
-
export type {
|
|
188
|
+
export type {
|
|
189
|
+
GlobalLayoutProps,
|
|
190
|
+
GlobalLayoutSidebarProps,
|
|
191
|
+
GlobalLayoutContentProps,
|
|
192
|
+
};
|