@brightlocal/ui-components 0.1.1 → 0.1.3
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.d.ts +22 -1
- package/dist/alert.d.ts.map +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 +209 -202
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +154 -154
- 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 +12 -0
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +10 -8
- 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 -2
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +46 -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 +29 -11
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +193 -159
- 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 +119 -121
- 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 +220 -81
- 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 +23 -6
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +54 -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 +383 -387
- 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-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +24 -25
- 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/logo.cjs +1 -1
- package/dist/logo.d.ts +3 -0
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +12 -10
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +40 -6
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +97 -76
- 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.d.ts +40 -0
- package/dist/radio-group.d.ts.map +1 -1
- 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 +65 -4
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +53 -36
- 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 +49 -2
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +48 -36
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +80 -9
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +117 -113
- 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 +4 -2
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +29 -28
- package/dist/split-layout.d.ts +4 -1
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.js +1 -1
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.d.ts +3 -1
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +38 -36
- package/package.json +8 -2
- package/src/blocks/data-table.tsx +42 -32
- package/src/blocks/sidebar.tsx +4 -12
- package/src/components/accordion.tsx +163 -77
- package/src/components/alert-dialog.tsx +156 -111
- package/src/components/alert.tsx +26 -13
- 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 +158 -82
- package/src/components/button.tsx +41 -62
- package/src/components/calendar.tsx +16 -2
- package/src/components/card.tsx +92 -40
- package/src/components/carousel.tsx +240 -115
- package/src/components/centred-layout.tsx +67 -35
- package/src/components/chart.tsx +118 -47
- package/src/components/checkbox.tsx +42 -78
- package/src/components/collapsible.tsx +95 -26
- package/src/components/combobox.tsx +242 -144
- package/src/components/command.tsx +295 -121
- package/src/components/context-menu.tsx +278 -81
- package/src/components/date-picker.tsx +281 -30
- package/src/components/description.tsx +60 -0
- package/src/components/dialog.tsx +162 -86
- package/src/components/drawer.tsx +76 -2
- package/src/components/dropdown-menu.tsx +143 -37
- package/src/components/field.tsx +36 -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-password.tsx +3 -4
- package/src/components/input.tsx +93 -186
- package/src/components/label.tsx +56 -15
- package/src/components/logo.tsx +3 -0
- package/src/components/menubar.tsx +58 -4
- package/src/components/popover.tsx +103 -20
- package/src/components/progress.tsx +82 -60
- package/src/components/radio-group.tsx +40 -0
- package/src/components/rating.tsx +4 -1
- package/src/components/resizable.tsx +119 -31
- package/src/components/scroll-area.tsx +123 -56
- package/src/components/select.tsx +21 -1
- package/src/components/separator.tsx +97 -20
- package/src/components/sheet.tsx +180 -79
- package/src/components/skeleton.tsx +40 -10
- package/src/components/slider.tsx +83 -57
- package/src/components/sonner.tsx +10 -7
- package/src/components/split-layout.tsx +4 -1
- package/src/components/table.tsx +1 -1
- package/src/components/toggle-group.tsx +4 -0
- 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
|
@@ -5,60 +5,29 @@ import { Loader2 } from "lucide-react";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Available button visual variants
|
|
10
|
-
*/
|
|
11
|
-
export enum ButtonVariant {
|
|
12
|
-
/** Primary action button with solid background */
|
|
13
|
-
DEFAULT = "default",
|
|
14
|
-
/** Destructive action button (delete, remove, etc.) */
|
|
15
|
-
DESTRUCTIVE = "destructive",
|
|
16
|
-
/** Button with border and transparent background */
|
|
17
|
-
OUTLINE = "outline",
|
|
18
|
-
/** Secondary action button with muted background */
|
|
19
|
-
SECONDARY = "secondary",
|
|
20
|
-
/** Subtle button with transparent background */
|
|
21
|
-
GHOST = "ghost",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Available button size variants
|
|
26
|
-
*/
|
|
27
|
-
export enum ButtonSize {
|
|
28
|
-
/** Standard button size (36px height) */
|
|
29
|
-
DEFAULT = "default",
|
|
30
|
-
/** Small button size (32px height) */
|
|
31
|
-
SM = "sm",
|
|
32
|
-
/** Large button size (40px height) */
|
|
33
|
-
LG = "lg",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal button state variants for styling
|
|
38
|
-
*/
|
|
39
|
-
export enum ButtonState {
|
|
40
|
-
/** Normal interactive state */
|
|
41
|
-
Default = "default",
|
|
42
|
-
/** Loading state with spinner */
|
|
43
|
-
Loading = "loading",
|
|
44
|
-
/** Disabled state with reduced opacity */
|
|
45
|
-
Disabled = "disabled",
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Button types matching native button types
|
|
50
|
-
*/
|
|
51
|
-
export enum ButtonType {
|
|
52
|
-
BUTTON = "button",
|
|
53
|
-
SUBMIT = "submit",
|
|
54
|
-
}
|
|
55
|
-
|
|
56
8
|
// Shared constants
|
|
57
9
|
const BUTTON_SPINNER_SIZE = 16;
|
|
58
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Variant props for CVA button styling
|
|
13
|
+
*/
|
|
59
14
|
type ButtonVariantProps = {
|
|
60
|
-
|
|
61
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Visual style variant of the button
|
|
17
|
+
* @default "default"
|
|
18
|
+
*/
|
|
19
|
+
variant?:
|
|
20
|
+
| "default"
|
|
21
|
+
| "destructive"
|
|
22
|
+
| "outline"
|
|
23
|
+
| "secondary"
|
|
24
|
+
| "ghost"
|
|
25
|
+
| "warning";
|
|
26
|
+
/**
|
|
27
|
+
* Size variant of the button
|
|
28
|
+
* @default "default"
|
|
29
|
+
*/
|
|
30
|
+
size?: "default" | "sm" | "lg";
|
|
62
31
|
};
|
|
63
32
|
|
|
64
33
|
const ButtonVariants = cva(
|
|
@@ -70,7 +39,9 @@ const ButtonVariants = cva(
|
|
|
70
39
|
"justify-center",
|
|
71
40
|
"gap-2",
|
|
72
41
|
"whitespace-nowrap",
|
|
73
|
-
"transition-
|
|
42
|
+
"transition-[color,background-color,border-color,box-shadow]",
|
|
43
|
+
"duration-150",
|
|
44
|
+
"ease-in-out",
|
|
74
45
|
"cursor-pointer",
|
|
75
46
|
"disabled:pointer-events-none",
|
|
76
47
|
"disabled:cursor-not-allowed",
|
|
@@ -114,6 +85,7 @@ const ButtonVariants = cva(
|
|
|
114
85
|
"dark:hover:bg-input/80",
|
|
115
86
|
"dark:hover:border-input",
|
|
116
87
|
"focus-visible:shadow-default",
|
|
88
|
+
"focus-visible:border-ring",
|
|
117
89
|
],
|
|
118
90
|
secondary: [
|
|
119
91
|
"bg-secondary",
|
|
@@ -151,9 +123,9 @@ const ButtonVariants = cva(
|
|
|
151
123
|
},
|
|
152
124
|
},
|
|
153
125
|
defaultVariants: {
|
|
154
|
-
variant:
|
|
155
|
-
size:
|
|
156
|
-
state:
|
|
126
|
+
variant: "default",
|
|
127
|
+
size: "default",
|
|
128
|
+
state: "default",
|
|
157
129
|
fullWidth: false,
|
|
158
130
|
},
|
|
159
131
|
}
|
|
@@ -169,8 +141,13 @@ type ButtonProps = NativeButtonProps &
|
|
|
169
141
|
ariaLabel?: string;
|
|
170
142
|
asChild?: boolean;
|
|
171
143
|
dataHook: string;
|
|
172
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Button type attribute
|
|
146
|
+
* @default "button"
|
|
147
|
+
*/
|
|
148
|
+
type?: "button" | "submit";
|
|
173
149
|
fullWidth?: boolean;
|
|
150
|
+
iconOnly?: boolean;
|
|
174
151
|
loading?: boolean;
|
|
175
152
|
trackingEl?: string;
|
|
176
153
|
trackingLabel?: string;
|
|
@@ -180,13 +157,14 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
180
157
|
(
|
|
181
158
|
{
|
|
182
159
|
className,
|
|
183
|
-
variant =
|
|
184
|
-
size =
|
|
160
|
+
variant = "default",
|
|
161
|
+
size = "default",
|
|
185
162
|
fullWidth = false,
|
|
186
163
|
asChild = false,
|
|
187
164
|
dataHook,
|
|
188
165
|
trackingEl,
|
|
189
166
|
trackingLabel,
|
|
167
|
+
iconOnly = false,
|
|
190
168
|
loading = false,
|
|
191
169
|
ariaLabel,
|
|
192
170
|
disabled = false,
|
|
@@ -202,8 +180,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
202
180
|
|
|
203
181
|
// Determine content to display
|
|
204
182
|
const displayChildren = children;
|
|
205
|
-
let isSingleIconOnly =
|
|
183
|
+
let isSingleIconOnly = iconOnly;
|
|
206
184
|
if (
|
|
185
|
+
!isSingleIconOnly &&
|
|
207
186
|
React.Children.count(children) === 1 &&
|
|
208
187
|
React.isValidElement(children)
|
|
209
188
|
) {
|
|
@@ -215,9 +194,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
215
194
|
const showLoadingSpinner = loading && !asChild;
|
|
216
195
|
|
|
217
196
|
// Compute visual state class via CVA
|
|
218
|
-
let visualState:
|
|
219
|
-
if (loading) visualState =
|
|
220
|
-
else if (disabled) visualState =
|
|
197
|
+
let visualState: "default" | "loading" | "disabled" = "default";
|
|
198
|
+
if (loading) visualState = "loading";
|
|
199
|
+
else if (disabled) visualState = "disabled";
|
|
221
200
|
|
|
222
201
|
// Ensure we always have an accessible label
|
|
223
202
|
const effectiveAriaLabel =
|
|
@@ -272,7 +251,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
272
251
|
data-tracking-el={trackingEl || `button-${variant}`}
|
|
273
252
|
data-tracking-label={trackingLabel}
|
|
274
253
|
disabled={isDisabled}
|
|
275
|
-
type={props.type ??
|
|
254
|
+
type={props.type ?? "button"}
|
|
276
255
|
{...props}
|
|
277
256
|
>
|
|
278
257
|
{showLoadingSpinner && (
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Props for the Calendar component
|
|
16
|
+
*/
|
|
14
17
|
export type CalendarProps = DayPickerProps & {
|
|
15
18
|
/**
|
|
16
19
|
* Number of months to display (1-3)
|
|
@@ -32,12 +35,17 @@ export type CalendarProps = DayPickerProps & {
|
|
|
32
35
|
};
|
|
33
36
|
|
|
34
37
|
const navButtonStyles = cn(
|
|
35
|
-
"inline-flex items-center justify-center rounded-md
|
|
38
|
+
"inline-flex items-center justify-center rounded-md",
|
|
39
|
+
"text-muted-foreground hover:text-foreground",
|
|
36
40
|
"hover:bg-accent hover:text-accent-foreground",
|
|
37
41
|
"focus-visible:outline-none focus-visible:shadow-default",
|
|
38
|
-
"h-8 w-8 p-0
|
|
42
|
+
"h-8 w-8 p-0"
|
|
39
43
|
);
|
|
40
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Custom day button component for the Calendar.
|
|
47
|
+
* Renders individual day cells with proper styling and selection states.
|
|
48
|
+
*/
|
|
41
49
|
function CalendarDayButton({
|
|
42
50
|
className,
|
|
43
51
|
day,
|
|
@@ -82,6 +90,11 @@ function CalendarDayButton({
|
|
|
82
90
|
);
|
|
83
91
|
}
|
|
84
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Calendar component for date and range selection.
|
|
95
|
+
* Supports single date, multiple dates, and date range selection modes.
|
|
96
|
+
* Built on top of react-day-picker with custom styling and navigation.
|
|
97
|
+
*/
|
|
85
98
|
function Calendar({
|
|
86
99
|
className,
|
|
87
100
|
classNames,
|
|
@@ -214,6 +227,7 @@ function Calendar({
|
|
|
214
227
|
...components,
|
|
215
228
|
}}
|
|
216
229
|
data-hook={dataHook}
|
|
230
|
+
data-slot="calendar"
|
|
217
231
|
data-tracking-el={trackingEl}
|
|
218
232
|
data-tracking-label={trackingLabel}
|
|
219
233
|
fixedWeeks={fixedWeeks}
|
package/src/components/card.tsx
CHANGED
|
@@ -3,18 +3,6 @@ import { cva } from "class-variance-authority";
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Available card visual variants
|
|
8
|
-
*/
|
|
9
|
-
export enum CardVariant {
|
|
10
|
-
/** Default card with background, border */
|
|
11
|
-
DEFAULT = "default",
|
|
12
|
-
/** Transparent card with no background or border */
|
|
13
|
-
TRANSPARENT = "transparent",
|
|
14
|
-
/** Card with border only, no background or shadow */
|
|
15
|
-
BORDER = "border",
|
|
16
|
-
}
|
|
17
|
-
|
|
18
6
|
const cardVariants = cva(
|
|
19
7
|
["flex", "flex-col", "gap-8", "rounded-[14px]", "py-8", "transition-colors"],
|
|
20
8
|
{
|
|
@@ -36,23 +24,43 @@ const cardVariants = cva(
|
|
|
36
24
|
},
|
|
37
25
|
},
|
|
38
26
|
defaultVariants: {
|
|
39
|
-
variant:
|
|
27
|
+
variant: "default",
|
|
40
28
|
},
|
|
41
29
|
}
|
|
42
30
|
);
|
|
43
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Props for the Card component
|
|
34
|
+
*/
|
|
44
35
|
type CardProps = React.ComponentProps<"div"> & {
|
|
45
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Visual style variant of the card
|
|
38
|
+
* @default "default"
|
|
39
|
+
*/
|
|
40
|
+
variant?: "default" | "transparent" | "border";
|
|
41
|
+
/**
|
|
42
|
+
* Data hook for automated testing (required)
|
|
43
|
+
*/
|
|
46
44
|
dataHook: string;
|
|
45
|
+
/**
|
|
46
|
+
* Tracking element identifier for analytics
|
|
47
|
+
*/
|
|
47
48
|
trackingEl?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Tracking label for analytics context
|
|
51
|
+
*/
|
|
48
52
|
trackingLabel?: string;
|
|
49
53
|
};
|
|
50
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Container component for grouping related content with visual separation.
|
|
57
|
+
* Supports multiple visual variants for different contexts.
|
|
58
|
+
*/
|
|
51
59
|
const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
52
60
|
(
|
|
53
61
|
{
|
|
54
62
|
className,
|
|
55
|
-
variant =
|
|
63
|
+
variant = "default",
|
|
56
64
|
dataHook,
|
|
57
65
|
trackingEl,
|
|
58
66
|
trackingLabel,
|
|
@@ -76,9 +84,27 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
76
84
|
|
|
77
85
|
Card.displayName = "Card";
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Props for Card sub-components
|
|
89
|
+
*/
|
|
90
|
+
type CardSubComponentProps = React.ComponentProps<"div"> & {
|
|
91
|
+
/**
|
|
92
|
+
* Additional CSS classes to apply
|
|
93
|
+
*/
|
|
94
|
+
className?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Content to render inside the component
|
|
97
|
+
*/
|
|
98
|
+
children?: React.ReactNode;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Header section of the Card containing title and description.
|
|
103
|
+
*/
|
|
104
|
+
const CardHeader = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
105
|
+
({ className, ...props }, ref) => (
|
|
81
106
|
<div
|
|
107
|
+
ref={ref}
|
|
82
108
|
className={cn(
|
|
83
109
|
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-8 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
|
|
84
110
|
className
|
|
@@ -86,22 +112,32 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
86
112
|
data-slot="card-header"
|
|
87
113
|
{...props}
|
|
88
114
|
/>
|
|
89
|
-
)
|
|
90
|
-
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
CardHeader.displayName = "CardHeader";
|
|
91
118
|
|
|
92
|
-
|
|
93
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Title element within the Card header.
|
|
121
|
+
*/
|
|
122
|
+
const CardTitle = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
123
|
+
({ className, ...props }, ref) => (
|
|
94
124
|
<div
|
|
125
|
+
ref={ref}
|
|
95
126
|
className={cn("heading-sm", className)}
|
|
96
127
|
data-slot="card-title"
|
|
97
128
|
{...props}
|
|
98
129
|
/>
|
|
99
|
-
)
|
|
100
|
-
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
CardTitle.displayName = "CardTitle";
|
|
101
133
|
|
|
102
|
-
|
|
103
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Description text within the Card header.
|
|
136
|
+
*/
|
|
137
|
+
const CardDescription = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
138
|
+
({ className, ...props }, ref) => (
|
|
104
139
|
<div
|
|
140
|
+
ref={ref}
|
|
105
141
|
className={cn(
|
|
106
142
|
"text-muted-foreground text-sm leading-normal font-normal",
|
|
107
143
|
className
|
|
@@ -109,12 +145,17 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
109
145
|
data-slot="card-description"
|
|
110
146
|
{...props}
|
|
111
147
|
/>
|
|
112
|
-
)
|
|
113
|
-
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
CardDescription.displayName = "CardDescription";
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Action area within the Card header for buttons or controls.
|
|
154
|
+
*/
|
|
155
|
+
const CardAction = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
156
|
+
({ className, ...props }, ref) => (
|
|
117
157
|
<div
|
|
158
|
+
ref={ref}
|
|
118
159
|
className={cn(
|
|
119
160
|
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
120
161
|
className
|
|
@@ -122,28 +163,39 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
122
163
|
data-slot="card-action"
|
|
123
164
|
{...props}
|
|
124
165
|
/>
|
|
125
|
-
)
|
|
126
|
-
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
CardAction.displayName = "CardAction";
|
|
127
169
|
|
|
128
|
-
|
|
129
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Main content area of the Card.
|
|
172
|
+
*/
|
|
173
|
+
const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
174
|
+
({ className, ...props }, ref) => (
|
|
130
175
|
<div
|
|
176
|
+
ref={ref}
|
|
131
177
|
className={cn("px-8", className)}
|
|
132
178
|
data-slot="card-content"
|
|
133
179
|
{...props}
|
|
134
180
|
/>
|
|
135
|
-
)
|
|
136
|
-
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
CardContent.displayName = "CardContent";
|
|
137
184
|
|
|
138
|
-
|
|
139
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Footer section of the Card for actions or metadata.
|
|
187
|
+
*/
|
|
188
|
+
const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
189
|
+
({ className, ...props }, ref) => (
|
|
140
190
|
<div
|
|
191
|
+
ref={ref}
|
|
141
192
|
className={cn("flex items-center px-8", className)}
|
|
142
193
|
data-slot="card-footer"
|
|
143
194
|
{...props}
|
|
144
195
|
/>
|
|
145
|
-
)
|
|
146
|
-
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
CardFooter.displayName = "CardFooter";
|
|
147
199
|
|
|
148
200
|
export {
|
|
149
201
|
Card,
|
|
@@ -155,4 +207,4 @@ export {
|
|
|
155
207
|
CardContent,
|
|
156
208
|
};
|
|
157
209
|
|
|
158
|
-
export type { CardProps };
|
|
210
|
+
export type { CardProps, CardSubComponentProps };
|