@brightlocal/ui-components 0.4.0 → 0.5.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.js +64 -64
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +47 -47
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +27 -26
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +34 -34
- package/dist/button.cjs +1 -1
- 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 -37
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +5 -0
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +49 -36
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +3 -8
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +33 -48
- 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 +9 -9
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +6 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +126 -116
- package/dist/command.cjs +1 -1
- package/dist/command.js +35 -35
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +3 -3
- 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 +47 -52
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +50 -49
- 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 +334 -319
- 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.js +10 -10
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +6 -6
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +56 -56
- 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 +30 -17
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.js +13 -13
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +2 -1
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +28 -28
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +3 -3
- package/dist/rating.cjs +1 -1
- package/dist/rating.js +8 -8
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +1 -1
- package/dist/resizable.js +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 +40 -44
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +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.js +1 -1
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +28 -28
- 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 +16 -15
- 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 -19
- package/src/components/card.tsx +24 -1
- package/src/components/centred-layout.tsx +6 -29
- package/src/components/chart.tsx +5 -5
- package/src/components/checkbox.tsx +3 -3
- package/src/components/combobox.tsx +20 -8
- package/src/components/command.tsx +5 -5
- package/src/components/context-menu.tsx +3 -3
- package/src/components/date-picker.tsx +1 -1
- package/src/components/dialog.tsx +3 -3
- package/src/components/dropdown-menu.tsx +7 -12
- package/src/components/field.tsx +36 -33
- package/src/components/input-chip.tsx +1 -4
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-otp.tsx +3 -3
- 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 +16 -9
- package/src/components/menubar.tsx +3 -3
- package/src/components/navigation-menu.tsx +2 -1
- package/src/components/pagination.tsx +4 -8
- package/src/components/radio-group.tsx +2 -2
- package/src/components/rating.tsx +2 -2
- package/src/components/resizable.tsx +1 -1
- package/src/components/select.tsx +8 -12
- package/src/components/sheet.tsx +5 -5
- package/src/components/sonner.tsx +1 -1
- package/src/components/switch.tsx +1 -1
- 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
|
@@ -130,7 +130,7 @@ function Calendar({
|
|
|
130
130
|
caption_label: cn(
|
|
131
131
|
"text-sm font-sans leading-5 text-foreground select-none",
|
|
132
132
|
captionLayout === "dropdown" ? "font-normal" : "font-medium",
|
|
133
|
-
"[&>svg]:text-muted-foreground
|
|
133
|
+
"[&>svg]:text-muted-foreground",
|
|
134
134
|
"flex h-[34px] items-center gap-1 rounded-md pl-2 pr-1",
|
|
135
135
|
defaultClassNames.caption_label
|
|
136
136
|
),
|
|
@@ -203,27 +203,12 @@ function Calendar({
|
|
|
203
203
|
...iconProps
|
|
204
204
|
}) => {
|
|
205
205
|
if (orientation === "left") {
|
|
206
|
-
return
|
|
207
|
-
<ChevronLeft
|
|
208
|
-
className={cn("size-4", chevronClassName)}
|
|
209
|
-
{...iconProps}
|
|
210
|
-
/>
|
|
211
|
-
);
|
|
206
|
+
return <ChevronLeft className={chevronClassName} {...iconProps} />;
|
|
212
207
|
}
|
|
213
208
|
if (orientation === "right") {
|
|
214
|
-
return
|
|
215
|
-
<ChevronRight
|
|
216
|
-
className={cn("size-4", chevronClassName)}
|
|
217
|
-
{...iconProps}
|
|
218
|
-
/>
|
|
219
|
-
);
|
|
209
|
+
return <ChevronRight className={chevronClassName} {...iconProps} />;
|
|
220
210
|
}
|
|
221
|
-
return
|
|
222
|
-
<ChevronDown
|
|
223
|
-
className={cn("size-4", chevronClassName)}
|
|
224
|
-
{...iconProps}
|
|
225
|
-
/>
|
|
226
|
-
);
|
|
211
|
+
return <ChevronDown className={chevronClassName} {...iconProps} />;
|
|
227
212
|
},
|
|
228
213
|
DayButton: CalendarDayButton,
|
|
229
214
|
...components,
|
package/src/components/card.tsx
CHANGED
|
@@ -14,7 +14,15 @@ type CardVariant = "default" | "transparent" | "border" | "transparent-flush";
|
|
|
14
14
|
const CardContext = React.createContext<{ flush: boolean }>({ flush: false });
|
|
15
15
|
|
|
16
16
|
const cardVariants = cva(
|
|
17
|
-
[
|
|
17
|
+
[
|
|
18
|
+
"flex",
|
|
19
|
+
"flex-col",
|
|
20
|
+
"gap-8",
|
|
21
|
+
"rounded-xl",
|
|
22
|
+
"py-8",
|
|
23
|
+
"transition-colors",
|
|
24
|
+
"w-full",
|
|
25
|
+
],
|
|
18
26
|
{
|
|
19
27
|
variants: {
|
|
20
28
|
variant: {
|
|
@@ -61,6 +69,11 @@ type CardProps = React.ComponentProps<"div"> & {
|
|
|
61
69
|
* Tracking label for analytics context
|
|
62
70
|
*/
|
|
63
71
|
trackingLabel?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Maximum width of the card (e.g., "420px", "600px", "100%")
|
|
74
|
+
* @default "400px"
|
|
75
|
+
*/
|
|
76
|
+
maxWidth?: string | number;
|
|
64
77
|
};
|
|
65
78
|
|
|
66
79
|
/**
|
|
@@ -75,13 +88,22 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
75
88
|
dataHook,
|
|
76
89
|
trackingEl,
|
|
77
90
|
trackingLabel,
|
|
91
|
+
maxWidth = "400px",
|
|
78
92
|
children,
|
|
93
|
+
style,
|
|
79
94
|
...props
|
|
80
95
|
},
|
|
81
96
|
ref
|
|
82
97
|
) => {
|
|
83
98
|
const flush = variant === "transparent-flush";
|
|
84
99
|
|
|
100
|
+
const maxWidthStyle =
|
|
101
|
+
maxWidth !== undefined
|
|
102
|
+
? {
|
|
103
|
+
maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth,
|
|
104
|
+
}
|
|
105
|
+
: undefined;
|
|
106
|
+
|
|
85
107
|
return (
|
|
86
108
|
<CardContext.Provider value={{ flush }}>
|
|
87
109
|
<div
|
|
@@ -91,6 +113,7 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
91
113
|
data-slot="card"
|
|
92
114
|
data-tracking-el={trackingEl || `card-${variant}`}
|
|
93
115
|
data-tracking-label={trackingLabel}
|
|
116
|
+
style={{ ...maxWidthStyle, ...style }}
|
|
94
117
|
{...props}
|
|
95
118
|
>
|
|
96
119
|
{children}
|
|
@@ -7,14 +7,13 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
7
7
|
* -----------------------------------------------------------------------------------------------*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* CentredLayout provides a
|
|
10
|
+
* CentredLayout provides a full-page centered container.
|
|
11
11
|
*
|
|
12
12
|
* Spacing tokens used:
|
|
13
13
|
* - Padding: section-padding-x/y tokens (responsive: 16px mobile, 24px desktop)
|
|
14
14
|
* - Header to content gap: gap-4 (spacing.4 = 16px)
|
|
15
|
-
* - Max width: max-w-7xl (1280px) by default
|
|
16
15
|
*
|
|
17
|
-
* The component centers content horizontally and vertically.
|
|
16
|
+
* The component takes full page width/height and centers content horizontally and vertically.
|
|
18
17
|
*
|
|
19
18
|
* @example
|
|
20
19
|
* // Basic usage
|
|
@@ -49,50 +48,28 @@ interface CentredLayoutProps extends React.ComponentProps<"div"> {
|
|
|
49
48
|
* Tracking label for analytics context
|
|
50
49
|
*/
|
|
51
50
|
trackingLabel?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Custom max-width value (overrides default 1280px)
|
|
54
|
-
*/
|
|
55
|
-
maxWidth?: string | number;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
/**
|
|
59
|
-
* CentredLayout component for centering content with
|
|
54
|
+
* CentredLayout component for centering content with full page width/height.
|
|
60
55
|
*/
|
|
61
56
|
const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
|
|
62
57
|
(
|
|
63
|
-
{
|
|
64
|
-
className,
|
|
65
|
-
maxWidth,
|
|
66
|
-
children,
|
|
67
|
-
dataHook,
|
|
68
|
-
trackingEl,
|
|
69
|
-
trackingLabel,
|
|
70
|
-
...props
|
|
71
|
-
},
|
|
58
|
+
{ className, children, dataHook, trackingEl, trackingLabel, ...props },
|
|
72
59
|
ref
|
|
73
60
|
) => {
|
|
74
|
-
// If custom maxWidth is provided, use inline style; otherwise use default max-w-7xl
|
|
75
|
-
const maxWidthStyle =
|
|
76
|
-
maxWidth !== undefined
|
|
77
|
-
? {
|
|
78
|
-
maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth,
|
|
79
|
-
}
|
|
80
|
-
: undefined;
|
|
81
|
-
|
|
82
61
|
return (
|
|
83
62
|
<div
|
|
84
63
|
ref={ref}
|
|
85
64
|
className={cn(
|
|
86
65
|
// Base styles with section-padding tokens (responsive: 16px mobile, 24px desktop) and gap-4 for header/content spacing
|
|
87
|
-
"bg-background flex min-h-screen flex-col items-center justify-center gap-4
|
|
88
|
-
!maxWidth && "max-w-7xl",
|
|
66
|
+
"bg-background p-section flex min-h-screen w-full flex-col items-center justify-center gap-4",
|
|
89
67
|
className
|
|
90
68
|
)}
|
|
91
69
|
data-hook={dataHook}
|
|
92
70
|
data-slot="centred-layout"
|
|
93
71
|
data-tracking-el={trackingEl}
|
|
94
72
|
data-tracking-label={trackingLabel}
|
|
95
|
-
style={maxWidthStyle}
|
|
96
73
|
{...props}
|
|
97
74
|
>
|
|
98
75
|
{children}
|
|
@@ -161,7 +138,7 @@ const CentredLayoutContent = React.forwardRef<
|
|
|
161
138
|
<div
|
|
162
139
|
ref={ref}
|
|
163
140
|
className={cn(
|
|
164
|
-
"flex flex-1 flex-col items-center justify-center",
|
|
141
|
+
"flex w-full flex-1 flex-col items-center justify-center",
|
|
165
142
|
className
|
|
166
143
|
)}
|
|
167
144
|
data-slot="centred-layout-content"
|
package/src/components/chart.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
11
11
|
export interface ChartConfig {
|
|
12
12
|
[key: string]: {
|
|
13
13
|
label?: React.ReactNode;
|
|
14
|
-
icon?: React.ComponentType
|
|
14
|
+
icon?: React.ComponentType<{ size?: number }>;
|
|
15
15
|
} & (
|
|
16
16
|
| { color?: string; theme?: never }
|
|
17
17
|
| { color?: never; theme: Record<string, string> }
|
|
@@ -309,7 +309,7 @@ function ChartTooltipContent({
|
|
|
309
309
|
<div
|
|
310
310
|
key={item.dataKey}
|
|
311
311
|
className={cn(
|
|
312
|
-
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2
|
|
312
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2",
|
|
313
313
|
indicator === "dot" && "items-center"
|
|
314
314
|
)}
|
|
315
315
|
>
|
|
@@ -318,7 +318,7 @@ function ChartTooltipContent({
|
|
|
318
318
|
) : (
|
|
319
319
|
<>
|
|
320
320
|
{itemConfig?.icon && !hideIndicator ? (
|
|
321
|
-
<itemConfig.icon />
|
|
321
|
+
<itemConfig.icon size={10} />
|
|
322
322
|
) : (
|
|
323
323
|
!hideIndicator && (
|
|
324
324
|
<div
|
|
@@ -450,11 +450,11 @@ function ChartLegendContent({
|
|
|
450
450
|
<div
|
|
451
451
|
key={item.value}
|
|
452
452
|
className={cn(
|
|
453
|
-
"[&>svg]:text-muted-foreground flex items-center gap-1.5
|
|
453
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5"
|
|
454
454
|
)}
|
|
455
455
|
>
|
|
456
456
|
{itemConfig?.icon && !hideIcon ? (
|
|
457
|
-
<itemConfig.icon />
|
|
457
|
+
<itemConfig.icon size={12} />
|
|
458
458
|
) : (
|
|
459
459
|
<div
|
|
460
460
|
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
4
|
-
import {
|
|
4
|
+
import { Check } from "@brightlocal/icons";
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
8
|
const checkboxVariants = cva(
|
|
9
9
|
[
|
|
10
10
|
// Layout & Size
|
|
11
|
-
"size-
|
|
11
|
+
"size-[18px] shrink-0 self-start mt-0.5",
|
|
12
12
|
// Appearance
|
|
13
13
|
"bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors outline-none",
|
|
14
14
|
// Checked State
|
|
@@ -83,7 +83,7 @@ const Checkbox = React.forwardRef<HTMLButtonElement, CheckboxProps>(
|
|
|
83
83
|
className="flex items-center justify-center text-current transition-none"
|
|
84
84
|
data-slot="checkbox-indicator"
|
|
85
85
|
>
|
|
86
|
-
<
|
|
86
|
+
<Check />
|
|
87
87
|
</CheckboxPrimitive.Indicator>
|
|
88
88
|
</CheckboxPrimitive.Root>
|
|
89
89
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ChevronsUpDown, Check } from "@brightlocal/icons";
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -189,7 +189,6 @@ const comboboxTriggerVariants = cva(
|
|
|
189
189
|
|
|
190
190
|
// Icon styles
|
|
191
191
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
192
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
193
192
|
],
|
|
194
193
|
{
|
|
195
194
|
variants: {
|
|
@@ -259,9 +258,9 @@ const ComboboxTrigger = React.forwardRef<
|
|
|
259
258
|
{...props}
|
|
260
259
|
>
|
|
261
260
|
{children}
|
|
262
|
-
<
|
|
261
|
+
<ChevronsUpDown
|
|
263
262
|
aria-hidden="true"
|
|
264
|
-
className="text-muted-foreground ml-auto
|
|
263
|
+
className="text-muted-foreground ml-auto shrink-0"
|
|
265
264
|
/>
|
|
266
265
|
</button>
|
|
267
266
|
</PopoverTrigger>
|
|
@@ -311,6 +310,11 @@ export interface ComboboxContentProps {
|
|
|
311
310
|
children: React.ReactNode;
|
|
312
311
|
/** Alignment of the popover relative to trigger */
|
|
313
312
|
align?: "start" | "center" | "end";
|
|
313
|
+
/**
|
|
314
|
+
* Hide the list area (and the input border). Useful for async search
|
|
315
|
+
* where you want to hide results until a minimum character count.
|
|
316
|
+
*/
|
|
317
|
+
hideList?: boolean;
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
function ComboboxContent({
|
|
@@ -318,6 +322,7 @@ function ComboboxContent({
|
|
|
318
322
|
className,
|
|
319
323
|
children,
|
|
320
324
|
align = "start",
|
|
325
|
+
hideList = false,
|
|
321
326
|
}: ComboboxContentProps) {
|
|
322
327
|
const { shouldFilter } = useComboboxContext();
|
|
323
328
|
|
|
@@ -326,9 +331,13 @@ function ComboboxContent({
|
|
|
326
331
|
align={align}
|
|
327
332
|
className={cn("w-[var(--radix-popover-trigger-width)] p-0", className)}
|
|
328
333
|
data-slot="combobox-popover"
|
|
334
|
+
side="bottom"
|
|
329
335
|
>
|
|
330
336
|
<Command
|
|
331
|
-
className=
|
|
337
|
+
className={cn(
|
|
338
|
+
"border-0 shadow-none",
|
|
339
|
+
hideList && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
340
|
+
)}
|
|
332
341
|
data-slot="combobox-command"
|
|
333
342
|
dataHook={dataHook || "combobox-command"}
|
|
334
343
|
shouldFilter={shouldFilter}
|
|
@@ -525,9 +534,9 @@ const ComboboxItem = React.forwardRef<
|
|
|
525
534
|
>
|
|
526
535
|
{renderContent()}
|
|
527
536
|
{isSelected && (
|
|
528
|
-
<
|
|
537
|
+
<Check
|
|
529
538
|
aria-hidden="true"
|
|
530
|
-
className="text-muted-foreground
|
|
539
|
+
className="text-muted-foreground shrink-0"
|
|
531
540
|
/>
|
|
532
541
|
)}
|
|
533
542
|
</CommandItem>
|
|
@@ -576,7 +585,10 @@ function ComboboxLoading({ className, children }: ComboboxLoadingProps) {
|
|
|
576
585
|
>
|
|
577
586
|
{children || (
|
|
578
587
|
<>
|
|
579
|
-
<
|
|
588
|
+
<div
|
|
589
|
+
aria-hidden="true"
|
|
590
|
+
className="size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"
|
|
591
|
+
/>
|
|
580
592
|
Loading...
|
|
581
593
|
</>
|
|
582
594
|
)}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Command as CommandPrimitive } from "cmdk";
|
|
5
|
-
import {
|
|
5
|
+
import { Check, Search, X } from "@brightlocal/icons";
|
|
6
6
|
|
|
7
7
|
import { Button } from "@brightlocal/ui-components/button";
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -127,7 +127,7 @@ const CommandInput = React.forwardRef<
|
|
|
127
127
|
data-hook={dataHook}
|
|
128
128
|
data-slot="command-input-wrapper"
|
|
129
129
|
>
|
|
130
|
-
<
|
|
130
|
+
<Search className="shrink-0 opacity-50" />
|
|
131
131
|
<CommandPrimitive.Input
|
|
132
132
|
ref={inputRef}
|
|
133
133
|
className={cn(
|
|
@@ -149,7 +149,7 @@ const CommandInput = React.forwardRef<
|
|
|
149
149
|
variant="ghost"
|
|
150
150
|
onClick={handleClear}
|
|
151
151
|
>
|
|
152
|
-
<
|
|
152
|
+
<X />
|
|
153
153
|
</Button>
|
|
154
154
|
)}
|
|
155
155
|
</div>
|
|
@@ -326,7 +326,7 @@ const CommandItem = React.forwardRef<
|
|
|
326
326
|
<CommandPrimitive.Item
|
|
327
327
|
ref={ref}
|
|
328
328
|
className={cn(
|
|
329
|
-
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground
|
|
329
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
330
330
|
className
|
|
331
331
|
)}
|
|
332
332
|
data-hook={dataHook}
|
|
@@ -337,7 +337,7 @@ const CommandItem = React.forwardRef<
|
|
|
337
337
|
{...props}
|
|
338
338
|
>
|
|
339
339
|
{children}
|
|
340
|
-
{selected && <
|
|
340
|
+
{selected && <Check className="text-foreground ml-auto" />}
|
|
341
341
|
</CommandPrimitive.Item>
|
|
342
342
|
)
|
|
343
343
|
);
|
|
@@ -175,7 +175,7 @@ const ContextMenuSubTrigger = React.forwardRef<
|
|
|
175
175
|
{...props}
|
|
176
176
|
>
|
|
177
177
|
{children}
|
|
178
|
-
<ChevronRight className="ml-auto
|
|
178
|
+
<ChevronRight className="ml-auto" />
|
|
179
179
|
</ContextMenuPrimitive.SubTrigger>
|
|
180
180
|
)
|
|
181
181
|
);
|
|
@@ -341,7 +341,7 @@ const ContextMenuCheckboxItem = React.forwardRef<
|
|
|
341
341
|
>
|
|
342
342
|
<span className="absolute left-2 flex size-3.5 items-center justify-center">
|
|
343
343
|
<ContextMenuPrimitive.ItemIndicator>
|
|
344
|
-
<Check
|
|
344
|
+
<Check />
|
|
345
345
|
</ContextMenuPrimitive.ItemIndicator>
|
|
346
346
|
</span>
|
|
347
347
|
{children}
|
|
@@ -395,7 +395,7 @@ const ContextMenuRadioItem = React.forwardRef<
|
|
|
395
395
|
>
|
|
396
396
|
<span className="absolute left-2 flex size-3.5 items-center justify-center">
|
|
397
397
|
<ContextMenuPrimitive.ItemIndicator>
|
|
398
|
-
<Circle className="
|
|
398
|
+
<Circle className="fill-current" size={8} />
|
|
399
399
|
</ContextMenuPrimitive.ItemIndicator>
|
|
400
400
|
</span>
|
|
401
401
|
{children}
|
|
@@ -296,7 +296,7 @@ const DatePickerTrigger = React.forwardRef<
|
|
|
296
296
|
>
|
|
297
297
|
<CalendarIcon
|
|
298
298
|
className={cn(
|
|
299
|
-
"text-muted-foreground pointer-events-none absolute top-1/2 left-3
|
|
299
|
+
"text-muted-foreground pointer-events-none absolute top-1/2 left-3 -translate-y-1/2",
|
|
300
300
|
disabled && "opacity-50"
|
|
301
301
|
)}
|
|
302
302
|
data-slot="calendar-icon"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
-
import {
|
|
5
|
+
import { X } from "@brightlocal/icons";
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
@@ -130,8 +130,8 @@ const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
130
130
|
{...props}
|
|
131
131
|
>
|
|
132
132
|
{children}
|
|
133
|
-
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-8 right-8 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
|
|
134
|
-
<
|
|
133
|
+
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-8 right-8 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">
|
|
134
|
+
<X />
|
|
135
135
|
<span className="sr-only">Close</span>
|
|
136
136
|
</DialogPrimitive.Close>
|
|
137
137
|
</DialogPrimitive.Content>
|
|
@@ -203,8 +203,6 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
203
203
|
"data-[inset]:pl-8",
|
|
204
204
|
// Icon styling
|
|
205
205
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
206
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
207
|
-
"[&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
208
206
|
],
|
|
209
207
|
className
|
|
210
208
|
)}
|
|
@@ -268,8 +266,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
|
|
268
266
|
"focus:bg-accent focus:text-accent-foreground",
|
|
269
267
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
270
268
|
// Icon styling
|
|
271
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
272
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
269
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
273
270
|
],
|
|
274
271
|
className
|
|
275
272
|
)}
|
|
@@ -281,7 +278,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
|
|
281
278
|
>
|
|
282
279
|
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
283
280
|
<DropdownMenuPrimitive.ItemIndicator>
|
|
284
|
-
<Check
|
|
281
|
+
<Check />
|
|
285
282
|
</DropdownMenuPrimitive.ItemIndicator>
|
|
286
283
|
</span>
|
|
287
284
|
{children}
|
|
@@ -341,8 +338,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
|
|
341
338
|
"focus:bg-accent focus:text-accent-foreground",
|
|
342
339
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
343
340
|
// Icon styling
|
|
344
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
345
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
341
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
346
342
|
],
|
|
347
343
|
className
|
|
348
344
|
)}
|
|
@@ -354,7 +350,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
|
|
354
350
|
>
|
|
355
351
|
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
356
352
|
<DropdownMenuPrimitive.ItemIndicator>
|
|
357
|
-
<Circle className="
|
|
353
|
+
<Circle className="fill-current" size={8} />
|
|
358
354
|
</DropdownMenuPrimitive.ItemIndicator>
|
|
359
355
|
</span>
|
|
360
356
|
{children}
|
|
@@ -502,8 +498,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
502
498
|
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
503
499
|
"data-[inset]:pl-8",
|
|
504
500
|
// Icon styling
|
|
505
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
506
|
-
"[&_svg:not([class*='size-'])]:size-4",
|
|
501
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
507
502
|
],
|
|
508
503
|
className
|
|
509
504
|
)}
|
|
@@ -515,7 +510,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
515
510
|
{...props}
|
|
516
511
|
>
|
|
517
512
|
{children}
|
|
518
|
-
<ChevronRight className="ml-auto
|
|
513
|
+
<ChevronRight className="ml-auto" />
|
|
519
514
|
</DropdownMenuPrimitive.SubTrigger>
|
|
520
515
|
);
|
|
521
516
|
}
|
|
@@ -647,7 +642,7 @@ const DropdownMenuTriggerAvatar = React.forwardRef<
|
|
|
647
642
|
</span>
|
|
648
643
|
)}
|
|
649
644
|
</div>
|
|
650
|
-
<ChevronsUpDown className="text-muted-foreground
|
|
645
|
+
<ChevronsUpDown className="text-muted-foreground opacity-50" />
|
|
651
646
|
</DropdownMenuPrimitive.Trigger>
|
|
652
647
|
);
|
|
653
648
|
}
|
package/src/components/field.tsx
CHANGED
|
@@ -64,39 +64,41 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const fieldVariants = cva(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
const fieldVariants = cva(
|
|
68
|
+
[
|
|
69
|
+
"group/field flex w-full gap-2",
|
|
70
|
+
// Label leading overrides: use leading-normal for wrap-capable labels (checkbox)
|
|
71
|
+
"has-[>[role=checkbox]]:[&_[data-slot=field-label]]:leading-normal",
|
|
72
|
+
],
|
|
73
|
+
{
|
|
74
|
+
variants: {
|
|
75
|
+
orientation: {
|
|
76
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
77
|
+
horizontal: [
|
|
78
|
+
"grid grid-cols-[auto_1fr] items-center gap-x-2",
|
|
79
|
+
"[&>[data-slot=field-description]]:col-start-2 [&>[data-slot=field-error]]:col-start-2",
|
|
80
|
+
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
81
|
+
],
|
|
82
|
+
responsive: [
|
|
83
|
+
"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:grid @md/field-group:grid-cols-[auto_1fr] @md/field-group:items-center @md/field-group:[&>*]:w-auto",
|
|
84
|
+
"@md/field-group:[&>[data-slot=field-description]]:col-start-2 @md/field-group:[&>[data-slot=field-error]]:col-start-2",
|
|
85
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
86
|
+
],
|
|
87
|
+
},
|
|
81
88
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
89
|
+
defaultVariants: {
|
|
90
|
+
orientation: "vertical",
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
);
|
|
87
94
|
|
|
88
95
|
/**
|
|
89
96
|
* Props for the Field component
|
|
90
97
|
*/
|
|
91
98
|
interface FieldProps
|
|
92
|
-
extends React.ComponentProps<"div">,
|
|
93
|
-
VariantProps<typeof fieldVariants> {}
|
|
99
|
+
extends React.ComponentProps<"div">, VariantProps<typeof fieldVariants> {}
|
|
94
100
|
|
|
95
|
-
function Field({
|
|
96
|
-
className,
|
|
97
|
-
orientation = "vertical",
|
|
98
|
-
...props
|
|
99
|
-
}: FieldProps) {
|
|
101
|
+
function Field({ className, orientation = "vertical", ...props }: FieldProps) {
|
|
100
102
|
return (
|
|
101
103
|
<div
|
|
102
104
|
className={cn(fieldVariants({ orientation }), className)}
|
|
@@ -142,6 +144,7 @@ function FieldLabel({
|
|
|
142
144
|
<Label
|
|
143
145
|
className={cn(
|
|
144
146
|
// Base label styles from primitives are inherited via Label component
|
|
147
|
+
// Reset to mb-0 when label wraps a field (card variant for radio/checkbox)
|
|
145
148
|
"group/field-label peer/field-label w-fit",
|
|
146
149
|
// Field-specific container styles
|
|
147
150
|
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
|
|
@@ -195,7 +198,10 @@ interface FieldErrorItem {
|
|
|
195
198
|
/**
|
|
196
199
|
* Props for the FieldError component
|
|
197
200
|
*/
|
|
198
|
-
interface FieldErrorProps extends Omit<
|
|
201
|
+
interface FieldErrorProps extends Omit<
|
|
202
|
+
React.ComponentProps<"div">,
|
|
203
|
+
"children"
|
|
204
|
+
> {
|
|
199
205
|
/**
|
|
200
206
|
* Data hook for automated testing (REQUIRED)
|
|
201
207
|
*/
|
|
@@ -251,10 +257,7 @@ function FieldErrorIcon({
|
|
|
251
257
|
return (
|
|
252
258
|
<Icon
|
|
253
259
|
aria-hidden="true"
|
|
254
|
-
className={cn(
|
|
255
|
-
"inline-block size-4 shrink-0 align-text-bottom",
|
|
256
|
-
className
|
|
257
|
-
)}
|
|
260
|
+
className={cn("inline-block shrink-0 align-text-bottom", className)}
|
|
258
261
|
{...props}
|
|
259
262
|
/>
|
|
260
263
|
);
|
|
@@ -297,8 +300,8 @@ function FieldError({
|
|
|
297
300
|
...props
|
|
298
301
|
}: FieldErrorProps) {
|
|
299
302
|
// Filter out undefined errors and those without messages
|
|
300
|
-
const errorMessages = errors?.filter(
|
|
301
|
-
|
|
303
|
+
const errorMessages = errors?.filter((e): e is FieldErrorItem =>
|
|
304
|
+
Boolean(e?.message)
|
|
302
305
|
);
|
|
303
306
|
|
|
304
307
|
// If no children and no valid errors, don't render anything
|
|
@@ -504,10 +504,7 @@ function InputChipItems({
|
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
return (
|
|
507
|
-
<div
|
|
508
|
-
className={cn("contents", className)}
|
|
509
|
-
data-slot="input-chip-items"
|
|
510
|
-
>
|
|
507
|
+
<div className={cn("contents", className)} data-slot="input-chip-items">
|
|
511
508
|
{value.map((item, index) => (
|
|
512
509
|
<Chip
|
|
513
510
|
key={`${item}-${index}`}
|
|
@@ -141,7 +141,7 @@ const inputGroupButtonVariants = cva(
|
|
|
141
141
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
142
142
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
143
143
|
"text-muted-foreground hover:text-foreground",
|
|
144
|
-
"[&_svg]:pointer-events-none [&_svg]:
|
|
144
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
145
145
|
],
|
|
146
146
|
{
|
|
147
147
|
variants: {
|