@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
|
@@ -5,82 +5,108 @@ import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Props for the Slider component
|
|
10
|
+
*/
|
|
8
11
|
export interface SliderProps extends React.ComponentProps<
|
|
9
12
|
typeof SliderPrimitive.Root
|
|
10
13
|
> {
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
15
|
+
* Data hook for automated testing (required)
|
|
13
16
|
*/
|
|
14
17
|
dataHook: string;
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
19
|
+
* Accessible labels for the slider thumb(s).
|
|
20
|
+
* For range sliders with multiple thumbs, provide an array of labels.
|
|
21
|
+
* @default ["Slider"]
|
|
22
|
+
*/
|
|
23
|
+
thumbLabels?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Tracking element identifier for analytics
|
|
17
26
|
*/
|
|
18
27
|
trackingEl?: string;
|
|
19
28
|
/**
|
|
20
|
-
*
|
|
29
|
+
* Tracking label for analytics context
|
|
21
30
|
*/
|
|
22
31
|
trackingLabel?: string;
|
|
23
32
|
}
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Slider component for selecting numeric values within a range.
|
|
36
|
+
* Supports single value selection and range selection (two thumbs).
|
|
37
|
+
* Built on Radix UI Slider primitive with full keyboard accessibility.
|
|
38
|
+
*/
|
|
39
|
+
const Slider = React.forwardRef<
|
|
40
|
+
React.ComponentRef<typeof SliderPrimitive.Root>,
|
|
41
|
+
SliderProps
|
|
42
|
+
>(
|
|
43
|
+
(
|
|
44
|
+
{
|
|
45
|
+
className,
|
|
46
|
+
dataHook,
|
|
47
|
+
defaultValue,
|
|
48
|
+
max = 100,
|
|
49
|
+
min = 0,
|
|
50
|
+
thumbLabels,
|
|
51
|
+
trackingEl,
|
|
52
|
+
trackingLabel,
|
|
53
|
+
value,
|
|
54
|
+
...props
|
|
55
|
+
},
|
|
56
|
+
ref
|
|
57
|
+
) => {
|
|
58
|
+
const _values = React.useMemo(
|
|
59
|
+
() =>
|
|
60
|
+
Array.isArray(value)
|
|
61
|
+
? value
|
|
62
|
+
: Array.isArray(defaultValue)
|
|
63
|
+
? defaultValue
|
|
64
|
+
: [min, max],
|
|
65
|
+
[value, defaultValue, min, max]
|
|
66
|
+
);
|
|
45
67
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
50
|
-
className
|
|
51
|
-
)}
|
|
52
|
-
data-hook={dataHook}
|
|
53
|
-
data-slot="slider"
|
|
54
|
-
data-tracking-el={trackingEl}
|
|
55
|
-
data-tracking-label={trackingLabel}
|
|
56
|
-
defaultValue={defaultValue}
|
|
57
|
-
max={max}
|
|
58
|
-
min={min}
|
|
59
|
-
value={value}
|
|
60
|
-
{...props}
|
|
61
|
-
>
|
|
62
|
-
<SliderPrimitive.Track
|
|
68
|
+
return (
|
|
69
|
+
<SliderPrimitive.Root
|
|
70
|
+
ref={ref}
|
|
63
71
|
className={cn(
|
|
64
|
-
"
|
|
72
|
+
"relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
73
|
+
className
|
|
65
74
|
)}
|
|
66
|
-
data-
|
|
75
|
+
data-hook={dataHook}
|
|
76
|
+
data-slot="slider"
|
|
77
|
+
data-tracking-el={trackingEl}
|
|
78
|
+
data-tracking-label={trackingLabel}
|
|
79
|
+
defaultValue={defaultValue}
|
|
80
|
+
max={max}
|
|
81
|
+
min={min}
|
|
82
|
+
value={value}
|
|
83
|
+
{...props}
|
|
67
84
|
>
|
|
68
|
-
<SliderPrimitive.
|
|
85
|
+
<SliderPrimitive.Track
|
|
69
86
|
className={cn(
|
|
70
|
-
"bg-
|
|
87
|
+
"bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
71
88
|
)}
|
|
72
|
-
data-slot="slider-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
89
|
+
data-slot="slider-track"
|
|
90
|
+
>
|
|
91
|
+
<SliderPrimitive.Range
|
|
92
|
+
className={cn(
|
|
93
|
+
"bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
|
|
94
|
+
)}
|
|
95
|
+
data-slot="slider-range"
|
|
96
|
+
/>
|
|
97
|
+
</SliderPrimitive.Track>
|
|
98
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
99
|
+
<SliderPrimitive.Thumb
|
|
100
|
+
key={index}
|
|
101
|
+
aria-label={thumbLabels?.[index] ?? "Slider"}
|
|
102
|
+
className="border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
103
|
+
data-slot="slider-thumb"
|
|
104
|
+
/>
|
|
105
|
+
))}
|
|
106
|
+
</SliderPrimitive.Root>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
Slider.displayName = "Slider";
|
|
85
111
|
|
|
86
112
|
export { Slider };
|
|
@@ -6,15 +6,11 @@ import {
|
|
|
6
6
|
Info,
|
|
7
7
|
Loader2,
|
|
8
8
|
XCircle,
|
|
9
|
-
} from "
|
|
9
|
+
} from "@brightlocal/icons";
|
|
10
10
|
import { cva } from "class-variance-authority";
|
|
11
11
|
import { toast as sonnerToast, Toaster as SonnerToaster } from "sonner";
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
Button,
|
|
15
|
-
ButtonVariant,
|
|
16
|
-
ButtonSize,
|
|
17
|
-
} from "@brightlocal/ui-components/button";
|
|
13
|
+
import { Button } from "@brightlocal/ui-components/button";
|
|
18
14
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
19
15
|
|
|
20
16
|
/**
|
|
@@ -36,7 +32,13 @@ type ToastProps = {
|
|
|
36
32
|
/** Click handler for the button */
|
|
37
33
|
onClick?: () => void;
|
|
38
34
|
/** Visual variant of the button */
|
|
39
|
-
variant?:
|
|
35
|
+
variant?:
|
|
36
|
+
| "default"
|
|
37
|
+
| "destructive"
|
|
38
|
+
| "outline"
|
|
39
|
+
| "secondary"
|
|
40
|
+
| "ghost"
|
|
41
|
+
| "warning";
|
|
40
42
|
};
|
|
41
43
|
/** Color theme for the toast */
|
|
42
44
|
colorSchema?: SonnerColorSchema;
|
|
@@ -44,20 +46,17 @@ type ToastProps = {
|
|
|
44
46
|
icon?: ToastIconType | null;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ERROR = "error",
|
|
52
|
-
LOADING = "loading",
|
|
53
|
-
}
|
|
49
|
+
/**
|
|
50
|
+
* Icon type variants for toast notifications
|
|
51
|
+
*/
|
|
52
|
+
export type SonnerIcon = "info" | "success" | "warning" | "error" | "loading";
|
|
54
53
|
|
|
55
54
|
export type ToastIconType = SonnerIcon | null;
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Color schema variants for toast notifications
|
|
58
|
+
*/
|
|
59
|
+
export type SonnerColorSchema = "default" | "success";
|
|
61
60
|
|
|
62
61
|
type SonnerCustomOptions = {
|
|
63
62
|
className?: string;
|
|
@@ -144,19 +143,19 @@ const ICON_VARIANTS = cva("size-5", {
|
|
|
144
143
|
*/
|
|
145
144
|
function renderToastIcon(type: ToastIconType, schema: "default" | "success") {
|
|
146
145
|
switch (type) {
|
|
147
|
-
case
|
|
146
|
+
case "info":
|
|
148
147
|
return <Info className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
149
|
-
case
|
|
148
|
+
case "success":
|
|
150
149
|
return (
|
|
151
150
|
<CheckCircle2 className={cn(ICON_VARIANTS({ colorSchema: schema }))} />
|
|
152
151
|
);
|
|
153
|
-
case
|
|
152
|
+
case "warning":
|
|
154
153
|
return (
|
|
155
154
|
<AlertTriangle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />
|
|
156
155
|
);
|
|
157
|
-
case
|
|
156
|
+
case "error":
|
|
158
157
|
return <XCircle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
159
|
-
case
|
|
158
|
+
case "loading":
|
|
160
159
|
return (
|
|
161
160
|
<Loader2
|
|
162
161
|
className={cn(ICON_VARIANTS({ colorSchema: schema }), "animate-spin")}
|
|
@@ -215,7 +214,7 @@ function Toast(props: ToastProps) {
|
|
|
215
214
|
const { button, description, icon, title, colorSchema } = props;
|
|
216
215
|
|
|
217
216
|
const resolveSchema = (schema?: SonnerColorSchema): "default" | "success" =>
|
|
218
|
-
schema ===
|
|
217
|
+
schema === "success" ? "success" : "default";
|
|
219
218
|
|
|
220
219
|
const schema = resolveSchema(colorSchema);
|
|
221
220
|
|
|
@@ -243,7 +242,7 @@ function Toast(props: ToastProps) {
|
|
|
243
242
|
aria-label={button.label}
|
|
244
243
|
className="min-h-6 px-2 py-0 text-xs leading-normal font-medium"
|
|
245
244
|
dataHook="toast-action"
|
|
246
|
-
size=
|
|
245
|
+
size="default"
|
|
247
246
|
variant={button.variant}
|
|
248
247
|
onClick={button.onClick}
|
|
249
248
|
>
|
|
@@ -308,13 +307,13 @@ function Toast(props: ToastProps) {
|
|
|
308
307
|
*
|
|
309
308
|
* @example
|
|
310
309
|
* // Then use sonner() anywhere in your app
|
|
311
|
-
* import { sonner
|
|
310
|
+
* import { sonner } from '@brightlocal/ui-components/sonner';
|
|
312
311
|
*
|
|
313
312
|
* function MyComponent() {
|
|
314
313
|
* const handleClick = () => {
|
|
315
314
|
* sonner({
|
|
316
315
|
* title: "Success!",
|
|
317
|
-
* icon:
|
|
316
|
+
* icon: "success"
|
|
318
317
|
* });
|
|
319
318
|
* };
|
|
320
319
|
*
|
|
@@ -324,6 +323,7 @@ function Toast(props: ToastProps) {
|
|
|
324
323
|
function Sonner() {
|
|
325
324
|
return <SonnerToaster position="top-right" />;
|
|
326
325
|
}
|
|
326
|
+
Sonner.displayName = "Sonner";
|
|
327
327
|
|
|
328
328
|
/**
|
|
329
329
|
* @module Sonner
|
|
@@ -345,7 +345,7 @@ function Sonner() {
|
|
|
345
345
|
* <Sonner />
|
|
346
346
|
*
|
|
347
347
|
* // 2. Show toasts anywhere in your app
|
|
348
|
-
* import { sonner
|
|
348
|
+
* import { sonner } from '@brightlocal/ui-components/sonner';
|
|
349
349
|
*
|
|
350
350
|
* // Simple toast
|
|
351
351
|
* sonner({ title: "Hello world" });
|
|
@@ -354,8 +354,8 @@ function Sonner() {
|
|
|
354
354
|
* sonner({
|
|
355
355
|
* title: "Changes saved",
|
|
356
356
|
* description: "Your changes have been saved successfully.",
|
|
357
|
-
* icon:
|
|
358
|
-
* colorSchema:
|
|
357
|
+
* icon: "success",
|
|
358
|
+
* colorSchema: "success",
|
|
359
359
|
* button: {
|
|
360
360
|
* label: "Undo",
|
|
361
361
|
* onClick: () => undoChanges()
|
|
@@ -370,7 +370,7 @@ function Sonner() {
|
|
|
370
370
|
* sonner({
|
|
371
371
|
* title: "Uploading...",
|
|
372
372
|
* description: "Please wait while we upload your file.",
|
|
373
|
-
* icon:
|
|
373
|
+
* icon: "loading",
|
|
374
374
|
* id: loadingToastId
|
|
375
375
|
* });
|
|
376
376
|
*
|
|
@@ -380,15 +380,15 @@ function Sonner() {
|
|
|
380
380
|
* toast.dismiss(loadingToastId);
|
|
381
381
|
* sonner({
|
|
382
382
|
* title: "Upload complete!",
|
|
383
|
-
* icon:
|
|
384
|
-
* colorSchema:
|
|
383
|
+
* icon: "success",
|
|
384
|
+
* colorSchema: "success"
|
|
385
385
|
* });
|
|
386
386
|
* } catch (error) {
|
|
387
387
|
* toast.dismiss(loadingToastId);
|
|
388
388
|
* sonner({
|
|
389
389
|
* title: "Upload failed",
|
|
390
390
|
* description: error.message,
|
|
391
|
-
* icon:
|
|
391
|
+
* icon: "error"
|
|
392
392
|
* });
|
|
393
393
|
* }
|
|
394
394
|
* ```
|
|
@@ -120,7 +120,10 @@ const SplitLayout = React.forwardRef<HTMLDivElement, SplitLayoutProps>(
|
|
|
120
120
|
SplitLayout.displayName = "SplitLayout";
|
|
121
121
|
|
|
122
122
|
interface SplitLayoutSectionProps extends React.ComponentProps<"div"> {
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Which side this section appears on: "left" | "right"
|
|
125
|
+
* @default "left"
|
|
126
|
+
*/
|
|
124
127
|
side?: "left" | "right";
|
|
125
128
|
}
|
|
126
129
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { figma } from "@figma/code-connect";
|
|
3
|
-
import {
|
|
4
|
-
Switch,
|
|
5
|
-
SwitchVariant,
|
|
6
|
-
SwitchSide,
|
|
7
|
-
} from "@brightlocal/ui-components/switch";
|
|
3
|
+
import { Switch } from "@brightlocal/ui-components/switch";
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* Figma Code Connect mapping for Switch component
|
|
@@ -32,8 +28,8 @@ figma.connect(
|
|
|
32
28
|
dataHook="switch-default"
|
|
33
29
|
id="switch"
|
|
34
30
|
label="Switch Text"
|
|
35
|
-
side=
|
|
36
|
-
variant=
|
|
31
|
+
side="right"
|
|
32
|
+
variant="default"
|
|
37
33
|
/>
|
|
38
34
|
),
|
|
39
35
|
}
|
|
@@ -57,8 +53,8 @@ figma.connect(
|
|
|
57
53
|
dataHook="switch-default-left"
|
|
58
54
|
id="switch-left"
|
|
59
55
|
label="Switch Text"
|
|
60
|
-
side=
|
|
61
|
-
variant=
|
|
56
|
+
side="left"
|
|
57
|
+
variant="default"
|
|
62
58
|
/>
|
|
63
59
|
),
|
|
64
60
|
}
|
|
@@ -83,7 +79,7 @@ figma.connect(
|
|
|
83
79
|
description="This is a switch description."
|
|
84
80
|
id="switch-box"
|
|
85
81
|
label="Switch Text"
|
|
86
|
-
variant=
|
|
82
|
+
variant="box"
|
|
87
83
|
/>
|
|
88
84
|
),
|
|
89
85
|
}
|
|
@@ -108,7 +104,7 @@ figma.connect(
|
|
|
108
104
|
description="This is a switch description."
|
|
109
105
|
id="switch-box-right"
|
|
110
106
|
label="Switch Text"
|
|
111
|
-
variant=
|
|
107
|
+
variant="box"
|
|
112
108
|
/>
|
|
113
109
|
),
|
|
114
110
|
}
|
|
@@ -9,22 +9,12 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
9
9
|
/**
|
|
10
10
|
* Visual style variants for Switch component
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
/** Default variant with inline switch and side label */
|
|
14
|
-
DEFAULT = "default",
|
|
15
|
-
/** Box variant with bordered container, label, and description */
|
|
16
|
-
BOX = "box",
|
|
17
|
-
}
|
|
12
|
+
export type SwitchVariant = "default" | "box";
|
|
18
13
|
|
|
19
14
|
/**
|
|
20
15
|
* Label position for switch (used in Default variant)
|
|
21
16
|
*/
|
|
22
|
-
export
|
|
23
|
-
/** Label positioned on the left side */
|
|
24
|
-
LEFT = "left",
|
|
25
|
-
/** Label positioned on the right side */
|
|
26
|
-
RIGHT = "right",
|
|
27
|
-
}
|
|
17
|
+
export type SwitchSide = "left" | "right";
|
|
28
18
|
|
|
29
19
|
const switchVariants = cva(
|
|
30
20
|
[
|
|
@@ -41,7 +31,7 @@ const switchVariants = cva(
|
|
|
41
31
|
},
|
|
42
32
|
},
|
|
43
33
|
defaultVariants: {
|
|
44
|
-
variant:
|
|
34
|
+
variant: "default",
|
|
45
35
|
},
|
|
46
36
|
}
|
|
47
37
|
);
|
|
@@ -73,13 +63,13 @@ const Switch = React.forwardRef<
|
|
|
73
63
|
(
|
|
74
64
|
{
|
|
75
65
|
className,
|
|
76
|
-
variant =
|
|
66
|
+
variant = "default",
|
|
77
67
|
dataHook,
|
|
78
68
|
trackingEl,
|
|
79
69
|
trackingLabel,
|
|
80
70
|
label,
|
|
81
71
|
description,
|
|
82
|
-
side =
|
|
72
|
+
side = "right",
|
|
83
73
|
...props
|
|
84
74
|
},
|
|
85
75
|
ref
|
|
@@ -106,12 +96,12 @@ const Switch = React.forwardRef<
|
|
|
106
96
|
);
|
|
107
97
|
|
|
108
98
|
// Default variant: inline switch with side label
|
|
109
|
-
if (variant ===
|
|
99
|
+
if (variant === "default") {
|
|
110
100
|
return (
|
|
111
101
|
<div
|
|
112
102
|
className={cn(
|
|
113
103
|
"flex items-center gap-2",
|
|
114
|
-
side ===
|
|
104
|
+
side === "left" && "flex-row-reverse"
|
|
115
105
|
)}
|
|
116
106
|
>
|
|
117
107
|
{switchElement}
|
|
@@ -128,7 +118,7 @@ const Switch = React.forwardRef<
|
|
|
128
118
|
}
|
|
129
119
|
|
|
130
120
|
// Box variant: switch in bordered container with label and description
|
|
131
|
-
if (variant ===
|
|
121
|
+
if (variant === "box") {
|
|
132
122
|
const textContent = (
|
|
133
123
|
<div className="flex flex-col gap-2">
|
|
134
124
|
{label && (
|
|
@@ -149,7 +139,7 @@ const Switch = React.forwardRef<
|
|
|
149
139
|
|
|
150
140
|
return (
|
|
151
141
|
<div className="border-border flex items-center justify-between gap-4 rounded-lg border p-4">
|
|
152
|
-
{side ===
|
|
142
|
+
{side === "left" ? (
|
|
153
143
|
<>
|
|
154
144
|
{switchElement}
|
|
155
145
|
{textContent}
|
package/src/components/table.tsx
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
import * as React from "react";
|
|
2
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
5
|
|
|
4
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
7
|
|
|
6
|
-
/**
|
|
7
|
-
* Table size variants
|
|
8
|
-
*/
|
|
9
|
-
export enum TableSize {
|
|
10
|
-
/** Default size - compact padding */
|
|
11
|
-
DEFAULT = "default",
|
|
12
|
-
/** Medium size - moderate padding */
|
|
13
|
-
MD = "md",
|
|
14
|
-
/** Large size - spacious padding */
|
|
15
|
-
LG = "lg",
|
|
16
|
-
}
|
|
17
|
-
|
|
18
8
|
const tableCellVariants = cva(
|
|
19
9
|
"align-middle bg-transparent text-foreground text-sm font-normal leading-normal break-words",
|
|
20
10
|
{
|
|
21
11
|
variants: {
|
|
22
12
|
size: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
default: "h-12 p-2",
|
|
14
|
+
md: "h-16 p-2",
|
|
15
|
+
lg: "h-24 p-2",
|
|
26
16
|
},
|
|
27
17
|
align: {
|
|
28
18
|
left: "text-left",
|
|
@@ -30,14 +20,14 @@ const tableCellVariants = cva(
|
|
|
30
20
|
},
|
|
31
21
|
},
|
|
32
22
|
defaultVariants: {
|
|
33
|
-
size:
|
|
23
|
+
size: "default",
|
|
34
24
|
align: "left",
|
|
35
25
|
},
|
|
36
26
|
}
|
|
37
27
|
);
|
|
38
28
|
|
|
39
29
|
const tableHeadVariants = cva(
|
|
40
|
-
"h-10 p-2 border-b align-middle text-muted-foreground text-sm font-medium leading-normal hover:bg-muted break-words",
|
|
30
|
+
"h-10 p-2 border-b align-middle text-muted-foreground text-sm font-medium leading-normal hover:bg-muted break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",
|
|
41
31
|
{
|
|
42
32
|
variants: {
|
|
43
33
|
align: {
|
|
@@ -162,7 +152,7 @@ const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
|
162
152
|
<tr
|
|
163
153
|
ref={ref}
|
|
164
154
|
className={cn(
|
|
165
|
-
"data-[state=selected]:bg-muted border-b transition-colors",
|
|
155
|
+
"data-[state=selected]:bg-muted border-b transition-colors duration-150 ease-in-out",
|
|
166
156
|
className
|
|
167
157
|
)}
|
|
168
158
|
data-hook={dataHook}
|
|
@@ -186,6 +176,11 @@ interface TableHeadProps
|
|
|
186
176
|
* Minimum width for the column (e.g., "100px", "8rem")
|
|
187
177
|
*/
|
|
188
178
|
minWidth?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Text alignment for the header cell
|
|
181
|
+
* @default "left"
|
|
182
|
+
*/
|
|
183
|
+
align?: "left" | "right";
|
|
189
184
|
}
|
|
190
185
|
|
|
191
186
|
const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
@@ -215,6 +210,16 @@ interface TableCellProps
|
|
|
215
210
|
* Minimum width for the cell (e.g., "100px", "8rem")
|
|
216
211
|
*/
|
|
217
212
|
minWidth?: string;
|
|
213
|
+
/**
|
|
214
|
+
* Size variant for cell height/padding
|
|
215
|
+
* @default "default"
|
|
216
|
+
*/
|
|
217
|
+
size?: "default" | "md" | "lg";
|
|
218
|
+
/**
|
|
219
|
+
* Text alignment for the cell
|
|
220
|
+
* @default "left"
|
|
221
|
+
*/
|
|
222
|
+
align?: "left" | "right";
|
|
218
223
|
}
|
|
219
224
|
|
|
220
225
|
const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(
|
package/src/components/tabs.tsx
CHANGED
|
@@ -5,9 +5,15 @@ import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Props for the Tabs component
|
|
10
|
+
*/
|
|
8
11
|
interface TabsProps extends React.ComponentProps<typeof TabsPrimitive.Root> {
|
|
12
|
+
/** Data hook for automated testing (required) */
|
|
9
13
|
dataHook: string;
|
|
14
|
+
/** Tracking element identifier for analytics */
|
|
10
15
|
trackingEl?: string;
|
|
16
|
+
/** Tracking label for analytics context */
|
|
11
17
|
trackingLabel?: string;
|
|
12
18
|
}
|
|
13
19
|
|
|
@@ -28,11 +34,17 @@ const Tabs = React.forwardRef<
|
|
|
28
34
|
|
|
29
35
|
Tabs.displayName = "Tabs";
|
|
30
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Props for the TabsList component
|
|
39
|
+
*/
|
|
31
40
|
interface TabsListProps extends React.ComponentProps<
|
|
32
41
|
typeof TabsPrimitive.List
|
|
33
42
|
> {
|
|
34
|
-
|
|
43
|
+
/** Data hook for automated testing */
|
|
44
|
+
dataHook?: string;
|
|
45
|
+
/** Tracking element identifier for analytics */
|
|
35
46
|
trackingEl?: string;
|
|
47
|
+
/** Tracking label for analytics context */
|
|
36
48
|
trackingLabel?: string;
|
|
37
49
|
}
|
|
38
50
|
|
|
@@ -61,11 +73,17 @@ const TabsList = React.forwardRef<
|
|
|
61
73
|
|
|
62
74
|
TabsList.displayName = "TabsList";
|
|
63
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Props for the TabsTrigger component
|
|
78
|
+
*/
|
|
64
79
|
interface TabsTriggerProps extends React.ComponentProps<
|
|
65
80
|
typeof TabsPrimitive.Trigger
|
|
66
81
|
> {
|
|
67
|
-
|
|
82
|
+
/** Data hook for automated testing */
|
|
83
|
+
dataHook?: string;
|
|
84
|
+
/** Tracking element identifier for analytics */
|
|
68
85
|
trackingEl?: string;
|
|
86
|
+
/** Tracking label for analytics context */
|
|
69
87
|
trackingLabel?: string;
|
|
70
88
|
}
|
|
71
89
|
|
|
@@ -112,11 +130,17 @@ const TabsTrigger = React.forwardRef<
|
|
|
112
130
|
|
|
113
131
|
TabsTrigger.displayName = "TabsTrigger";
|
|
114
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Props for the TabsContent component
|
|
135
|
+
*/
|
|
115
136
|
interface TabsContentProps extends React.ComponentProps<
|
|
116
137
|
typeof TabsPrimitive.Content
|
|
117
138
|
> {
|
|
118
|
-
|
|
139
|
+
/** Data hook for automated testing */
|
|
140
|
+
dataHook?: string;
|
|
141
|
+
/** Tracking element identifier for analytics */
|
|
119
142
|
trackingEl?: string;
|
|
143
|
+
/** Tracking label for analytics context */
|
|
120
144
|
trackingLabel?: string;
|
|
121
145
|
}
|
|
122
146
|
|