@brightlocal/ui-components 0.1.3 → 0.2.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 +1 -1
- package/dist/alert.cjs +1 -1
- package/dist/alert.js +1 -1
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +37 -306
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +392 -489
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +4 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +33 -33
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +5 -18
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +21 -23
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +75 -67
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +241 -194
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +3 -0
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +361 -366
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +5 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +47 -39
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +6 -0
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +79 -76
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +4 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +32 -31
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +26 -24
- package/dist/link.cjs +1 -1
- package/dist/link.js +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -4
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +17 -20
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +3 -0
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +31 -30
- 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/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +10 -23
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +47 -55
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +19 -28
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +24 -40
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +3 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +57 -56
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +4 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +19 -21
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +5 -10
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +24 -26
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +17 -20
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +42 -45
- 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/textarea.cjs +1 -1
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +19 -18
- 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 +18 -22
- package/package.json +2 -2
- package/src/blocks/data-table.tsx +1 -1
- package/src/blocks/sidebar.tsx +157 -532
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/calendar.tsx +6 -4
- package/src/components/centred-layout.tsx +11 -24
- package/src/components/checkbox.tsx +5 -6
- package/src/components/combobox.tsx +481 -301
- package/src/components/command.tsx +1 -1
- package/src/components/context-menu.tsx +1 -1
- package/src/components/date-picker.tsx +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/field.tsx +2 -0
- package/src/components/input-group.tsx +14 -2
- package/src/components/input-otp.tsx +17 -2
- package/src/components/input-password.tsx +7 -2
- package/src/components/input.tsx +11 -3
- package/src/components/link.tsx +1 -1
- package/src/components/logo.tsx +10 -8
- package/src/components/menubar.tsx +3 -1
- package/src/components/navigation-menu.tsx +37 -99
- package/src/components/pagination.tsx +13 -19
- package/src/components/radio-group.tsx +28 -38
- package/src/components/resizable.tsx +5 -43
- package/src/components/select.tsx +8 -3
- package/src/components/separator.tsx +5 -5
- package/src/components/sheet.tsx +6 -11
- package/src/components/sonner.tsx +24 -27
- 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/textarea.tsx +12 -5
- package/src/components/toggle-group.tsx +115 -86
- package/src/components/toggle.figma.tsx +13 -19
- package/src/components/toggle.tsx +32 -48
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
5
|
-
import { Circle } from "
|
|
5
|
+
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";
|
|
@@ -120,17 +120,16 @@ const radioContentVariants = cva(
|
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Visual style variants for the radio group component.
|
|
123
|
+
* - `default`: Standard radio group with minimal styling
|
|
124
|
+
* - `box`: Radio items wrapped in styled card containers
|
|
125
|
+
* - `boxIconVertical`: Radio items with icons displayed vertically above the label
|
|
126
|
+
* - `boxIconHorizontal`: Radio items with icons displayed horizontally to the left
|
|
123
127
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/** Radio items with icons displayed vertically above the label */
|
|
130
|
-
BOX_ICON_VERTICAL = "boxIconVertical",
|
|
131
|
-
/** Radio items with icons displayed horizontally to the left */
|
|
132
|
-
BOX_ICON_HORIZONTAL = "boxIconHorizontal",
|
|
133
|
-
}
|
|
128
|
+
type RadioGroupVariant =
|
|
129
|
+
| "default"
|
|
130
|
+
| "box"
|
|
131
|
+
| "boxIconVertical"
|
|
132
|
+
| "boxIconHorizontal";
|
|
134
133
|
|
|
135
134
|
interface RadioGroupContextValue {
|
|
136
135
|
variant?: RadioGroupVariant;
|
|
@@ -155,6 +154,10 @@ interface RadioGroupProps
|
|
|
155
154
|
* Tracking label for analytics context
|
|
156
155
|
*/
|
|
157
156
|
trackingLabel?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Whether the radio group has an error state
|
|
159
|
+
*/
|
|
160
|
+
error?: boolean;
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
/**
|
|
@@ -176,24 +179,12 @@ interface RadioGroupItemProps
|
|
|
176
179
|
* Icon displayed for box icon variants
|
|
177
180
|
*/
|
|
178
181
|
icon?: React.ReactNode;
|
|
179
|
-
/**
|
|
180
|
-
* Data hook for automated testing (required)
|
|
181
|
-
*/
|
|
182
|
-
dataHook: string;
|
|
183
|
-
/**
|
|
184
|
-
* Tracking element identifier for analytics
|
|
185
|
-
*/
|
|
186
|
-
trackingEl?: string;
|
|
187
|
-
/**
|
|
188
|
-
* Tracking label for analytics context
|
|
189
|
-
*/
|
|
190
|
-
trackingLabel?: string;
|
|
191
182
|
}
|
|
192
183
|
|
|
193
184
|
/* --------------------------------- Context -------------------------------- */
|
|
194
185
|
|
|
195
186
|
const RadioGroupContext = React.createContext<RadioGroupContextValue>({
|
|
196
|
-
variant:
|
|
187
|
+
variant: "default",
|
|
197
188
|
});
|
|
198
189
|
|
|
199
190
|
/* ------------------------------- RadioGroup ------------------------------- */
|
|
@@ -205,21 +196,27 @@ const RadioGroup = React.forwardRef<
|
|
|
205
196
|
(
|
|
206
197
|
{
|
|
207
198
|
className,
|
|
208
|
-
variant =
|
|
199
|
+
variant = "default",
|
|
209
200
|
dataHook,
|
|
210
201
|
trackingEl,
|
|
211
202
|
trackingLabel,
|
|
203
|
+
error,
|
|
212
204
|
...props
|
|
213
205
|
},
|
|
214
206
|
ref
|
|
215
207
|
) => {
|
|
216
|
-
const contextVariant =
|
|
217
|
-
|
|
208
|
+
const contextVariant = variant || "default";
|
|
209
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
210
|
+
const hasError =
|
|
211
|
+
error ||
|
|
212
|
+
props["aria-invalid"] === true ||
|
|
213
|
+
props["aria-invalid"] === "true";
|
|
218
214
|
|
|
219
215
|
return (
|
|
220
216
|
<RadioGroupContext.Provider value={{ variant: contextVariant }}>
|
|
221
217
|
<RadioGroupPrimitive.Root
|
|
222
218
|
ref={ref}
|
|
219
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
223
220
|
className={cn(radioGroupVariants({ variant }), className)}
|
|
224
221
|
data-hook={dataHook}
|
|
225
222
|
data-slot="radio-group"
|
|
@@ -247,28 +244,21 @@ const RadioGroupItem = React.forwardRef<
|
|
|
247
244
|
description,
|
|
248
245
|
icon,
|
|
249
246
|
children,
|
|
250
|
-
dataHook,
|
|
251
|
-
trackingEl,
|
|
252
|
-
trackingLabel,
|
|
253
247
|
...props
|
|
254
248
|
},
|
|
255
249
|
ref
|
|
256
250
|
) => {
|
|
257
251
|
const context = React.useContext(RadioGroupContext);
|
|
258
|
-
const variant = variantProp ?? context.variant ??
|
|
252
|
+
const variant = variantProp ?? context.variant ?? "default";
|
|
259
253
|
|
|
260
254
|
const isBoxIcon =
|
|
261
|
-
variant ===
|
|
262
|
-
variant === RadioGroupVariant.BOX_ICON_HORIZONTAL;
|
|
255
|
+
variant === "boxIconVertical" || variant === "boxIconHorizontal";
|
|
263
256
|
|
|
264
257
|
return (
|
|
265
258
|
<RadioGroupPrimitive.Item
|
|
266
259
|
ref={ref}
|
|
267
260
|
className={cn(radioGroupItemVariants({ variant }), className)}
|
|
268
|
-
data-hook={dataHook}
|
|
269
261
|
data-slot="radio-group-item"
|
|
270
|
-
data-tracking-el={trackingEl}
|
|
271
|
-
data-tracking-label={trackingLabel}
|
|
272
262
|
{...props}
|
|
273
263
|
>
|
|
274
264
|
{/* Icon for box icon variants */}
|
|
@@ -288,7 +278,7 @@ const RadioGroupItem = React.forwardRef<
|
|
|
288
278
|
<Circle
|
|
289
279
|
className={cn(
|
|
290
280
|
"size-2",
|
|
291
|
-
variant ===
|
|
281
|
+
variant === "default"
|
|
292
282
|
? "fill-primary text-primary"
|
|
293
283
|
: "fill-background text-background"
|
|
294
284
|
)}
|
|
@@ -317,5 +307,5 @@ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
|
317
307
|
|
|
318
308
|
/* --------------------------------- Exports -------------------------------- */
|
|
319
309
|
|
|
320
|
-
export { RadioGroup, RadioGroupItem, RadioGroupVariant };
|
|
310
|
+
export { RadioGroup, RadioGroupItem, type RadioGroupVariant };
|
|
321
311
|
export type { RadioGroupProps, RadioGroupItemProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { GripVertical } from "
|
|
3
|
+
import { GripVertical } from "@brightlocal/icons";
|
|
4
4
|
import * as ResizablePrimitive from "react-resizable-panels";
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -51,22 +51,9 @@ ResizablePanelGroup.displayName = "ResizablePanelGroup";
|
|
|
51
51
|
/**
|
|
52
52
|
* Props for the ResizablePanel component.
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
type ResizablePanelProps = React.ComponentProps<
|
|
55
55
|
typeof ResizablePrimitive.Panel
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Data hook for automated testing
|
|
59
|
-
*/
|
|
60
|
-
dataHook?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Tracking element identifier for analytics
|
|
63
|
-
*/
|
|
64
|
-
trackingEl?: string;
|
|
65
|
-
/**
|
|
66
|
-
* Tracking label for analytics context
|
|
67
|
-
*/
|
|
68
|
-
trackingLabel?: string;
|
|
69
|
-
}
|
|
56
|
+
>;
|
|
70
57
|
|
|
71
58
|
/**
|
|
72
59
|
* Individual resizable panel within a panel group.
|
|
@@ -74,15 +61,8 @@ interface ResizablePanelProps extends React.ComponentProps<
|
|
|
74
61
|
const ResizablePanel = React.forwardRef<
|
|
75
62
|
React.ComponentRef<typeof ResizablePrimitive.Panel>,
|
|
76
63
|
ResizablePanelProps
|
|
77
|
-
>(({
|
|
78
|
-
<ResizablePrimitive.Panel
|
|
79
|
-
ref={ref}
|
|
80
|
-
data-hook={dataHook}
|
|
81
|
-
data-slot="resizable-panel"
|
|
82
|
-
data-tracking-el={trackingEl}
|
|
83
|
-
data-tracking-label={trackingLabel}
|
|
84
|
-
{...props}
|
|
85
|
-
/>
|
|
64
|
+
>(({ ...props }, ref) => (
|
|
65
|
+
<ResizablePrimitive.Panel ref={ref} data-slot="resizable-panel" {...props} />
|
|
86
66
|
));
|
|
87
67
|
|
|
88
68
|
ResizablePanel.displayName = "ResizablePanel";
|
|
@@ -97,18 +77,6 @@ interface ResizableHandleProps extends React.ComponentProps<
|
|
|
97
77
|
* Show a visible drag handle indicator
|
|
98
78
|
*/
|
|
99
79
|
withHandle?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Data hook for automated testing
|
|
102
|
-
*/
|
|
103
|
-
dataHook?: string;
|
|
104
|
-
/**
|
|
105
|
-
* Tracking element identifier for analytics
|
|
106
|
-
*/
|
|
107
|
-
trackingEl?: string;
|
|
108
|
-
/**
|
|
109
|
-
* Tracking label for analytics context
|
|
110
|
-
*/
|
|
111
|
-
trackingLabel?: string;
|
|
112
80
|
}
|
|
113
81
|
|
|
114
82
|
/**
|
|
@@ -117,9 +85,6 @@ interface ResizableHandleProps extends React.ComponentProps<
|
|
|
117
85
|
function ResizableHandle({
|
|
118
86
|
withHandle,
|
|
119
87
|
className,
|
|
120
|
-
dataHook,
|
|
121
|
-
trackingEl,
|
|
122
|
-
trackingLabel,
|
|
123
88
|
...props
|
|
124
89
|
}: ResizableHandleProps) {
|
|
125
90
|
return (
|
|
@@ -128,10 +93,7 @@ function ResizableHandle({
|
|
|
128
93
|
"bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
|
|
129
94
|
className
|
|
130
95
|
)}
|
|
131
|
-
data-hook={dataHook}
|
|
132
96
|
data-slot="resizable-handle"
|
|
133
|
-
data-tracking-el={trackingEl}
|
|
134
|
-
data-tracking-label={trackingLabel}
|
|
135
97
|
{...props}
|
|
136
98
|
>
|
|
137
99
|
{withHandle && (
|
|
@@ -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 { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "
|
|
5
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "@brightlocal/icons";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -184,6 +184,8 @@ interface SelectTriggerProps extends React.ComponentProps<
|
|
|
184
184
|
placeholder?: string;
|
|
185
185
|
/** Data hook for testing and automation */
|
|
186
186
|
dataHook?: string;
|
|
187
|
+
/** Whether the select trigger has an error state */
|
|
188
|
+
error?: boolean;
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
// ============================================================================
|
|
@@ -198,11 +200,14 @@ function SelectTrigger({
|
|
|
198
200
|
children,
|
|
199
201
|
placeholder,
|
|
200
202
|
dataHook,
|
|
203
|
+
error,
|
|
201
204
|
...props
|
|
202
205
|
}: SelectTriggerProps) {
|
|
203
|
-
//
|
|
206
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
204
207
|
const isError =
|
|
205
|
-
|
|
208
|
+
error ||
|
|
209
|
+
props["aria-invalid"] === true ||
|
|
210
|
+
props["aria-invalid"] === "true";
|
|
206
211
|
const isRequired =
|
|
207
212
|
props["aria-required"] === true || props["aria-required"] === "true";
|
|
208
213
|
|
|
@@ -5,10 +5,10 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Orientation variants for Separator
|
|
10
|
+
*/
|
|
11
|
+
export type SeparatorOrientation = "horizontal" | "vertical";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Props for the Separator component.
|
|
@@ -41,7 +41,7 @@ const Separator = React.forwardRef<
|
|
|
41
41
|
(
|
|
42
42
|
{
|
|
43
43
|
className,
|
|
44
|
-
orientation =
|
|
44
|
+
orientation = "horizontal",
|
|
45
45
|
decorative = true,
|
|
46
46
|
dataHook,
|
|
47
47
|
trackingEl,
|
package/src/components/sheet.tsx
CHANGED
|
@@ -3,23 +3,18 @@
|
|
|
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 { XIcon } from "
|
|
6
|
+
import { XIcon } from "@brightlocal/icons";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Available sheet side variants
|
|
12
|
+
* - top: Sheet slides in from the top
|
|
13
|
+
* - right: Sheet slides in from the right (default)
|
|
14
|
+
* - bottom: Sheet slides in from the bottom
|
|
15
|
+
* - left: Sheet slides in from the left
|
|
12
16
|
*/
|
|
13
|
-
export
|
|
14
|
-
/** Sheet slides in from the top */
|
|
15
|
-
TOP = "top",
|
|
16
|
-
/** Sheet slides in from the right (default) */
|
|
17
|
-
RIGHT = "right",
|
|
18
|
-
/** Sheet slides in from the bottom */
|
|
19
|
-
BOTTOM = "bottom",
|
|
20
|
-
/** Sheet slides in from the left */
|
|
21
|
-
LEFT = "left",
|
|
22
|
-
}
|
|
17
|
+
export type SheetSide = "top" | "right" | "bottom" | "left";
|
|
23
18
|
|
|
24
19
|
const sheetContentVariants = cva(
|
|
25
20
|
[
|
|
@@ -6,7 +6,7 @@ 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
|
|
|
@@ -46,20 +46,17 @@ type ToastProps = {
|
|
|
46
46
|
icon?: ToastIconType | null;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ERROR = "error",
|
|
54
|
-
LOADING = "loading",
|
|
55
|
-
}
|
|
49
|
+
/**
|
|
50
|
+
* Icon type variants for toast notifications
|
|
51
|
+
*/
|
|
52
|
+
export type SonnerIcon = "info" | "success" | "warning" | "error" | "loading";
|
|
56
53
|
|
|
57
54
|
export type ToastIconType = SonnerIcon | null;
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Color schema variants for toast notifications
|
|
58
|
+
*/
|
|
59
|
+
export type SonnerColorSchema = "default" | "success";
|
|
63
60
|
|
|
64
61
|
type SonnerCustomOptions = {
|
|
65
62
|
className?: string;
|
|
@@ -146,19 +143,19 @@ const ICON_VARIANTS = cva("size-5", {
|
|
|
146
143
|
*/
|
|
147
144
|
function renderToastIcon(type: ToastIconType, schema: "default" | "success") {
|
|
148
145
|
switch (type) {
|
|
149
|
-
case
|
|
146
|
+
case "info":
|
|
150
147
|
return <Info className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
151
|
-
case
|
|
148
|
+
case "success":
|
|
152
149
|
return (
|
|
153
150
|
<CheckCircle2 className={cn(ICON_VARIANTS({ colorSchema: schema }))} />
|
|
154
151
|
);
|
|
155
|
-
case
|
|
152
|
+
case "warning":
|
|
156
153
|
return (
|
|
157
154
|
<AlertTriangle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />
|
|
158
155
|
);
|
|
159
|
-
case
|
|
156
|
+
case "error":
|
|
160
157
|
return <XCircle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
161
|
-
case
|
|
158
|
+
case "loading":
|
|
162
159
|
return (
|
|
163
160
|
<Loader2
|
|
164
161
|
className={cn(ICON_VARIANTS({ colorSchema: schema }), "animate-spin")}
|
|
@@ -217,7 +214,7 @@ function Toast(props: ToastProps) {
|
|
|
217
214
|
const { button, description, icon, title, colorSchema } = props;
|
|
218
215
|
|
|
219
216
|
const resolveSchema = (schema?: SonnerColorSchema): "default" | "success" =>
|
|
220
|
-
schema ===
|
|
217
|
+
schema === "success" ? "success" : "default";
|
|
221
218
|
|
|
222
219
|
const schema = resolveSchema(colorSchema);
|
|
223
220
|
|
|
@@ -310,13 +307,13 @@ function Toast(props: ToastProps) {
|
|
|
310
307
|
*
|
|
311
308
|
* @example
|
|
312
309
|
* // Then use sonner() anywhere in your app
|
|
313
|
-
* import { sonner
|
|
310
|
+
* import { sonner } from '@brightlocal/ui-components/sonner';
|
|
314
311
|
*
|
|
315
312
|
* function MyComponent() {
|
|
316
313
|
* const handleClick = () => {
|
|
317
314
|
* sonner({
|
|
318
315
|
* title: "Success!",
|
|
319
|
-
* icon:
|
|
316
|
+
* icon: "success"
|
|
320
317
|
* });
|
|
321
318
|
* };
|
|
322
319
|
*
|
|
@@ -348,7 +345,7 @@ Sonner.displayName = "Sonner";
|
|
|
348
345
|
* <Sonner />
|
|
349
346
|
*
|
|
350
347
|
* // 2. Show toasts anywhere in your app
|
|
351
|
-
* import { sonner
|
|
348
|
+
* import { sonner } from '@brightlocal/ui-components/sonner';
|
|
352
349
|
*
|
|
353
350
|
* // Simple toast
|
|
354
351
|
* sonner({ title: "Hello world" });
|
|
@@ -357,8 +354,8 @@ Sonner.displayName = "Sonner";
|
|
|
357
354
|
* sonner({
|
|
358
355
|
* title: "Changes saved",
|
|
359
356
|
* description: "Your changes have been saved successfully.",
|
|
360
|
-
* icon:
|
|
361
|
-
* colorSchema:
|
|
357
|
+
* icon: "success",
|
|
358
|
+
* colorSchema: "success",
|
|
362
359
|
* button: {
|
|
363
360
|
* label: "Undo",
|
|
364
361
|
* onClick: () => undoChanges()
|
|
@@ -373,7 +370,7 @@ Sonner.displayName = "Sonner";
|
|
|
373
370
|
* sonner({
|
|
374
371
|
* title: "Uploading...",
|
|
375
372
|
* description: "Please wait while we upload your file.",
|
|
376
|
-
* icon:
|
|
373
|
+
* icon: "loading",
|
|
377
374
|
* id: loadingToastId
|
|
378
375
|
* });
|
|
379
376
|
*
|
|
@@ -383,15 +380,15 @@ Sonner.displayName = "Sonner";
|
|
|
383
380
|
* toast.dismiss(loadingToastId);
|
|
384
381
|
* sonner({
|
|
385
382
|
* title: "Upload complete!",
|
|
386
|
-
* icon:
|
|
387
|
-
* colorSchema:
|
|
383
|
+
* icon: "success",
|
|
384
|
+
* colorSchema: "success"
|
|
388
385
|
* });
|
|
389
386
|
* } catch (error) {
|
|
390
387
|
* toast.dismiss(loadingToastId);
|
|
391
388
|
* sonner({
|
|
392
389
|
* title: "Upload failed",
|
|
393
390
|
* description: error.message,
|
|
394
|
-
* icon:
|
|
391
|
+
* icon: "error"
|
|
395
392
|
* });
|
|
396
393
|
* }
|
|
397
394
|
* ```
|
|
@@ -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>(
|