@brightlocal/ui-components 0.4.1 → 1.0.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/README.md +2 -1
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +2 -2
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +2 -2
- package/dist/alert.js +64 -64
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +38 -38
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +2 -2
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +23 -23
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +34 -34
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +2 -2
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +58 -57
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +19 -40
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.js +1 -1
- package/dist/chart.cjs +2 -2
- package/dist/chart.d.ts +3 -1
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +21 -21
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +3 -3
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +6 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +157 -149
- package/dist/command.cjs +1 -1
- package/dist/command.js +35 -35
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +2 -2
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +7 -7
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +22 -22
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +40 -45
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +8 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +133 -92
- package/dist/header.d.ts.map +1 -1
- package/dist/header.js +1 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +394 -381
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +18 -25
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +1 -1
- package/dist/input-group.js +10 -10
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +3 -20
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +93 -134
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +16 -16
- package/dist/input.cjs +1 -1
- package/dist/input.js +9 -9
- package/dist/label.cjs +1 -1
- package/dist/label.js +1 -1
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +1 -8
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +23 -11
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.js +12 -12
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +15 -15
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +3 -19
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +93 -121
- package/dist/resizable.d.ts +1 -1
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +1 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +46 -50
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +19 -19
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +7 -8
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts +1 -21
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +31 -100
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +10 -12
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +9 -9
- package/dist/typography.cjs +1 -0
- package/dist/typography.d.ts +176 -0
- package/dist/typography.d.ts.map +1 -0
- package/dist/typography.js +331 -0
- package/package.json +2 -2
- package/src/blocks/data-table.tsx +10 -10
- package/src/blocks/sidebar.tsx +13 -13
- package/src/components/accordion.tsx +2 -2
- package/src/components/alert.tsx +10 -10
- package/src/components/breadcrumb.tsx +3 -3
- package/src/components/button.tsx +7 -7
- package/src/components/calendar.tsx +4 -22
- package/src/components/centred-layout.tsx +1 -1
- package/src/components/chart.tsx +5 -5
- package/src/components/checkbox.tsx +3 -3
- package/src/components/combobox.tsx +26 -10
- package/src/components/command.tsx +5 -5
- package/src/components/context-menu.tsx +2 -2
- package/src/components/date-picker.tsx +1 -1
- package/src/components/dialog.tsx +3 -3
- package/src/components/dropdown-menu.tsx +6 -11
- package/src/components/field.tsx +70 -22
- package/src/components/header.tsx +1 -4
- package/src/components/input-chip.tsx +1 -4
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-otp.tsx +12 -92
- package/src/components/input-password.tsx +2 -10
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +1 -1
- package/src/components/link.tsx +1 -5
- package/src/components/logo.tsx +11 -5
- package/src/components/menubar.tsx +2 -2
- package/src/components/pagination.tsx +4 -8
- package/src/components/radio-group.tsx +66 -130
- package/src/components/select.tsx +8 -12
- package/src/components/sheet.tsx +5 -5
- package/src/components/sonner.tsx +4 -5
- package/src/components/switch.tsx +29 -140
- package/src/components/tabs.tsx +0 -2
- package/src/components/toggle.tsx +1 -1
- package/src/components/typography.tsx +678 -0
- package/src/index.ts +1 -0
- package/dist/link.figma.d.ts +0 -2
- package/dist/link.figma.d.ts.map +0 -1
- package/dist/switch.figma.d.ts +0 -2
- package/dist/switch.figma.d.ts.map +0 -1
- package/dist/toggle.figma.d.ts +0 -2
- package/dist/toggle.figma.d.ts.map +0 -1
- package/src/components/link.figma.tsx +0 -71
- package/src/components/switch.figma.tsx +0 -111
- package/src/components/toggle.figma.tsx +0 -75
|
@@ -6,7 +6,6 @@ import { Circle } from "@brightlocal/icons";
|
|
|
6
6
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
|
-
import { Label } from "@brightlocal/ui-components/label";
|
|
10
9
|
|
|
11
10
|
/* ---------------------------------- Styles -------------------------------- */
|
|
12
11
|
|
|
@@ -14,9 +13,9 @@ const radioGroupVariants = cva("grid", {
|
|
|
14
13
|
variants: {
|
|
15
14
|
variant: {
|
|
16
15
|
default: ["gap-3"],
|
|
17
|
-
box: ["gap-
|
|
16
|
+
box: ["gap-3"],
|
|
18
17
|
boxIconVertical: ["grid-flow-col auto-cols-fr gap-3"],
|
|
19
|
-
boxIconHorizontal: ["gap-
|
|
18
|
+
boxIconHorizontal: ["gap-3"],
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
21
|
defaultVariants: {
|
|
@@ -25,32 +24,14 @@ const radioGroupVariants = cva("grid", {
|
|
|
25
24
|
});
|
|
26
25
|
|
|
27
26
|
const radioGroupItemVariants = cva(
|
|
28
|
-
"group relative flex cursor-pointer outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
27
|
+
"group relative flex cursor-pointer outline-none disabled:cursor-not-allowed disabled:opacity-50 after:absolute after:inset-0",
|
|
29
28
|
{
|
|
30
29
|
variants: {
|
|
31
30
|
variant: {
|
|
32
|
-
default: ["items-
|
|
33
|
-
box: [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"data-[state=checked]:border-primary data-[state=checked]:bg-primary/10",
|
|
37
|
-
"dark:data-[state=checked]:bg-alpha-10",
|
|
38
|
-
"focus-visible:outline-none",
|
|
39
|
-
],
|
|
40
|
-
boxIconVertical: [
|
|
41
|
-
"flex-col items-center gap-3 rounded-lg border border-border bg-background p-3",
|
|
42
|
-
"transition-colors",
|
|
43
|
-
"data-[state=checked]:border-primary data-[state=checked]:bg-primary/10",
|
|
44
|
-
"dark:data-[state=checked]:bg-alpha-10",
|
|
45
|
-
"focus-visible:outline-none focus-visible:shadow-default",
|
|
46
|
-
],
|
|
47
|
-
boxIconHorizontal: [
|
|
48
|
-
"flex-row items-start gap-3 rounded-lg border border-border bg-background p-3",
|
|
49
|
-
"transition-colors",
|
|
50
|
-
"data-[state=checked]:border-primary data-[state=checked]:bg-primary/10",
|
|
51
|
-
"dark:data-[state=checked]:bg-alpha-10",
|
|
52
|
-
"focus-visible:outline-none focus-visible:shadow-default",
|
|
53
|
-
],
|
|
31
|
+
default: ["items-center"],
|
|
32
|
+
box: ["items-center"],
|
|
33
|
+
boxIconVertical: ["items-center justify-center"],
|
|
34
|
+
boxIconHorizontal: ["items-center justify-center"],
|
|
54
35
|
},
|
|
55
36
|
},
|
|
56
37
|
defaultVariants: {
|
|
@@ -60,7 +41,7 @@ const radioGroupItemVariants = cva(
|
|
|
60
41
|
);
|
|
61
42
|
|
|
62
43
|
const radioCircleVariants = cva(
|
|
63
|
-
"relative aspect-square size-4 shrink-0 rounded-full border transition-
|
|
44
|
+
"relative aspect-square size-4 shrink-0 rounded-full border transition-[border-color,border-width,box-shadow,background-color]",
|
|
64
45
|
{
|
|
65
46
|
variants: {
|
|
66
47
|
variant: {
|
|
@@ -99,23 +80,6 @@ const radioCircleVariants = cva(
|
|
|
99
80
|
}
|
|
100
81
|
);
|
|
101
82
|
|
|
102
|
-
const radioContentVariants = cva(
|
|
103
|
-
"text-foreground flex flex-col gap-1.5 leading-none",
|
|
104
|
-
{
|
|
105
|
-
variants: {
|
|
106
|
-
variant: {
|
|
107
|
-
default: [],
|
|
108
|
-
box: ["text-left"],
|
|
109
|
-
boxIconVertical: ["items-center"],
|
|
110
|
-
boxIconHorizontal: ["text-left justify-center"],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
defaultVariants: {
|
|
114
|
-
variant: "default",
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
|
|
119
83
|
/* ---------------------------------- Types --------------------------------- */
|
|
120
84
|
|
|
121
85
|
/**
|
|
@@ -133,6 +97,7 @@ type RadioGroupVariant =
|
|
|
133
97
|
|
|
134
98
|
interface RadioGroupContextValue {
|
|
135
99
|
variant?: RadioGroupVariant;
|
|
100
|
+
error?: boolean;
|
|
136
101
|
}
|
|
137
102
|
|
|
138
103
|
/**
|
|
@@ -163,23 +128,9 @@ interface RadioGroupProps
|
|
|
163
128
|
/**
|
|
164
129
|
* Props for the RadioGroupItem component.
|
|
165
130
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
VariantProps<typeof radioGroupItemVariants> {
|
|
170
|
-
/**
|
|
171
|
-
* Label text displayed next to the radio button
|
|
172
|
-
*/
|
|
173
|
-
label?: React.ReactNode;
|
|
174
|
-
/**
|
|
175
|
-
* Description text displayed below the label
|
|
176
|
-
*/
|
|
177
|
-
description?: React.ReactNode;
|
|
178
|
-
/**
|
|
179
|
-
* Icon displayed for box icon variants
|
|
180
|
-
*/
|
|
181
|
-
icon?: React.ReactNode;
|
|
182
|
-
}
|
|
131
|
+
type RadioGroupItemProps = React.ComponentPropsWithoutRef<
|
|
132
|
+
typeof RadioGroupPrimitive.Item
|
|
133
|
+
>;
|
|
183
134
|
|
|
184
135
|
/* --------------------------------- Context -------------------------------- */
|
|
185
136
|
|
|
@@ -201,6 +152,7 @@ const RadioGroup = React.forwardRef<
|
|
|
201
152
|
trackingEl,
|
|
202
153
|
trackingLabel,
|
|
203
154
|
error,
|
|
155
|
+
orientation,
|
|
204
156
|
...props
|
|
205
157
|
},
|
|
206
158
|
ref
|
|
@@ -212,8 +164,14 @@ const RadioGroup = React.forwardRef<
|
|
|
212
164
|
props["aria-invalid"] === true ||
|
|
213
165
|
props["aria-invalid"] === "true";
|
|
214
166
|
|
|
167
|
+
// Auto-set horizontal orientation for boxIconVertical (items laid out in columns)
|
|
168
|
+
const effectiveOrientation =
|
|
169
|
+
variant === "boxIconVertical" ? "horizontal" : orientation;
|
|
170
|
+
|
|
215
171
|
return (
|
|
216
|
-
<RadioGroupContext.Provider
|
|
172
|
+
<RadioGroupContext.Provider
|
|
173
|
+
value={{ variant: contextVariant, error: hasError }}
|
|
174
|
+
>
|
|
217
175
|
<RadioGroupPrimitive.Root
|
|
218
176
|
ref={ref}
|
|
219
177
|
aria-invalid={hasError ? "true" : undefined}
|
|
@@ -222,6 +180,8 @@ const RadioGroup = React.forwardRef<
|
|
|
222
180
|
data-slot="radio-group"
|
|
223
181
|
data-tracking-el={trackingEl}
|
|
224
182
|
data-tracking-label={trackingLabel}
|
|
183
|
+
data-variant={variant}
|
|
184
|
+
orientation={effectiveOrientation}
|
|
225
185
|
{...props}
|
|
226
186
|
/>
|
|
227
187
|
</RadioGroupContext.Provider>
|
|
@@ -235,74 +195,50 @@ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
|
235
195
|
const RadioGroupItem = React.forwardRef<
|
|
236
196
|
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
237
197
|
RadioGroupItemProps
|
|
238
|
-
>(
|
|
239
|
-
(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
? "fill-primary text-primary"
|
|
283
|
-
: "fill-background text-background"
|
|
284
|
-
)}
|
|
285
|
-
/>
|
|
286
|
-
</RadioGroupPrimitive.Indicator>
|
|
287
|
-
</div>
|
|
288
|
-
)}
|
|
289
|
-
|
|
290
|
-
{/* Label and description */}
|
|
291
|
-
{(label || description || children) && (
|
|
292
|
-
<div className={radioContentVariants({ variant })}>
|
|
293
|
-
{label && (
|
|
294
|
-
<Label className="my-[1px] cursor-pointer">{label}</Label>
|
|
295
|
-
)}
|
|
296
|
-
{description && (
|
|
297
|
-
<p className="text-muted-foreground text-sm">{description}</p>
|
|
298
|
-
)}
|
|
299
|
-
{children}
|
|
300
|
-
</div>
|
|
301
|
-
)}
|
|
302
|
-
</RadioGroupPrimitive.Item>
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
);
|
|
198
|
+
>(({ className, children, ...props }, ref) => {
|
|
199
|
+
const { variant: ctxVariant, error } = React.useContext(RadioGroupContext);
|
|
200
|
+
const variant = ctxVariant ?? "default";
|
|
201
|
+
|
|
202
|
+
const isBoxIcon =
|
|
203
|
+
variant === "boxIconVertical" || variant === "boxIconHorizontal";
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<RadioGroupPrimitive.Item
|
|
207
|
+
ref={ref}
|
|
208
|
+
className={cn(radioGroupItemVariants({ variant }), className)}
|
|
209
|
+
data-slot="radio-group-item"
|
|
210
|
+
{...props}
|
|
211
|
+
>
|
|
212
|
+
{/* Radio button circle for default and box variants */}
|
|
213
|
+
{!isBoxIcon && (
|
|
214
|
+
<div
|
|
215
|
+
className={cn(
|
|
216
|
+
radioCircleVariants({ variant }),
|
|
217
|
+
error && [
|
|
218
|
+
"border-red-600/40 dark:border-red-400/60",
|
|
219
|
+
"group-focus-visible:border-destructive group-focus-visible:shadow-destructive",
|
|
220
|
+
]
|
|
221
|
+
)}
|
|
222
|
+
>
|
|
223
|
+
<RadioGroupPrimitive.Indicator
|
|
224
|
+
className="absolute inset-0 flex items-center justify-center"
|
|
225
|
+
data-slot="radio-group-indicator"
|
|
226
|
+
>
|
|
227
|
+
<Circle
|
|
228
|
+
className={cn(
|
|
229
|
+
variant === "default"
|
|
230
|
+
? "fill-primary text-primary"
|
|
231
|
+
: "fill-background text-background"
|
|
232
|
+
)}
|
|
233
|
+
size={8}
|
|
234
|
+
/>
|
|
235
|
+
</RadioGroupPrimitive.Indicator>
|
|
236
|
+
</div>
|
|
237
|
+
)}
|
|
238
|
+
{children}
|
|
239
|
+
</RadioGroupPrimitive.Item>
|
|
240
|
+
);
|
|
241
|
+
});
|
|
306
242
|
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
307
243
|
|
|
308
244
|
/* --------------------------------- Exports -------------------------------- */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
5
|
-
import {
|
|
5
|
+
import { Check, ChevronDown, ChevronUp } from "@brightlocal/icons";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -84,7 +84,7 @@ const selectTriggerVariants = cva([
|
|
|
84
84
|
"px-3 py-2",
|
|
85
85
|
|
|
86
86
|
// Base appearance
|
|
87
|
-
"border border-border rounded-sm outline-none transition-
|
|
87
|
+
"border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color]",
|
|
88
88
|
"bg-neutral-50 border-neutral-300",
|
|
89
89
|
"dark:bg-white/5 dark:border-white/15",
|
|
90
90
|
|
|
@@ -109,8 +109,6 @@ const selectTriggerVariants = cva([
|
|
|
109
109
|
|
|
110
110
|
// Icon styles (chevron and custom icons)
|
|
111
111
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
112
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
113
|
-
"[&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
114
112
|
]);
|
|
115
113
|
|
|
116
114
|
interface SelectTriggerProps extends React.ComponentProps<
|
|
@@ -168,7 +166,7 @@ function SelectTrigger({
|
|
|
168
166
|
|
|
169
167
|
{/* Dropdown chevron (right side) */}
|
|
170
168
|
<SelectPrimitive.Icon asChild>
|
|
171
|
-
<
|
|
169
|
+
<ChevronDown className="text-muted-foreground" />
|
|
172
170
|
</SelectPrimitive.Icon>
|
|
173
171
|
</SelectPrimitive.Trigger>
|
|
174
172
|
);
|
|
@@ -270,7 +268,7 @@ SelectLabel.displayName = "SelectLabel";
|
|
|
270
268
|
* 2. With icon (appears in trigger):
|
|
271
269
|
* <SelectItem value="apple">
|
|
272
270
|
* <div className="flex items-center gap-2">
|
|
273
|
-
* <AppleIcon
|
|
271
|
+
* <AppleIcon />
|
|
274
272
|
* Apple
|
|
275
273
|
* </div>
|
|
276
274
|
* </SelectItem>
|
|
@@ -297,9 +295,7 @@ function SelectItem({
|
|
|
297
295
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
298
296
|
|
|
299
297
|
// Icon styles
|
|
300
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
301
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
302
|
-
"[&_svg:not([class*='text-'])]:text-foreground"
|
|
298
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
303
299
|
);
|
|
304
300
|
|
|
305
301
|
return (
|
|
@@ -310,7 +306,7 @@ function SelectItem({
|
|
|
310
306
|
>
|
|
311
307
|
<span className="absolute right-2 flex size-4 items-center justify-center">
|
|
312
308
|
<SelectPrimitive.ItemIndicator>
|
|
313
|
-
<
|
|
309
|
+
<Check />
|
|
314
310
|
</SelectPrimitive.ItemIndicator>
|
|
315
311
|
</span>
|
|
316
312
|
|
|
@@ -355,7 +351,7 @@ function SelectScrollUpButton({
|
|
|
355
351
|
data-slot="select-scroll-up-button"
|
|
356
352
|
{...props}
|
|
357
353
|
>
|
|
358
|
-
<
|
|
354
|
+
<ChevronUp />
|
|
359
355
|
</SelectPrimitive.ScrollUpButton>
|
|
360
356
|
);
|
|
361
357
|
}
|
|
@@ -378,7 +374,7 @@ function SelectScrollDownButton({
|
|
|
378
374
|
data-slot="select-scroll-down-button"
|
|
379
375
|
{...props}
|
|
380
376
|
>
|
|
381
|
-
<
|
|
377
|
+
<ChevronDown />
|
|
382
378
|
</SelectPrimitive.ScrollDownButton>
|
|
383
379
|
);
|
|
384
380
|
}
|
package/src/components/sheet.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
-
import {
|
|
6
|
+
import { X } from "@brightlocal/icons";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
9
|
|
|
@@ -166,8 +166,8 @@ SheetOverlay.displayName = "SheetOverlay";
|
|
|
166
166
|
*/
|
|
167
167
|
interface SheetContentProps
|
|
168
168
|
extends
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
React.ComponentProps<typeof SheetPrimitive.Content>,
|
|
170
|
+
VariantProps<typeof sheetContentVariants> {
|
|
171
171
|
/**
|
|
172
172
|
* Side from which the sheet slides in
|
|
173
173
|
* @default "right"
|
|
@@ -219,8 +219,8 @@ const SheetContent = React.forwardRef<
|
|
|
219
219
|
{...props}
|
|
220
220
|
>
|
|
221
221
|
{children}
|
|
222
|
-
<SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0
|
|
223
|
-
<
|
|
222
|
+
<SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0">
|
|
223
|
+
<X />
|
|
224
224
|
<span className="sr-only">Close</span>
|
|
225
225
|
</SheetPrimitive.Close>
|
|
226
226
|
</SheetPrimitive.Content>
|
|
@@ -144,22 +144,21 @@ const ICON_VARIANTS = cva("", {
|
|
|
144
144
|
function renderToastIcon(type: ToastIconType, schema: "default" | "success") {
|
|
145
145
|
switch (type) {
|
|
146
146
|
case "info":
|
|
147
|
-
return <Info className={cn(ICON_VARIANTS({ colorSchema: schema }))}
|
|
147
|
+
return <Info className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
148
148
|
case "success":
|
|
149
149
|
return (
|
|
150
|
-
<CheckCircle2 className={cn(ICON_VARIANTS({ colorSchema: schema }))}
|
|
150
|
+
<CheckCircle2 className={cn(ICON_VARIANTS({ colorSchema: schema }))} />
|
|
151
151
|
);
|
|
152
152
|
case "warning":
|
|
153
153
|
return (
|
|
154
|
-
<AlertTriangle className={cn(ICON_VARIANTS({ colorSchema: schema }))}
|
|
154
|
+
<AlertTriangle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />
|
|
155
155
|
);
|
|
156
156
|
case "error":
|
|
157
|
-
return <XCircle className={cn(ICON_VARIANTS({ colorSchema: schema }))}
|
|
157
|
+
return <XCircle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
158
158
|
case "loading":
|
|
159
159
|
return (
|
|
160
160
|
<Loader2
|
|
161
161
|
className={cn(ICON_VARIANTS({ colorSchema: schema }), "animate-spin")}
|
|
162
|
-
size={20}
|
|
163
162
|
/>
|
|
164
163
|
);
|
|
165
164
|
default:
|
|
@@ -2,161 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
5
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
5
|
|
|
7
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
7
|
|
|
9
|
-
/**
|
|
10
|
-
* Visual style variants for Switch component
|
|
11
|
-
*/
|
|
12
|
-
export type SwitchVariant = "default" | "box";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Label position for switch (used in Default variant)
|
|
16
|
-
*/
|
|
17
|
-
export type SwitchSide = "left" | "right";
|
|
18
|
-
|
|
19
|
-
const switchVariants = cva(
|
|
20
|
-
[
|
|
21
|
-
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80",
|
|
22
|
-
"inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-all outline-none focus-visible:shadow-default",
|
|
23
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
24
|
-
"pl-[1px]",
|
|
25
|
-
],
|
|
26
|
-
{
|
|
27
|
-
variants: {
|
|
28
|
-
variant: {
|
|
29
|
-
default: [],
|
|
30
|
-
box: [],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
defaultVariants: {
|
|
34
|
-
variant: "default",
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
|
|
39
8
|
interface SwitchProps
|
|
40
|
-
extends
|
|
41
|
-
Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, "asChild">,
|
|
42
|
-
VariantProps<typeof switchVariants> {
|
|
9
|
+
extends Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, "asChild"> {
|
|
43
10
|
/** Data hook for automated testing (REQUIRED) */
|
|
44
11
|
dataHook: string;
|
|
45
12
|
/** Tracking element identifier for analytics */
|
|
46
13
|
trackingEl?: string;
|
|
47
14
|
/** Tracking label for analytics context */
|
|
48
15
|
trackingLabel?: string;
|
|
49
|
-
/** Visual style variant */
|
|
50
|
-
variant?: SwitchVariant;
|
|
51
|
-
/** Label text for the switch */
|
|
52
|
-
label?: string;
|
|
53
|
-
/** Description text (visible in Box variant) */
|
|
54
|
-
description?: string;
|
|
55
|
-
/** Label position - left or right (for Default variant) */
|
|
56
|
-
side?: SwitchSide;
|
|
57
16
|
}
|
|
58
17
|
|
|
59
18
|
const Switch = React.forwardRef<
|
|
60
19
|
React.ElementRef<typeof SwitchPrimitive.Root>,
|
|
61
20
|
SwitchProps
|
|
62
|
-
>(
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
className={cn(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"pointer-events-none block size-4 rounded-full ring-0 transition-transform",
|
|
91
|
-
"data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
92
|
-
)}
|
|
93
|
-
data-slot="switch-thumb"
|
|
94
|
-
/>
|
|
95
|
-
</SwitchPrimitive.Root>
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
// Default variant: inline switch with side label
|
|
99
|
-
if (variant === "default") {
|
|
100
|
-
return (
|
|
101
|
-
<div
|
|
102
|
-
className={cn(
|
|
103
|
-
"flex items-center gap-2",
|
|
104
|
-
side === "left" && "flex-row-reverse"
|
|
105
|
-
)}
|
|
106
|
-
>
|
|
107
|
-
{switchElement}
|
|
108
|
-
{label && (
|
|
109
|
-
<label
|
|
110
|
-
className="cursor-pointer text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
111
|
-
htmlFor={props.id}
|
|
112
|
-
>
|
|
113
|
-
{label}
|
|
114
|
-
</label>
|
|
115
|
-
)}
|
|
116
|
-
</div>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Box variant: switch in bordered container with label and description
|
|
121
|
-
if (variant === "box") {
|
|
122
|
-
const textContent = (
|
|
123
|
-
<div className="flex flex-col gap-2">
|
|
124
|
-
{label && (
|
|
125
|
-
<label
|
|
126
|
-
className="cursor-pointer text-sm leading-none font-medium"
|
|
127
|
-
htmlFor={props.id}
|
|
128
|
-
>
|
|
129
|
-
{label}
|
|
130
|
-
</label>
|
|
131
|
-
)}
|
|
132
|
-
{description && (
|
|
133
|
-
<p className="text-muted-foreground text-sm leading-normal">
|
|
134
|
-
{description}
|
|
135
|
-
</p>
|
|
136
|
-
)}
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<div className="border-border flex items-center justify-between gap-4 rounded-lg border p-4">
|
|
142
|
-
{side === "left" ? (
|
|
143
|
-
<>
|
|
144
|
-
{switchElement}
|
|
145
|
-
{textContent}
|
|
146
|
-
</>
|
|
147
|
-
) : (
|
|
148
|
-
<>
|
|
149
|
-
{textContent}
|
|
150
|
-
{switchElement}
|
|
151
|
-
</>
|
|
152
|
-
)}
|
|
153
|
-
</div>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return switchElement;
|
|
158
|
-
}
|
|
159
|
-
);
|
|
21
|
+
>(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
22
|
+
return (
|
|
23
|
+
<SwitchPrimitive.Root
|
|
24
|
+
ref={ref}
|
|
25
|
+
className={cn(
|
|
26
|
+
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80",
|
|
27
|
+
"inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:shadow-default",
|
|
28
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
29
|
+
"pl-[1px]",
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
data-hook={dataHook}
|
|
33
|
+
data-slot="switch"
|
|
34
|
+
data-tracking-el={trackingEl || "switch"}
|
|
35
|
+
data-tracking-label={trackingLabel}
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
38
|
+
<SwitchPrimitive.Thumb
|
|
39
|
+
className={cn(
|
|
40
|
+
"bg-background",
|
|
41
|
+
"pointer-events-none block size-4 rounded-full ring-0 transition-transform",
|
|
42
|
+
"data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
43
|
+
)}
|
|
44
|
+
data-slot="switch-thumb"
|
|
45
|
+
/>
|
|
46
|
+
</SwitchPrimitive.Root>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
160
49
|
|
|
161
50
|
Switch.displayName = "Switch";
|
|
162
51
|
|
package/src/components/tabs.tsx
CHANGED
|
@@ -116,8 +116,6 @@ const TabsTrigger = React.forwardRef<
|
|
|
116
116
|
"dark:data-[state=active]:border-white/15 dark:data-[state=active]:bg-white/5",
|
|
117
117
|
// Disabled state
|
|
118
118
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
119
|
-
// Icon styling
|
|
120
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
121
119
|
className
|
|
122
120
|
)}
|
|
123
121
|
data-hook={dataHook}
|
|
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg
|
|
10
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-150 ease-in-out whitespace-nowrap",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|