@brightlocal/ui-components 0.1.3 → 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.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.js +1 -1
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +9 -17
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +104 -107
- 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 +348 -363
- 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.js +1 -1
- 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 +18 -21
- 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 +6 -23
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +56 -66
- 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.js +1 -1
- 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/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 +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 +1 -1
- package/src/components/combobox.tsx +18 -26
- 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-otp.tsx +1 -1
- package/src/components/input-password.tsx +1 -1
- package/src/components/link.tsx +1 -1
- package/src/components/logo.tsx +9 -7
- 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 +17 -38
- package/src/components/resizable.tsx +5 -43
- package/src/components/select.tsx +1 -1
- 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/toggle-group.tsx +115 -86
- package/src/components/toggle.figma.tsx +13 -19
- package/src/components/toggle.tsx +20 -34
|
@@ -3,23 +3,18 @@ import {
|
|
|
3
3
|
ChevronLeftIcon,
|
|
4
4
|
ChevronRightIcon,
|
|
5
5
|
MoreHorizontalIcon,
|
|
6
|
-
} from "
|
|
6
|
+
} from "@brightlocal/icons";
|
|
7
7
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Pagination item variants
|
|
12
|
+
* - `previous`: Previous navigation button
|
|
13
|
+
* - `next`: Next navigation button
|
|
14
|
+
* - `link`: Page number link
|
|
15
|
+
* - `ellipsis`: Ellipsis indicator for skipped pages
|
|
12
16
|
*/
|
|
13
|
-
export
|
|
14
|
-
/** Previous navigation button */
|
|
15
|
-
PREVIOUS = "previous",
|
|
16
|
-
/** Next navigation button */
|
|
17
|
-
NEXT = "next",
|
|
18
|
-
/** Page number link */
|
|
19
|
-
LINK = "link",
|
|
20
|
-
/** Ellipsis indicator for skipped pages */
|
|
21
|
-
ELLIPSIS = "ellipsis",
|
|
22
|
-
}
|
|
17
|
+
export type PaginationVariant = "previous" | "next" | "link" | "ellipsis";
|
|
23
18
|
|
|
24
19
|
/**
|
|
25
20
|
* Pagination hook parameters
|
|
@@ -167,7 +162,7 @@ const paginationItemVariants = cva(
|
|
|
167
162
|
},
|
|
168
163
|
},
|
|
169
164
|
defaultVariants: {
|
|
170
|
-
variant:
|
|
165
|
+
variant: "link",
|
|
171
166
|
},
|
|
172
167
|
}
|
|
173
168
|
);
|
|
@@ -205,6 +200,8 @@ function Pagination({
|
|
|
205
200
|
);
|
|
206
201
|
}
|
|
207
202
|
|
|
203
|
+
Pagination.displayName = "Pagination";
|
|
204
|
+
|
|
208
205
|
function PaginationContent({
|
|
209
206
|
className,
|
|
210
207
|
...props
|
|
@@ -270,7 +267,7 @@ const PaginationPrevious = React.forwardRef<
|
|
|
270
267
|
aria-label="Go to previous page"
|
|
271
268
|
className={className}
|
|
272
269
|
disabled={disabled}
|
|
273
|
-
variant=
|
|
270
|
+
variant="previous"
|
|
274
271
|
{...props}
|
|
275
272
|
>
|
|
276
273
|
<ChevronLeftIcon className="size-4" />
|
|
@@ -294,7 +291,7 @@ const PaginationNext = React.forwardRef<HTMLButtonElement, PaginationNextProps>(
|
|
|
294
291
|
aria-label="Go to next page"
|
|
295
292
|
className={className}
|
|
296
293
|
disabled={disabled}
|
|
297
|
-
variant=
|
|
294
|
+
variant="next"
|
|
298
295
|
{...props}
|
|
299
296
|
>
|
|
300
297
|
<ChevronRightIcon className="size-4" />
|
|
@@ -318,7 +315,7 @@ const PaginationLink = React.forwardRef<HTMLButtonElement, PaginationLinkProps>(
|
|
|
318
315
|
aria-label={`Go to page ${page}`}
|
|
319
316
|
className={className}
|
|
320
317
|
isActive={isActive}
|
|
321
|
-
variant=
|
|
318
|
+
variant="link"
|
|
322
319
|
{...props}
|
|
323
320
|
>
|
|
324
321
|
{page}
|
|
@@ -336,10 +333,7 @@ function PaginationEllipsis({
|
|
|
336
333
|
return (
|
|
337
334
|
<span
|
|
338
335
|
aria-hidden="true"
|
|
339
|
-
className={cn(
|
|
340
|
-
paginationItemVariants({ variant: PaginationVariant.ELLIPSIS }),
|
|
341
|
-
className
|
|
342
|
-
)}
|
|
336
|
+
className={cn(paginationItemVariants({ variant: "ellipsis" }), className)}
|
|
343
337
|
data-slot="pagination-ellipsis"
|
|
344
338
|
{...props}
|
|
345
339
|
>
|
|
@@ -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;
|
|
@@ -176,24 +175,12 @@ interface RadioGroupItemProps
|
|
|
176
175
|
* Icon displayed for box icon variants
|
|
177
176
|
*/
|
|
178
177
|
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
178
|
}
|
|
192
179
|
|
|
193
180
|
/* --------------------------------- Context -------------------------------- */
|
|
194
181
|
|
|
195
182
|
const RadioGroupContext = React.createContext<RadioGroupContextValue>({
|
|
196
|
-
variant:
|
|
183
|
+
variant: "default",
|
|
197
184
|
});
|
|
198
185
|
|
|
199
186
|
/* ------------------------------- RadioGroup ------------------------------- */
|
|
@@ -205,7 +192,7 @@ const RadioGroup = React.forwardRef<
|
|
|
205
192
|
(
|
|
206
193
|
{
|
|
207
194
|
className,
|
|
208
|
-
variant =
|
|
195
|
+
variant = "default",
|
|
209
196
|
dataHook,
|
|
210
197
|
trackingEl,
|
|
211
198
|
trackingLabel,
|
|
@@ -213,8 +200,7 @@ const RadioGroup = React.forwardRef<
|
|
|
213
200
|
},
|
|
214
201
|
ref
|
|
215
202
|
) => {
|
|
216
|
-
const contextVariant =
|
|
217
|
-
RadioGroupVariant.DEFAULT) as RadioGroupVariant;
|
|
203
|
+
const contextVariant = variant || "default";
|
|
218
204
|
|
|
219
205
|
return (
|
|
220
206
|
<RadioGroupContext.Provider value={{ variant: contextVariant }}>
|
|
@@ -247,28 +233,21 @@ const RadioGroupItem = React.forwardRef<
|
|
|
247
233
|
description,
|
|
248
234
|
icon,
|
|
249
235
|
children,
|
|
250
|
-
dataHook,
|
|
251
|
-
trackingEl,
|
|
252
|
-
trackingLabel,
|
|
253
236
|
...props
|
|
254
237
|
},
|
|
255
238
|
ref
|
|
256
239
|
) => {
|
|
257
240
|
const context = React.useContext(RadioGroupContext);
|
|
258
|
-
const variant = variantProp ?? context.variant ??
|
|
241
|
+
const variant = variantProp ?? context.variant ?? "default";
|
|
259
242
|
|
|
260
243
|
const isBoxIcon =
|
|
261
|
-
variant ===
|
|
262
|
-
variant === RadioGroupVariant.BOX_ICON_HORIZONTAL;
|
|
244
|
+
variant === "boxIconVertical" || variant === "boxIconHorizontal";
|
|
263
245
|
|
|
264
246
|
return (
|
|
265
247
|
<RadioGroupPrimitive.Item
|
|
266
248
|
ref={ref}
|
|
267
249
|
className={cn(radioGroupItemVariants({ variant }), className)}
|
|
268
|
-
data-hook={dataHook}
|
|
269
250
|
data-slot="radio-group-item"
|
|
270
|
-
data-tracking-el={trackingEl}
|
|
271
|
-
data-tracking-label={trackingLabel}
|
|
272
251
|
{...props}
|
|
273
252
|
>
|
|
274
253
|
{/* Icon for box icon variants */}
|
|
@@ -288,7 +267,7 @@ const RadioGroupItem = React.forwardRef<
|
|
|
288
267
|
<Circle
|
|
289
268
|
className={cn(
|
|
290
269
|
"size-2",
|
|
291
|
-
variant ===
|
|
270
|
+
variant === "default"
|
|
292
271
|
? "fill-primary text-primary"
|
|
293
272
|
: "fill-background text-background"
|
|
294
273
|
)}
|
|
@@ -317,5 +296,5 @@ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
|
317
296
|
|
|
318
297
|
/* --------------------------------- Exports -------------------------------- */
|
|
319
298
|
|
|
320
|
-
export { RadioGroup, RadioGroupItem, RadioGroupVariant };
|
|
299
|
+
export { RadioGroup, RadioGroupItem, type RadioGroupVariant };
|
|
321
300
|
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";
|
|
@@ -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}
|