@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
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
|
|
|
@@ -2,20 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
5
|
-
import { type VariantProps } from "class-variance-authority";
|
|
6
5
|
|
|
7
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
|
-
import {
|
|
9
|
-
toggleVariants,
|
|
10
|
-
ToggleSize,
|
|
11
|
-
ToggleVariant,
|
|
12
|
-
} from "@brightlocal/ui-components/toggle";
|
|
7
|
+
import { toggleVariants } from "./toggle";
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
variant
|
|
9
|
+
/**
|
|
10
|
+
* Context value for sharing variant and size props between ToggleGroup and ToggleGroupItem.
|
|
11
|
+
*/
|
|
12
|
+
type ToggleGroupContextValue = {
|
|
13
|
+
/** Visual style variant inherited by child items */
|
|
14
|
+
variant?: "default" | "outline";
|
|
15
|
+
/** Size variant inherited by child items */
|
|
16
|
+
size?: "default" | "sm" | "lg";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ToggleGroupContext = React.createContext<ToggleGroupContextValue>({
|
|
20
|
+
size: "default",
|
|
21
|
+
variant: "default",
|
|
19
22
|
});
|
|
20
23
|
|
|
21
24
|
type ToggleGroupProps = {
|
|
@@ -25,88 +28,114 @@ type ToggleGroupProps = {
|
|
|
25
28
|
trackingEl?: string;
|
|
26
29
|
/** Tracking label for analytics context */
|
|
27
30
|
trackingLabel?: string;
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Visual style variant
|
|
33
|
+
* @default "default"
|
|
34
|
+
*/
|
|
35
|
+
variant?: "default" | "outline";
|
|
36
|
+
/**
|
|
37
|
+
* Size variant
|
|
38
|
+
* @default "default"
|
|
39
|
+
*/
|
|
40
|
+
size?: "default" | "sm" | "lg";
|
|
41
|
+
} & React.ComponentProps<typeof ToggleGroupPrimitive.Root>;
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
43
|
+
const ToggleGroup = React.forwardRef<
|
|
44
|
+
React.ComponentRef<typeof ToggleGroupPrimitive.Root>,
|
|
45
|
+
ToggleGroupProps
|
|
46
|
+
>(
|
|
47
|
+
(
|
|
48
|
+
{
|
|
49
|
+
className,
|
|
50
|
+
variant,
|
|
51
|
+
size,
|
|
52
|
+
children,
|
|
53
|
+
dataHook,
|
|
54
|
+
trackingEl,
|
|
55
|
+
trackingLabel,
|
|
56
|
+
...props
|
|
57
|
+
},
|
|
58
|
+
ref
|
|
59
|
+
) => {
|
|
60
|
+
return (
|
|
61
|
+
<ToggleGroupPrimitive.Root
|
|
62
|
+
ref={ref}
|
|
63
|
+
className={cn(
|
|
64
|
+
"group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs",
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
data-hook={dataHook}
|
|
68
|
+
data-size={size}
|
|
69
|
+
data-slot="toggle-group"
|
|
70
|
+
data-tracking-el={trackingEl || `toggle-group-${variant}`}
|
|
71
|
+
data-tracking-label={trackingLabel}
|
|
72
|
+
data-variant={variant}
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
76
|
+
{children}
|
|
77
|
+
</ToggleGroupContext.Provider>
|
|
78
|
+
</ToggleGroupPrimitive.Root>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
ToggleGroup.displayName = "ToggleGroup";
|
|
61
84
|
|
|
62
85
|
type ToggleGroupItemProps = {
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
/** Tracking label for analytics context */
|
|
68
|
-
trackingLabel?: string;
|
|
86
|
+
/** Unique value for the toggle item (REQUIRED) */
|
|
87
|
+
value: string;
|
|
88
|
+
/** Data hook for automated testing */
|
|
89
|
+
dataHook?: string;
|
|
69
90
|
/** ARIA label for accessibility (required when no text content) */
|
|
70
91
|
ariaLabel?: string;
|
|
71
|
-
|
|
72
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Visual style variant (inherited from ToggleGroup if not specified)
|
|
94
|
+
* @default "default"
|
|
95
|
+
*/
|
|
96
|
+
variant?: "default" | "outline";
|
|
97
|
+
/**
|
|
98
|
+
* Size variant (inherited from ToggleGroup if not specified)
|
|
99
|
+
* @default "default"
|
|
100
|
+
*/
|
|
101
|
+
size?: "default" | "sm" | "lg";
|
|
102
|
+
} & Omit<React.ComponentProps<typeof ToggleGroupPrimitive.Item>, "value">;
|
|
73
103
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
const ToggleGroupItem = React.forwardRef<
|
|
105
|
+
React.ComponentRef<typeof ToggleGroupPrimitive.Item>,
|
|
106
|
+
ToggleGroupItemProps
|
|
107
|
+
>(
|
|
108
|
+
(
|
|
109
|
+
{ className, children, variant, size, ariaLabel, dataHook, ...props },
|
|
110
|
+
ref
|
|
111
|
+
) => {
|
|
112
|
+
const context = React.useContext(ToggleGroupContext);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<ToggleGroupPrimitive.Item
|
|
116
|
+
ref={ref}
|
|
117
|
+
aria-label={ariaLabel}
|
|
118
|
+
className={cn(
|
|
119
|
+
toggleVariants({
|
|
120
|
+
variant: context.variant || variant,
|
|
121
|
+
size: context.size || size,
|
|
122
|
+
}),
|
|
123
|
+
"w-auto min-w-0 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",
|
|
124
|
+
className
|
|
125
|
+
)}
|
|
126
|
+
data-hook={dataHook}
|
|
127
|
+
data-size={context.size || size}
|
|
128
|
+
data-slot="toggle-group-item"
|
|
129
|
+
data-variant={context.variant || variant}
|
|
130
|
+
{...props}
|
|
131
|
+
>
|
|
132
|
+
{children}
|
|
133
|
+
</ToggleGroupPrimitive.Item>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
);
|
|
86
137
|
|
|
87
|
-
|
|
88
|
-
<ToggleGroupPrimitive.Item
|
|
89
|
-
aria-label={ariaLabel}
|
|
90
|
-
className={cn(
|
|
91
|
-
toggleVariants({
|
|
92
|
-
variant: context.variant || variant,
|
|
93
|
-
size: context.size || size,
|
|
94
|
-
}),
|
|
95
|
-
"w-auto min-w-0 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",
|
|
96
|
-
className
|
|
97
|
-
)}
|
|
98
|
-
data-hook={dataHook}
|
|
99
|
-
data-size={context.size || size}
|
|
100
|
-
data-slot="toggle-group-item"
|
|
101
|
-
data-tracking-el={trackingEl || `toggle-group-item-${props.value}`}
|
|
102
|
-
data-tracking-label={trackingLabel}
|
|
103
|
-
data-variant={context.variant || variant}
|
|
104
|
-
{...props}
|
|
105
|
-
>
|
|
106
|
-
{children}
|
|
107
|
-
</ToggleGroupPrimitive.Item>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
138
|
+
ToggleGroupItem.displayName = "ToggleGroupItem";
|
|
110
139
|
|
|
111
140
|
export { ToggleGroup, ToggleGroupItem };
|
|
112
141
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { figma } from "@figma/code-connect";
|
|
3
|
-
import {
|
|
4
|
-
Toggle,
|
|
5
|
-
ToggleVariant,
|
|
6
|
-
ToggleSize,
|
|
7
|
-
} from "@brightlocal/ui-components/toggle";
|
|
3
|
+
import { Toggle } from "@brightlocal/ui-components/toggle";
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* Figma Code Connect mapping for Toggle component
|
|
@@ -18,20 +14,18 @@ figma.connect(
|
|
|
18
14
|
Toggle,
|
|
19
15
|
"https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---UI-Components?node-id=17429-129988&m=dev",
|
|
20
16
|
{
|
|
21
|
-
imports: [
|
|
22
|
-
"import { Toggle, ToggleVariant, ToggleSize } from '@brightlocal/ui-components/toggle'",
|
|
23
|
-
],
|
|
17
|
+
imports: ["import { Toggle } from '@brightlocal/ui-components/toggle'"],
|
|
24
18
|
props: {
|
|
25
|
-
// Map Figma variant property to code
|
|
19
|
+
// Map Figma variant property to code string
|
|
26
20
|
variant: figma.enum("Variant", {
|
|
27
|
-
Default:
|
|
28
|
-
Outline:
|
|
21
|
+
Default: "default",
|
|
22
|
+
Outline: "outline",
|
|
29
23
|
}),
|
|
30
|
-
// Map Figma size property to code
|
|
24
|
+
// Map Figma size property to code string
|
|
31
25
|
size: figma.enum("Size", {
|
|
32
|
-
sm:
|
|
33
|
-
default:
|
|
34
|
-
lg:
|
|
26
|
+
sm: "sm",
|
|
27
|
+
default: "default",
|
|
28
|
+
lg: "lg",
|
|
35
29
|
}),
|
|
36
30
|
// Map Figma properties
|
|
37
31
|
disabled: figma.boolean("Disabled"),
|
|
@@ -46,8 +40,8 @@ figma.connect(
|
|
|
46
40
|
ariaLabel: figma.string("ARIA Label"),
|
|
47
41
|
},
|
|
48
42
|
example: (props: {
|
|
49
|
-
variant?:
|
|
50
|
-
size?:
|
|
43
|
+
variant?: "default" | "outline";
|
|
44
|
+
size?: "default" | "sm" | "lg";
|
|
51
45
|
disabled?: boolean;
|
|
52
46
|
pressed?: boolean;
|
|
53
47
|
showText?: boolean;
|
|
@@ -67,10 +61,10 @@ figma.connect(
|
|
|
67
61
|
dataHook={props.dataHook || "toggle"}
|
|
68
62
|
disabled={props.disabled}
|
|
69
63
|
pressed={props.pressed}
|
|
70
|
-
size={props.size ||
|
|
64
|
+
size={props.size || "default"}
|
|
71
65
|
trackingEl={props.trackingEl}
|
|
72
66
|
trackingLabel={props.trackingLabel}
|
|
73
|
-
variant={props.variant ||
|
|
67
|
+
variant={props.variant || "default"}
|
|
74
68
|
>
|
|
75
69
|
{icon}
|
|
76
70
|
{props.showText && (props.text || "Toggle")}
|
|
@@ -1,49 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
import * as React from "react";
|
|
2
4
|
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
3
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
6
|
|
|
5
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
8
|
|
|
7
|
-
/**
|
|
8
|
-
* Visual style variants for Toggle
|
|
9
|
-
*/
|
|
10
|
-
export enum ToggleVariant {
|
|
11
|
-
/** Default variant with transparent background */
|
|
12
|
-
DEFAULT = "default",
|
|
13
|
-
/** Outline variant with border styling */
|
|
14
|
-
OUTLINE = "outline",
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Size variants for Toggle
|
|
19
|
-
*/
|
|
20
|
-
export enum ToggleSize {
|
|
21
|
-
/** Small size (32px height) */
|
|
22
|
-
SM = "sm",
|
|
23
|
-
/** Default size (36px height) */
|
|
24
|
-
DEFAULT = "default",
|
|
25
|
-
/** Large size (40px height) */
|
|
26
|
-
LG = "lg",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
9
|
const toggleVariants = cva(
|
|
30
|
-
"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:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
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:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-150 ease-in-out aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
31
11
|
{
|
|
32
12
|
variants: {
|
|
33
13
|
variant: {
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
default: "bg-transparent",
|
|
15
|
+
outline:
|
|
36
16
|
"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
37
17
|
},
|
|
38
18
|
size: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
default: "h-9 px-2 min-w-9",
|
|
20
|
+
sm: "h-8 px-1.5 min-w-8",
|
|
21
|
+
lg: "h-10 px-2.5 min-w-10",
|
|
42
22
|
},
|
|
43
23
|
},
|
|
44
24
|
defaultVariants: {
|
|
45
|
-
variant:
|
|
46
|
-
size:
|
|
25
|
+
variant: "default",
|
|
26
|
+
size: "default",
|
|
47
27
|
},
|
|
48
28
|
}
|
|
49
29
|
);
|
|
@@ -58,10 +38,16 @@ export interface ToggleProps
|
|
|
58
38
|
trackingEl?: string;
|
|
59
39
|
/** Tracking label for analytics context */
|
|
60
40
|
trackingLabel?: string;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Visual style variant
|
|
43
|
+
* @default "default"
|
|
44
|
+
*/
|
|
45
|
+
variant?: "default" | "outline";
|
|
46
|
+
/**
|
|
47
|
+
* Size variant
|
|
48
|
+
* @default "default"
|
|
49
|
+
*/
|
|
50
|
+
size?: "default" | "sm" | "lg";
|
|
65
51
|
/** ARIA label for accessibility (required when no text content) */
|
|
66
52
|
ariaLabel?: string;
|
|
67
53
|
}
|