@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.
- package/LICENSE +21 -0
- package/README.md +349 -0
- package/dist/accordion.cjs +1 -0
- package/dist/accordion.d.ts +32 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +107 -0
- package/dist/alert-dialog.cjs +1 -0
- package/dist/alert-dialog.d.ts +15 -0
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert-dialog.js +146 -0
- package/dist/alert.cjs +1 -0
- package/dist/alert.d.ts +16 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +174 -0
- package/dist/aspect-ratio.cjs +1 -0
- package/dist/aspect-ratio.d.ts +10 -0
- package/dist/aspect-ratio.d.ts.map +1 -0
- package/dist/aspect-ratio.js +22 -0
- package/dist/avatar.cjs +1 -0
- package/dist/avatar.d.ts +11 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +46 -0
- package/dist/badge.cjs +1 -0
- package/dist/badge.d.ts +19 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +50 -0
- package/dist/blocks/data-table.cjs +1 -0
- package/dist/blocks/data-table.d.ts +303 -0
- package/dist/blocks/data-table.d.ts.map +1 -0
- package/dist/blocks/data-table.js +555 -0
- package/dist/blocks/sidebar.cjs +1 -0
- package/dist/blocks/sidebar.d.ts +744 -0
- package/dist/blocks/sidebar.d.ts.map +1 -0
- package/dist/blocks/sidebar.js +839 -0
- package/dist/breadcrumb.cjs +1 -0
- package/dist/breadcrumb.d.ts +12 -0
- package/dist/breadcrumb.d.ts.map +1 -0
- package/dist/breadcrumb.js +102 -0
- package/dist/button.cjs +1 -0
- package/dist/button.d.ts +73 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +195 -0
- package/dist/calendar.cjs +1 -0
- package/dist/calendar.d.ts +28 -0
- package/dist/calendar.d.ts.map +1 -0
- package/dist/calendar.js +191 -0
- package/dist/card.cjs +1 -0
- package/dist/card.d.ts +28 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +131 -0
- package/dist/carousel.cjs +1 -0
- package/dist/carousel.d.ts +21 -0
- package/dist/carousel.d.ts.map +1 -0
- package/dist/carousel.js +185 -0
- package/dist/centred-layout.cjs +1 -0
- package/dist/centred-layout.d.ts +49 -0
- package/dist/centred-layout.d.ts.map +1 -0
- package/dist/centred-layout.js +35 -0
- package/dist/chart.cjs +10 -0
- package/dist/chart.d.ts +83 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +254 -0
- package/dist/checkbox.cjs +1 -0
- package/dist/checkbox.d.ts +15 -0
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/checkbox.js +96 -0
- package/dist/collapsible.cjs +1 -0
- package/dist/collapsible.d.ts +18 -0
- package/dist/collapsible.d.ts.map +1 -0
- package/dist/collapsible.js +58 -0
- package/dist/combobox.cjs +1 -0
- package/dist/combobox.d.ts +65 -0
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +203 -0
- package/dist/command.cjs +1 -0
- package/dist/command.d.ts +44 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +166 -0
- package/dist/context-menu.cjs +1 -0
- package/dist/context-menu.d.ts +42 -0
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/context-menu.js +226 -0
- package/dist/date-picker.cjs +1 -0
- package/dist/date-picker.d.ts +54 -0
- package/dist/date-picker.d.ts.map +1 -0
- package/dist/date-picker.js +95 -0
- package/dist/dialog.cjs +1 -0
- package/dist/dialog.d.ts +20 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +130 -0
- package/dist/drawer.cjs +1 -0
- package/dist/drawer.d.ts +22 -0
- package/dist/drawer.d.ts.map +1 -0
- package/dist/drawer.js +149 -0
- package/dist/dropdown-menu.cjs +1 -0
- package/dist/dropdown-menu.d.ts +253 -0
- package/dist/dropdown-menu.d.ts.map +1 -0
- package/dist/dropdown-menu.js +325 -0
- package/dist/field.cjs +1 -0
- package/dist/field.d.ts +21 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +148 -0
- package/dist/global-layout.cjs +1 -0
- package/dist/global-layout.d.ts +60 -0
- package/dist/global-layout.d.ts.map +1 -0
- package/dist/global-layout.js +87 -0
- package/dist/hooks/use-mobile.cjs +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +16 -0
- package/dist/hover-card.cjs +1 -0
- package/dist/hover-card.d.ts +43 -0
- package/dist/hover-card.d.ts.map +1 -0
- package/dist/hover-card.js +71 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +412 -0
- package/dist/input-base.cjs +1 -0
- package/dist/input-base.d.ts +28 -0
- package/dist/input-base.d.ts.map +1 -0
- package/dist/input-base.js +56 -0
- package/dist/input-group.cjs +1 -0
- package/dist/input-group.d.ts +26 -0
- package/dist/input-group.d.ts.map +1 -0
- package/dist/input-group.js +116 -0
- package/dist/input-otp.cjs +1 -0
- package/dist/input-otp.d.ts +45 -0
- package/dist/input-otp.d.ts.map +1 -0
- package/dist/input-otp.js +186 -0
- package/dist/input-password.cjs +1 -0
- package/dist/input-password.d.ts +38 -0
- package/dist/input-password.d.ts.map +1 -0
- package/dist/input-password.js +101 -0
- package/dist/input.cjs +1 -0
- package/dist/input.d.ts +32 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +146 -0
- package/dist/label.cjs +1 -0
- package/dist/label.d.ts +12 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +34 -0
- package/dist/lib/utils.cjs +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +8 -0
- package/dist/link.cjs +1 -0
- package/dist/link.d.ts +29 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.figma.d.ts +2 -0
- package/dist/link.figma.d.ts.map +1 -0
- package/dist/link.js +71 -0
- package/dist/logo.cjs +1 -0
- package/dist/logo.d.ts +25 -0
- package/dist/logo.d.ts.map +1 -0
- package/dist/logo.js +71 -0
- package/dist/menubar.cjs +1 -0
- package/dist/menubar.d.ts +106 -0
- package/dist/menubar.d.ts.map +1 -0
- package/dist/menubar.js +270 -0
- package/dist/navigation-menu.cjs +1 -0
- package/dist/navigation-menu.d.ts +108 -0
- package/dist/navigation-menu.d.ts.map +1 -0
- package/dist/navigation-menu.js +175 -0
- package/dist/pagination.cjs +1 -0
- package/dist/pagination.d.ts +81 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +216 -0
- package/dist/popover.cjs +1 -0
- package/dist/popover.d.ts +8 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +44 -0
- package/dist/progress.cjs +1 -0
- package/dist/progress.d.ts +29 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +64 -0
- package/dist/radio-group.cjs +1 -0
- package/dist/radio-group.d.ts +33 -0
- package/dist/radio-group.d.ts.map +1 -0
- package/dist/radio-group.js +193 -0
- package/dist/rating.cjs +1 -0
- package/dist/rating.d.ts +22 -0
- package/dist/rating.d.ts.map +1 -0
- package/dist/rating.js +51 -0
- package/dist/resizable.cjs +1 -0
- package/dist/resizable.d.ts +14 -0
- package/dist/resizable.d.ts.map +1 -0
- package/dist/resizable.js +46 -0
- package/dist/scroll-area.cjs +1 -0
- package/dist/scroll-area.d.ts +12 -0
- package/dist/scroll-area.d.ts.map +1 -0
- package/dist/scroll-area.js +67 -0
- package/dist/select.cjs +1 -0
- package/dist/select.d.ts +77 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +259 -0
- package/dist/separator.cjs +1 -0
- package/dist/separator.d.ts +14 -0
- package/dist/separator.d.ts.map +1 -0
- package/dist/separator.js +43 -0
- package/dist/sheet.cjs +1 -0
- package/dist/sheet.d.ts +38 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +190 -0
- package/dist/skeleton.cjs +1 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.d.ts.map +1 -0
- package/dist/skeleton.js +15 -0
- package/dist/slider.cjs +1 -0
- package/dist/slider.d.ts +19 -0
- package/dist/slider.d.ts.map +1 -0
- package/dist/slider.js +69 -0
- package/dist/sonner.cjs +1 -0
- package/dist/sonner.d.ts +188 -0
- package/dist/sonner.d.ts.map +1 -0
- package/dist/sonner.js +150 -0
- package/dist/split-layout.cjs +1 -0
- package/dist/split-layout.d.ts +42 -0
- package/dist/split-layout.d.ts.map +1 -0
- package/dist/split-layout.js +108 -0
- package/dist/switch.cjs +1 -0
- package/dist/switch.d.ts +43 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/switch.figma.d.ts +2 -0
- package/dist/switch.figma.d.ts.map +1 -0
- package/dist/switch.js +110 -0
- package/dist/table.cjs +1 -0
- package/dist/table.d.ts +95 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +164 -0
- package/dist/tabs.cjs +1 -0
- package/dist/tabs.d.ts +29 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +96 -0
- package/dist/textarea.cjs +1 -0
- package/dist/textarea.d.ts +23 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +47 -0
- package/dist/toggle-group.cjs +1 -0
- package/dist/toggle-group.d.ts +25 -0
- package/dist/toggle-group.d.ts.map +1 -0
- package/dist/toggle-group.js +74 -0
- package/dist/toggle.cjs +1 -0
- package/dist/toggle.d.ts +44 -0
- package/dist/toggle.d.ts.map +1 -0
- package/dist/toggle.figma.d.ts +2 -0
- package/dist/toggle.figma.d.ts.map +1 -0
- package/dist/toggle.js +57 -0
- package/dist/tooltip.cjs +1 -0
- package/dist/tooltip.d.ts +66 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +78 -0
- package/package.json +184 -0
- package/src/blocks/data-table.tsx +1166 -0
- package/src/blocks/sidebar.tsx +1830 -0
- package/src/components/.gitkeep +0 -0
- package/src/components/accordion.tsx +142 -0
- package/src/components/alert-dialog.tsx +157 -0
- package/src/components/alert.tsx +199 -0
- package/src/components/aspect-ratio.tsx +30 -0
- package/src/components/avatar.tsx +56 -0
- package/src/components/badge.tsx +72 -0
- package/src/components/breadcrumb.tsx +109 -0
- package/src/components/button.tsx +296 -0
- package/src/components/calendar.tsx +234 -0
- package/src/components/card.tsx +158 -0
- package/src/components/carousel.tsx +256 -0
- package/src/components/centred-layout.tsx +91 -0
- package/src/components/chart.tsx +456 -0
- package/src/components/checkbox.tsx +132 -0
- package/src/components/collapsible.tsx +68 -0
- package/src/components/combobox.tsx +321 -0
- package/src/components/command.tsx +220 -0
- package/src/components/context-menu.tsx +305 -0
- package/src/components/date-picker.tsx +155 -0
- package/src/components/dialog.tsx +152 -0
- package/src/components/drawer.tsx +168 -0
- package/src/components/dropdown-menu.tsx +575 -0
- package/src/components/field.tsx +155 -0
- package/src/components/global-layout.tsx +153 -0
- package/src/components/hover-card.tsx +121 -0
- package/src/components/input-base.tsx +86 -0
- package/src/components/input-group.tsx +158 -0
- package/src/components/input-otp.tsx +327 -0
- package/src/components/input-password.tsx +191 -0
- package/src/components/input.tsx +220 -0
- package/src/components/label.tsx +42 -0
- package/src/components/link.figma.tsx +71 -0
- package/src/components/link.tsx +105 -0
- package/src/components/logo.tsx +97 -0
- package/src/components/menubar.tsx +379 -0
- package/src/components/navigation-menu.tsx +324 -0
- package/src/components/pagination.tsx +368 -0
- package/src/components/popover.tsx +46 -0
- package/src/components/progress.tsx +100 -0
- package/src/components/radio-group.tsx +281 -0
- package/src/components/rating.tsx +87 -0
- package/src/components/resizable.tsx +66 -0
- package/src/components/scroll-area.tsx +72 -0
- package/src/components/select.tsx +442 -0
- package/src/components/separator.tsx +53 -0
- package/src/components/sheet.tsx +220 -0
- package/src/components/skeleton.tsx +17 -0
- package/src/components/slider.tsx +86 -0
- package/src/components/sonner.tsx +396 -0
- package/src/components/split-layout.tsx +155 -0
- package/src/components/switch.figma.tsx +115 -0
- package/src/components/switch.tsx +173 -0
- package/src/components/table.tsx +277 -0
- package/src/components/tabs.tsx +142 -0
- package/src/components/textarea.tsx +77 -0
- package/src/components/toggle-group.tsx +109 -0
- package/src/components/toggle.figma.tsx +81 -0
- package/src/components/toggle.tsx +103 -0
- package/src/components/tooltip.tsx +156 -0
- package/src/hooks/.gitkeep +0 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/index.ts +67 -0
- package/src/lib/utils.ts +6 -0
- package/src/types/external-modules.d.ts +16 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { Label } from "@brightlocal/ui-components/label";
|
|
5
|
+
|
|
6
|
+
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
7
|
+
return (
|
|
8
|
+
<fieldset
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex flex-col gap-6",
|
|
11
|
+
"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
|
12
|
+
className
|
|
13
|
+
)}
|
|
14
|
+
data-slot="field-set"
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function FieldLegend({
|
|
21
|
+
className,
|
|
22
|
+
variant = "legend",
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
|
|
25
|
+
return (
|
|
26
|
+
<legend
|
|
27
|
+
className={cn(
|
|
28
|
+
"mb-3 font-medium",
|
|
29
|
+
"data-[variant=legend]:text-base",
|
|
30
|
+
"data-[variant=label]:text-sm",
|
|
31
|
+
className
|
|
32
|
+
)}
|
|
33
|
+
data-slot="field-legend"
|
|
34
|
+
data-variant={variant}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
className={cn(
|
|
44
|
+
"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
|
|
45
|
+
className
|
|
46
|
+
)}
|
|
47
|
+
data-slot="field-group"
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const fieldVariants = cva("group/field flex w-full gap-2", {
|
|
54
|
+
variants: {
|
|
55
|
+
orientation: {
|
|
56
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
57
|
+
horizontal: [
|
|
58
|
+
"flex-row items-center",
|
|
59
|
+
"[&>[data-slot=field-label]]:flex-auto",
|
|
60
|
+
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
61
|
+
],
|
|
62
|
+
responsive: [
|
|
63
|
+
"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
|
|
64
|
+
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
65
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
orientation: "vertical",
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function Field({
|
|
75
|
+
className,
|
|
76
|
+
orientation = "vertical",
|
|
77
|
+
...props
|
|
78
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
|
|
79
|
+
return (
|
|
80
|
+
<div
|
|
81
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
82
|
+
data-orientation={orientation}
|
|
83
|
+
data-slot="field"
|
|
84
|
+
role="group"
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
className={cn(
|
|
94
|
+
"group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
|
|
95
|
+
className
|
|
96
|
+
)}
|
|
97
|
+
data-slot="field-content"
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function FieldLabel({
|
|
104
|
+
className,
|
|
105
|
+
htmlFor,
|
|
106
|
+
...props
|
|
107
|
+
}: Omit<React.ComponentProps<typeof Label>, "htmlFor"> & {
|
|
108
|
+
/**
|
|
109
|
+
* Required htmlFor attribute for linking label with input
|
|
110
|
+
*/
|
|
111
|
+
htmlFor: string;
|
|
112
|
+
}) {
|
|
113
|
+
return (
|
|
114
|
+
<Label
|
|
115
|
+
className={cn(
|
|
116
|
+
// Base label styles from primitives are inherited via Label component
|
|
117
|
+
"group/field-label peer/field-label w-fit",
|
|
118
|
+
// Field-specific container styles
|
|
119
|
+
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
|
|
120
|
+
// Checked state styles for radio/checkbox fields
|
|
121
|
+
"has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",
|
|
122
|
+
className
|
|
123
|
+
)}
|
|
124
|
+
data-slot="field-label"
|
|
125
|
+
htmlFor={htmlFor}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
132
|
+
return (
|
|
133
|
+
<p
|
|
134
|
+
className={cn(
|
|
135
|
+
"text-muted-foreground mt-2 text-left text-sm",
|
|
136
|
+
"group-has-[[data-orientation=horizontal]]/field:text-balance",
|
|
137
|
+
"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
|
+
className
|
|
140
|
+
)}
|
|
141
|
+
data-slot="field-description"
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
Field,
|
|
149
|
+
FieldLabel,
|
|
150
|
+
FieldDescription,
|
|
151
|
+
FieldGroup,
|
|
152
|
+
FieldLegend,
|
|
153
|
+
FieldSet,
|
|
154
|
+
FieldContent,
|
|
155
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
|
|
5
|
+
// Matches Tailwind's max-w-7xl (1280px) and aligns with Figma design
|
|
6
|
+
const MAX_WIDTH = "1280px";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* GlobalLayout provides a responsive layout structure with optional sidebar
|
|
10
|
+
* and content containers that adapt to different breakpoints.
|
|
11
|
+
*
|
|
12
|
+
* Breakpoints:
|
|
13
|
+
* - Mobile (< 768px): Full width content, no sidebar
|
|
14
|
+
* - Tablet (768px - 1023px): Full width content, no sidebar
|
|
15
|
+
* - Desktop (≥ 1024px): Sidebar + content with max-width container
|
|
16
|
+
*
|
|
17
|
+
* @see https://ui.shadcn.com/docs/components/sidebar for sidebar patterns
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface GlobalLayoutProps extends React.ComponentProps<"div"> {
|
|
21
|
+
/**
|
|
22
|
+
* Maximum width for the global container (default: 1280px)
|
|
23
|
+
*/
|
|
24
|
+
maxWidth?: string | number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function GlobalLayout({
|
|
28
|
+
className,
|
|
29
|
+
maxWidth = MAX_WIDTH,
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}: GlobalLayoutProps) {
|
|
33
|
+
const maxWidthStyle =
|
|
34
|
+
typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className={cn("min-h-screen w-full px-4 md:px-6", className)}
|
|
39
|
+
data-slot="global-layout"
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
className="mx-auto flex h-full w-full"
|
|
44
|
+
data-slot="global-container"
|
|
45
|
+
style={{ maxWidth: maxWidthStyle }}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Matches 16rem (256px) and aligns with Figma design
|
|
54
|
+
const SIDEBAR_WIDTH = "256px";
|
|
55
|
+
|
|
56
|
+
interface GlobalLayoutSidebarProps extends React.ComponentProps<"aside"> {
|
|
57
|
+
/**
|
|
58
|
+
* Width of the sidebar (default: 256px)
|
|
59
|
+
*/
|
|
60
|
+
width?: string | number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function GlobalLayoutSidebar({
|
|
64
|
+
className,
|
|
65
|
+
width = SIDEBAR_WIDTH,
|
|
66
|
+
children,
|
|
67
|
+
...props
|
|
68
|
+
}: GlobalLayoutSidebarProps) {
|
|
69
|
+
const widthStyle = typeof width === "number" ? `${width}px` : width;
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<aside
|
|
73
|
+
className={cn("hidden h-full shrink-0 lg:block", className)}
|
|
74
|
+
data-slot="sidebar-container"
|
|
75
|
+
style={{ width: widthStyle }}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</aside>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Content width variants for GlobalLayoutContent
|
|
85
|
+
*/
|
|
86
|
+
export enum ContentVariant {
|
|
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
|
+
}
|
|
100
|
+
|
|
101
|
+
interface GlobalLayoutContentProps extends React.ComponentProps<"div"> {
|
|
102
|
+
/**
|
|
103
|
+
* Content width variant:
|
|
104
|
+
* - "full": Full width of available space
|
|
105
|
+
* - "md": 768px max-width (medium)
|
|
106
|
+
* - "sm": 374px max-width (small)
|
|
107
|
+
*/
|
|
108
|
+
variant?: ContentVariant;
|
|
109
|
+
/**
|
|
110
|
+
* Custom padding for the content wrapper
|
|
111
|
+
*/
|
|
112
|
+
padding?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function GlobalLayoutContent({
|
|
116
|
+
className,
|
|
117
|
+
variant = ContentVariant.FULL,
|
|
118
|
+
padding,
|
|
119
|
+
children,
|
|
120
|
+
...props
|
|
121
|
+
}: GlobalLayoutContentProps) {
|
|
122
|
+
// Aligned with Figma design and Tailwind breakpoints
|
|
123
|
+
// md: 768px - matches Tailwind's max-w-3xl
|
|
124
|
+
// sm: 374px - optimized for mobile content
|
|
125
|
+
const contentMaxWidth = {
|
|
126
|
+
[ContentVariant.FULL]: "100%",
|
|
127
|
+
[ContentVariant.MD]: "768px",
|
|
128
|
+
[ContentVariant.SM]: "374px",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div
|
|
133
|
+
className={cn("flex h-full min-h-0 min-w-0 flex-1", className)}
|
|
134
|
+
data-slot="content-wrapper"
|
|
135
|
+
{...props}
|
|
136
|
+
>
|
|
137
|
+
<div
|
|
138
|
+
className={cn("mx-auto w-full px-4 md:px-6")}
|
|
139
|
+
data-slot="content-container"
|
|
140
|
+
style={{
|
|
141
|
+
maxWidth: contentMaxWidth[variant],
|
|
142
|
+
padding,
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{children}
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { GlobalLayout, GlobalLayoutSidebar, GlobalLayoutContent };
|
|
152
|
+
|
|
153
|
+
export type { GlobalLayoutProps };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
5
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* HoverCard - A component that displays content on hover
|
|
9
|
+
*
|
|
10
|
+
* Based on Radix UI Hover Card primitive
|
|
11
|
+
* @see https://www.radix-ui.com/docs/primitives/components/hover-card
|
|
12
|
+
*
|
|
13
|
+
* Default timing:
|
|
14
|
+
* - openDelay: 200ms (vs Radix default of 700ms)
|
|
15
|
+
* - closeDelay: 300ms (Radix default)
|
|
16
|
+
*/
|
|
17
|
+
function HoverCard({
|
|
18
|
+
openDelay = 300,
|
|
19
|
+
closeDelay = 300,
|
|
20
|
+
...props
|
|
21
|
+
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
|
22
|
+
// Note: HoverCardPrimitive.Root is a context provider that doesn't render to DOM
|
|
23
|
+
// Data attributes should be placed on HoverCardContent instead
|
|
24
|
+
return (
|
|
25
|
+
<HoverCardPrimitive.Root
|
|
26
|
+
closeDelay={closeDelay}
|
|
27
|
+
openDelay={openDelay}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HoverCardTriggerProps extends React.ComponentProps<
|
|
34
|
+
typeof HoverCardPrimitive.Trigger
|
|
35
|
+
> {
|
|
36
|
+
/**
|
|
37
|
+
* Whether the trigger is disabled
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* HoverCardTrigger - The element that triggers the hover card
|
|
44
|
+
*/
|
|
45
|
+
function HoverCardTrigger({
|
|
46
|
+
className,
|
|
47
|
+
disabled,
|
|
48
|
+
...props
|
|
49
|
+
}: HoverCardTriggerProps) {
|
|
50
|
+
return (
|
|
51
|
+
<HoverCardPrimitive.Trigger
|
|
52
|
+
aria-disabled={disabled}
|
|
53
|
+
className={cn(
|
|
54
|
+
"text-link cursor-pointer text-sm leading-5 font-medium underline",
|
|
55
|
+
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
data-slot="hover-card-trigger"
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface HoverCardContentProps extends React.ComponentPropsWithoutRef<
|
|
65
|
+
typeof HoverCardPrimitive.Content
|
|
66
|
+
> {
|
|
67
|
+
/**
|
|
68
|
+
* Required data-hook attribute for testing and analytics
|
|
69
|
+
*/
|
|
70
|
+
dataHook: string;
|
|
71
|
+
/**
|
|
72
|
+
* Optional analytics element identifier
|
|
73
|
+
*/
|
|
74
|
+
trackingEl?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Optional analytics label context
|
|
77
|
+
*/
|
|
78
|
+
trackingLabel?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* HoverCardContent - The content container that appears on hover
|
|
83
|
+
*/
|
|
84
|
+
const HoverCardContent = React.forwardRef<
|
|
85
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
86
|
+
HoverCardContentProps
|
|
87
|
+
>(
|
|
88
|
+
(
|
|
89
|
+
{
|
|
90
|
+
className,
|
|
91
|
+
align = "center",
|
|
92
|
+
sideOffset = 4,
|
|
93
|
+
dataHook,
|
|
94
|
+
trackingEl,
|
|
95
|
+
trackingLabel,
|
|
96
|
+
...props
|
|
97
|
+
},
|
|
98
|
+
ref
|
|
99
|
+
) => (
|
|
100
|
+
<HoverCardPrimitive.Portal>
|
|
101
|
+
<HoverCardPrimitive.Content
|
|
102
|
+
ref={ref}
|
|
103
|
+
align={align}
|
|
104
|
+
className={cn(
|
|
105
|
+
"border-border bg-popover text-popover-foreground z-50 w-80 rounded-lg border p-4 shadow-md outline-hidden",
|
|
106
|
+
"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",
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
data-hook={dataHook}
|
|
110
|
+
data-slot="hover-card-content"
|
|
111
|
+
data-tracking-el={trackingEl}
|
|
112
|
+
data-tracking-label={trackingLabel}
|
|
113
|
+
sideOffset={sideOffset}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
</HoverCardPrimitive.Portal>
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
120
|
+
|
|
121
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Shared input variant styles
|
|
9
|
+
* These can be reused across different input components
|
|
10
|
+
*/
|
|
11
|
+
export const inputVariants = cva(
|
|
12
|
+
[
|
|
13
|
+
// Layout & Size
|
|
14
|
+
"flex w-full min-w-0 h-9",
|
|
15
|
+
// Appearance
|
|
16
|
+
"border border-input bg-background rounded-sm",
|
|
17
|
+
"outline-none transition-all",
|
|
18
|
+
// Typography
|
|
19
|
+
"text-sm font-sans",
|
|
20
|
+
"text-foreground",
|
|
21
|
+
"overflow-hidden text-ellipsis",
|
|
22
|
+
// States - Focus
|
|
23
|
+
"focus-visible:outline-none focus-visible:border-ring focus-visible:bg-background",
|
|
24
|
+
"focus-visible:shadow-default",
|
|
25
|
+
// States - Disabled
|
|
26
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
27
|
+
// Pseudo-elements
|
|
28
|
+
"placeholder:text-muted-foreground",
|
|
29
|
+
"placeholder:overflow-hidden placeholder:text-ellipsis",
|
|
30
|
+
// Text input alignment - uses design token for text/sm line-height (20px)
|
|
31
|
+
"items-center px-3 pb-[1px] leading-5",
|
|
32
|
+
],
|
|
33
|
+
{
|
|
34
|
+
variants: {
|
|
35
|
+
hasIcon: {
|
|
36
|
+
true: "pl-9",
|
|
37
|
+
false: "",
|
|
38
|
+
},
|
|
39
|
+
hasSecondaryIcon: {
|
|
40
|
+
true: "pr-9",
|
|
41
|
+
false: "",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
hasIcon: false,
|
|
46
|
+
hasSecondaryIcon: false,
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Base input element without label/description wrapper
|
|
53
|
+
* Use this for composing custom input components
|
|
54
|
+
*
|
|
55
|
+
* For inputs with label/description, compose with Field, FieldLabel, FieldDescription
|
|
56
|
+
* For full-featured input with all props, use the Input component
|
|
57
|
+
*/
|
|
58
|
+
export interface BaseInputElementProps extends Omit<
|
|
59
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
60
|
+
"size"
|
|
61
|
+
> {
|
|
62
|
+
/**
|
|
63
|
+
* Whether the input has an icon (adds left padding)
|
|
64
|
+
*/
|
|
65
|
+
hasIcon?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the input has a secondary icon (adds right padding)
|
|
68
|
+
*/
|
|
69
|
+
hasSecondaryIcon?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const BaseInputElement = React.forwardRef<
|
|
73
|
+
HTMLInputElement,
|
|
74
|
+
BaseInputElementProps
|
|
75
|
+
>(({ className, hasIcon = false, hasSecondaryIcon = false, ...props }, ref) => {
|
|
76
|
+
return (
|
|
77
|
+
<input
|
|
78
|
+
ref={ref}
|
|
79
|
+
className={cn(inputVariants({ hasIcon, hasSecondaryIcon }), className)}
|
|
80
|
+
data-slot="input"
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
BaseInputElement.displayName = "BaseInputElement";
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
|
+
import { BaseInputElement } from "@brightlocal/ui-components/input-base";
|
|
9
|
+
|
|
10
|
+
const inputGroupVariants = cva(
|
|
11
|
+
"relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
default: "h-9",
|
|
16
|
+
sm: "h-8",
|
|
17
|
+
lg: "h-10",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: "default",
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
interface InputGroupProps
|
|
27
|
+
extends
|
|
28
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
29
|
+
VariantProps<typeof inputGroupVariants> {}
|
|
30
|
+
|
|
31
|
+
const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
32
|
+
({ className, size, ...props }, ref) => {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(inputGroupVariants({ size }), className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
InputGroup.displayName = "InputGroup";
|
|
43
|
+
|
|
44
|
+
const InputGroupInput = React.forwardRef<
|
|
45
|
+
HTMLInputElement,
|
|
46
|
+
React.InputHTMLAttributes<HTMLInputElement>
|
|
47
|
+
>(({ className, ...props }, ref) => {
|
|
48
|
+
return (
|
|
49
|
+
<BaseInputElement
|
|
50
|
+
ref={ref}
|
|
51
|
+
className={cn(
|
|
52
|
+
// Override border and focus styles since InputGroup handles them
|
|
53
|
+
"border-0 focus-visible:border-0 focus-visible:shadow-[none]",
|
|
54
|
+
"h-full",
|
|
55
|
+
className
|
|
56
|
+
)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
InputGroupInput.displayName = "InputGroupInput";
|
|
62
|
+
|
|
63
|
+
const inputGroupAddonVariants = cva("flex shrink-0 items-center", {
|
|
64
|
+
variants: {
|
|
65
|
+
align: {
|
|
66
|
+
"inline-start": "",
|
|
67
|
+
"inline-end": "ml-auto",
|
|
68
|
+
"block-start": "self-start",
|
|
69
|
+
"block-end": "self-end",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
align: "inline-start",
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
interface InputGroupAddonProps
|
|
78
|
+
extends
|
|
79
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
80
|
+
VariantProps<typeof inputGroupAddonVariants> {}
|
|
81
|
+
|
|
82
|
+
const InputGroupAddon = React.forwardRef<HTMLDivElement, InputGroupAddonProps>(
|
|
83
|
+
({ className, align, ...props }, ref) => {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
ref={ref}
|
|
87
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
InputGroupAddon.displayName = "InputGroupAddon";
|
|
94
|
+
|
|
95
|
+
const inputGroupButtonVariants = cva(
|
|
96
|
+
[
|
|
97
|
+
"inline-flex items-center justify-center gap-2",
|
|
98
|
+
"text-sm font-medium transition-colors",
|
|
99
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
100
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
101
|
+
"text-muted-foreground hover:text-foreground",
|
|
102
|
+
"[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
103
|
+
],
|
|
104
|
+
{
|
|
105
|
+
variants: {
|
|
106
|
+
variant: {
|
|
107
|
+
default: "hover:bg-accent",
|
|
108
|
+
ghost: "",
|
|
109
|
+
},
|
|
110
|
+
size: {
|
|
111
|
+
default: "h-9 px-3",
|
|
112
|
+
sm: "h-8 px-2",
|
|
113
|
+
lg: "h-10 px-4",
|
|
114
|
+
icon: "h-9 w-9",
|
|
115
|
+
"icon-xs": "h-6 w-6",
|
|
116
|
+
"icon-sm": "h-8 w-8",
|
|
117
|
+
"icon-lg": "h-10 w-10",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
defaultVariants: {
|
|
121
|
+
variant: "default",
|
|
122
|
+
size: "default",
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
interface InputGroupButtonProps
|
|
128
|
+
extends
|
|
129
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
130
|
+
VariantProps<typeof inputGroupButtonVariants> {
|
|
131
|
+
asChild?: boolean;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const InputGroupButton = React.forwardRef<
|
|
135
|
+
HTMLButtonElement,
|
|
136
|
+
InputGroupButtonProps
|
|
137
|
+
>(({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
138
|
+
const Comp = asChild ? Slot : "button";
|
|
139
|
+
return (
|
|
140
|
+
<Comp
|
|
141
|
+
ref={ref}
|
|
142
|
+
className={cn(inputGroupButtonVariants({ variant, size, className }))}
|
|
143
|
+
type={asChild ? undefined : "button"}
|
|
144
|
+
{...props}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
InputGroupButton.displayName = "InputGroupButton";
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
InputGroup,
|
|
152
|
+
InputGroupInput,
|
|
153
|
+
InputGroupAddon,
|
|
154
|
+
InputGroupButton,
|
|
155
|
+
inputGroupVariants,
|
|
156
|
+
inputGroupButtonVariants,
|
|
157
|
+
};
|
|
158
|
+
export type { InputGroupProps, InputGroupAddonProps, InputGroupButtonProps };
|