@brightlocal/ui-components 1.1.1 → 1.2.1
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/AI_USAGE.md +390 -0
- package/README.md +45 -10
- package/component-meta.json +1488 -0
- package/dist/blocks/input-list.cjs +2 -0
- package/dist/blocks/input-list.d.ts +93 -0
- package/dist/blocks/input-list.d.ts.map +1 -0
- package/dist/blocks/input-list.js +215 -0
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +17 -14
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +9 -8
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +20 -16
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.js +1 -1
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +8 -10
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +12 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +87 -79
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +60 -50
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +66 -57
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +2 -2
- package/dist/header.cjs +1 -1
- package/dist/header.d.ts +4 -0
- package/dist/header.d.ts.map +1 -1
- package/dist/header.js +33 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +281 -268
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +2 -2
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +17 -17
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +20 -20
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +33 -25
- package/dist/input.cjs +1 -1
- package/dist/input.js +15 -15
- package/dist/label.d.ts.map +1 -1
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +24 -25
- package/dist/list.cjs +1 -0
- package/dist/list.d.ts +104 -0
- package/dist/list.d.ts.map +1 -0
- package/dist/list.js +145 -0
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +6 -5
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +20 -20
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +10 -4
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +69 -56
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +66 -15
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/split-layout.js +100 -96
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +2 -2
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +40 -38
- package/package.json +5 -1
- package/src/blocks/input-list.tsx +366 -0
- package/src/blocks/sidebar.tsx +7 -7
- package/src/components/breadcrumb.tsx +4 -1
- package/src/components/button.tsx +1 -0
- package/src/components/calendar.tsx +1 -1
- package/src/components/card.tsx +8 -4
- package/src/components/centred-layout.tsx +1 -1
- package/src/components/checkbox.tsx +2 -4
- package/src/components/combobox.tsx +21 -2
- package/src/components/command.tsx +25 -9
- package/src/components/date-picker.tsx +15 -5
- package/src/components/dropdown-menu.tsx +3 -3
- package/src/components/field.tsx +5 -3
- package/src/components/header.tsx +28 -2
- package/src/components/input-chip.tsx +2 -2
- package/src/components/input-group.tsx +4 -4
- package/src/components/input-otp.tsx +7 -3
- package/src/components/input-password.tsx +8 -2
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +1 -4
- package/src/components/link.tsx +3 -4
- package/src/components/list.tsx +290 -0
- package/src/components/navigation-menu.tsx +1 -0
- package/src/components/radio-group.tsx +2 -2
- package/src/components/select.tsx +3 -3
- package/src/components/sheet.tsx +2 -2
- package/src/components/sonner.tsx +65 -38
- package/src/components/split-layout.tsx +200 -79
- package/src/components/switch.tsx +6 -4
- package/src/components/textarea.tsx +1 -1
- package/src/components/tooltip.tsx +4 -2
- package/src/index.ts +2 -0
|
@@ -263,7 +263,7 @@ const ComboboxTrigger = React.forwardRef<
|
|
|
263
263
|
className={cn(
|
|
264
264
|
comboboxTriggerVariants({ variant }),
|
|
265
265
|
hasError &&
|
|
266
|
-
"border-
|
|
266
|
+
"border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive",
|
|
267
267
|
className
|
|
268
268
|
)}
|
|
269
269
|
data-hook={dataHook}
|
|
@@ -330,6 +330,17 @@ export interface ComboboxContentProps {
|
|
|
330
330
|
children: React.ReactNode;
|
|
331
331
|
/** Alignment of the popover relative to trigger */
|
|
332
332
|
align?: "start" | "center" | "end";
|
|
333
|
+
/** Which side of the trigger to render the popover. @default "bottom" */
|
|
334
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
335
|
+
/** Distance in px between the trigger and the popover. @default 4 */
|
|
336
|
+
sideOffset?: number;
|
|
337
|
+
/**
|
|
338
|
+
* When true, Radix avoids collisions with the viewport/boundaries by
|
|
339
|
+
* flipping and/or shifting the popover to keep it in view. Set to false
|
|
340
|
+
* to disable collision handling and force the requested position.
|
|
341
|
+
* @default true
|
|
342
|
+
*/
|
|
343
|
+
avoidCollisions?: boolean;
|
|
333
344
|
/**
|
|
334
345
|
* Hide the list area (and the input border). Useful for async search
|
|
335
346
|
* where you want to hide results until a minimum character count.
|
|
@@ -342,6 +353,9 @@ function ComboboxContent({
|
|
|
342
353
|
className,
|
|
343
354
|
children,
|
|
344
355
|
align = "start",
|
|
356
|
+
side = "bottom",
|
|
357
|
+
sideOffset,
|
|
358
|
+
avoidCollisions,
|
|
345
359
|
hideList = false,
|
|
346
360
|
}: ComboboxContentProps) {
|
|
347
361
|
const { shouldFilter, itemToStringValue } = useComboboxContext();
|
|
@@ -356,9 +370,11 @@ function ComboboxContent({
|
|
|
356
370
|
<PopoverContent
|
|
357
371
|
align={align}
|
|
358
372
|
aria-label="Options"
|
|
373
|
+
avoidCollisions={avoidCollisions}
|
|
359
374
|
className={cn("w-[var(--radix-popover-trigger-width)] p-0", className)}
|
|
360
375
|
data-slot="combobox-popover"
|
|
361
|
-
side=
|
|
376
|
+
side={side}
|
|
377
|
+
sideOffset={sideOffset}
|
|
362
378
|
>
|
|
363
379
|
<Command
|
|
364
380
|
className={cn(
|
|
@@ -609,11 +625,14 @@ export interface ComboboxLoadingProps {
|
|
|
609
625
|
function ComboboxLoading({ className, children }: ComboboxLoadingProps) {
|
|
610
626
|
return (
|
|
611
627
|
<div
|
|
628
|
+
aria-disabled="true"
|
|
629
|
+
aria-selected="false"
|
|
612
630
|
className={cn(
|
|
613
631
|
"text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
|
|
614
632
|
className
|
|
615
633
|
)}
|
|
616
634
|
data-slot="combobox-loading"
|
|
635
|
+
role="option"
|
|
617
636
|
>
|
|
618
637
|
{children || (
|
|
619
638
|
<>
|
|
@@ -208,15 +208,31 @@ export interface CommandEmptyProps extends React.ComponentProps<
|
|
|
208
208
|
const CommandEmpty = React.forwardRef<
|
|
209
209
|
React.ComponentRef<typeof CommandPrimitive.Empty>,
|
|
210
210
|
CommandEmptyProps
|
|
211
|
-
>(({ dataHook, ...props }, ref) =>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)
|
|
211
|
+
>(({ dataHook, ...props }, ref) => {
|
|
212
|
+
// cmdk hardcodes role="presentation" after spreading props, so we
|
|
213
|
+
// override it via a callback ref to satisfy the listbox a11y contract
|
|
214
|
+
// (role="listbox" requires option or group children).
|
|
215
|
+
const setRef = React.useCallback(
|
|
216
|
+
(node: HTMLDivElement | null) => {
|
|
217
|
+
node?.setAttribute("role", "option");
|
|
218
|
+
if (typeof ref === "function") ref(node);
|
|
219
|
+
else if (ref) ref.current = node;
|
|
220
|
+
},
|
|
221
|
+
[ref]
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<CommandPrimitive.Empty
|
|
226
|
+
ref={setRef}
|
|
227
|
+
aria-disabled="true"
|
|
228
|
+
aria-selected="false"
|
|
229
|
+
className="py-6 text-center text-sm"
|
|
230
|
+
data-hook={dataHook}
|
|
231
|
+
data-slot="command-empty"
|
|
232
|
+
{...props}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
});
|
|
220
236
|
CommandEmpty.displayName = "CommandEmpty";
|
|
221
237
|
|
|
222
238
|
/**
|
|
@@ -227,7 +227,9 @@ function DatePickerRoot({
|
|
|
227
227
|
return (
|
|
228
228
|
<DatePickerContext.Provider value={contextValue}>
|
|
229
229
|
<Popover open={open} onOpenChange={setOpen}>
|
|
230
|
-
{
|
|
230
|
+
<div data-hook={dataHook} data-slot="date-picker">
|
|
231
|
+
{children}
|
|
232
|
+
</div>
|
|
231
233
|
</Popover>
|
|
232
234
|
</DatePickerContext.Provider>
|
|
233
235
|
);
|
|
@@ -261,8 +263,16 @@ const DatePickerTrigger = React.forwardRef<
|
|
|
261
263
|
HTMLButtonElement,
|
|
262
264
|
DatePickerTriggerProps
|
|
263
265
|
>(({ className, children, id, error, ...props }, ref) => {
|
|
264
|
-
const {
|
|
265
|
-
|
|
266
|
+
const {
|
|
267
|
+
mode,
|
|
268
|
+
date,
|
|
269
|
+
dateRange,
|
|
270
|
+
dateFormat,
|
|
271
|
+
placeholder,
|
|
272
|
+
disabled,
|
|
273
|
+
dataHook,
|
|
274
|
+
open,
|
|
275
|
+
} = useDatePickerContext();
|
|
266
276
|
|
|
267
277
|
const hasError = !!error;
|
|
268
278
|
|
|
@@ -309,10 +319,10 @@ const DatePickerTrigger = React.forwardRef<
|
|
|
309
319
|
}
|
|
310
320
|
className={cn(
|
|
311
321
|
inputVariants({ hasIcon: true }),
|
|
312
|
-
"
|
|
322
|
+
"group-hover/field:bg-accent dark:group-hover/field:bg-input/50 relative cursor-pointer justify-start pb-0 text-left",
|
|
313
323
|
!hasValue && "text-muted-foreground",
|
|
314
324
|
hasError &&
|
|
315
|
-
"border-
|
|
325
|
+
"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",
|
|
316
326
|
className
|
|
317
327
|
)}
|
|
318
328
|
data-error={hasError || undefined}
|
|
@@ -266,7 +266,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
|
|
266
266
|
"focus:bg-accent focus:text-accent-foreground",
|
|
267
267
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
268
268
|
// Icon styling
|
|
269
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
269
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
270
270
|
],
|
|
271
271
|
className
|
|
272
272
|
)}
|
|
@@ -338,7 +338,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
|
|
338
338
|
"focus:bg-accent focus:text-accent-foreground",
|
|
339
339
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
340
340
|
// Icon styling
|
|
341
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
341
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
342
342
|
],
|
|
343
343
|
className
|
|
344
344
|
)}
|
|
@@ -498,7 +498,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
498
498
|
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
499
499
|
"data-[inset]:pl-8",
|
|
500
500
|
// Icon styling
|
|
501
|
-
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
501
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
502
502
|
],
|
|
503
503
|
className
|
|
504
504
|
)}
|
package/src/components/field.tsx
CHANGED
|
@@ -102,8 +102,8 @@ const fieldVariants = cva(
|
|
|
102
102
|
"has-[[data-state=checked]:not([role=switch])]:border-primary has-[[data-state=checked]:not([role=switch])]:bg-primary/10",
|
|
103
103
|
"dark:has-[[data-state=checked]:not([role=switch])]:bg-alpha-10",
|
|
104
104
|
// Error-state when inside an invalid container (e.g. RadioGroup with error)
|
|
105
|
-
"[[aria-invalid=true]_&]:border-
|
|
106
|
-
"[[aria-invalid=true]_&]:has-[:focus-visible]:border-destructive [[aria-invalid=true]_&]:has-[:focus-visible]:shadow-destructive",
|
|
105
|
+
"[[aria-invalid=true]_&]:border-destructive-40",
|
|
106
|
+
"[[aria-invalid=true]_&]:has-[:focus-visible]:border-destructive-40 [[aria-invalid=true]_&]:has-[:focus-visible]:shadow-destructive",
|
|
107
107
|
],
|
|
108
108
|
},
|
|
109
109
|
},
|
|
@@ -138,7 +138,9 @@ function Field({
|
|
|
138
138
|
<div
|
|
139
139
|
className={cn(
|
|
140
140
|
fieldVariants({ orientation, variant }),
|
|
141
|
-
align === "end" &&
|
|
141
|
+
align === "end" &&
|
|
142
|
+
orientation === "horizontal" &&
|
|
143
|
+
"grid-cols-[1fr_auto]",
|
|
142
144
|
className
|
|
143
145
|
)}
|
|
144
146
|
data-orientation={orientation}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
3
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
5
|
|
|
6
|
+
const headerVariants = cva("flex w-full items-center", {
|
|
7
|
+
variants: {
|
|
8
|
+
align: {
|
|
9
|
+
left: "justify-start",
|
|
10
|
+
center: "justify-center",
|
|
11
|
+
right: "justify-end",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
align: "left",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
5
19
|
/**
|
|
6
20
|
* Header provides a semantic header container for top-level page navigation.
|
|
7
21
|
*
|
|
@@ -28,6 +42,10 @@ interface HeaderProps extends React.ComponentProps<"header"> {
|
|
|
28
42
|
* Data hook for automated testing (required)
|
|
29
43
|
*/
|
|
30
44
|
dataHook: string;
|
|
45
|
+
/**
|
|
46
|
+
* Content alignment: "left" (default), "center", or "right"
|
|
47
|
+
*/
|
|
48
|
+
align?: "left" | "center" | "right";
|
|
31
49
|
/**
|
|
32
50
|
* Tracking element identifier for analytics
|
|
33
51
|
*/
|
|
@@ -43,13 +61,21 @@ interface HeaderProps extends React.ComponentProps<"header"> {
|
|
|
43
61
|
*/
|
|
44
62
|
const Header = React.forwardRef<HTMLElement, HeaderProps>(
|
|
45
63
|
(
|
|
46
|
-
{
|
|
64
|
+
{
|
|
65
|
+
className,
|
|
66
|
+
dataHook,
|
|
67
|
+
align = "left",
|
|
68
|
+
trackingEl,
|
|
69
|
+
trackingLabel,
|
|
70
|
+
children,
|
|
71
|
+
...props
|
|
72
|
+
},
|
|
47
73
|
ref
|
|
48
74
|
) => {
|
|
49
75
|
return (
|
|
50
76
|
<header
|
|
51
77
|
ref={ref}
|
|
52
|
-
className={cn(
|
|
78
|
+
className={cn(headerVariants({ align }), className)}
|
|
53
79
|
data-hook={dataHook}
|
|
54
80
|
data-slot="header"
|
|
55
81
|
data-tracking-el={trackingEl}
|
|
@@ -200,8 +200,8 @@ const inputChipInputVariants = cva(
|
|
|
200
200
|
variants: {
|
|
201
201
|
error: {
|
|
202
202
|
true: [
|
|
203
|
-
"border-
|
|
204
|
-
"has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive",
|
|
203
|
+
"border-destructive-40",
|
|
204
|
+
"has-[:focus-visible]:border-destructive-40 has-[:focus-visible]:shadow-destructive",
|
|
205
205
|
],
|
|
206
206
|
false: "",
|
|
207
207
|
},
|
|
@@ -8,7 +8,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
8
8
|
import { Input, type InputProps } from "./input";
|
|
9
9
|
|
|
10
10
|
const inputGroupVariants = cva(
|
|
11
|
-
"relative flex w-full items-center
|
|
11
|
+
"relative flex w-full items-center rounded-md border border-input bg-background transition-colors has-[input:focus-visible]:border-ring has-[input:focus-visible]:shadow-default has-[:disabled]:opacity-50",
|
|
12
12
|
{
|
|
13
13
|
variants: {
|
|
14
14
|
size: {
|
|
@@ -18,8 +18,8 @@ const inputGroupVariants = cva(
|
|
|
18
18
|
},
|
|
19
19
|
error: {
|
|
20
20
|
true: [
|
|
21
|
-
"border-
|
|
22
|
-
"has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive",
|
|
21
|
+
"border-destructive-40",
|
|
22
|
+
"has-[input:focus-visible]:border-destructive-40 has-[input:focus-visible]:shadow-destructive",
|
|
23
23
|
],
|
|
24
24
|
false: "",
|
|
25
25
|
},
|
|
@@ -138,7 +138,7 @@ const inputGroupButtonVariants = cva(
|
|
|
138
138
|
[
|
|
139
139
|
"inline-flex items-center justify-center gap-2",
|
|
140
140
|
"text-sm font-medium transition-colors",
|
|
141
|
-
"
|
|
141
|
+
"outline-none focus-visible:shadow-default rounded-sm",
|
|
142
142
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
143
143
|
"text-muted-foreground hover:text-foreground",
|
|
144
144
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
@@ -143,8 +143,9 @@ function InputOTPSlot({ index, className, ...props }: InputOTPSlotProps) {
|
|
|
143
143
|
"data-[active=true]:border-ring data-[active=true]:z-10",
|
|
144
144
|
"data-[active=true]:shadow-default",
|
|
145
145
|
// Error state
|
|
146
|
-
error && "border-destructive",
|
|
147
|
-
error &&
|
|
146
|
+
error && "border-destructive-40",
|
|
147
|
+
error &&
|
|
148
|
+
"data-[active=true]:border-destructive-40 data-[active=true]:shadow-destructive",
|
|
148
149
|
// Dark mode
|
|
149
150
|
"dark:bg-input/30",
|
|
150
151
|
className
|
|
@@ -182,7 +183,10 @@ function InputOTPSeparator({ ...props }: InputOTPSeparatorProps) {
|
|
|
182
183
|
* Variant Components (Convenience wrappers)
|
|
183
184
|
* -----------------------------------------------------------------------------------------------*/
|
|
184
185
|
|
|
185
|
-
interface InputOTPVariantProps extends Omit<
|
|
186
|
+
interface InputOTPVariantProps extends Omit<
|
|
187
|
+
InputOTPProps,
|
|
188
|
+
"children" | "maxLength"
|
|
189
|
+
> {
|
|
186
190
|
/** Number of OTP digits */
|
|
187
191
|
maxLength?: number;
|
|
188
192
|
}
|
|
@@ -311,7 +311,13 @@ function InputPasswordRoot<T extends string = DefaultPasswordStrength>({
|
|
|
311
311
|
|
|
312
312
|
return (
|
|
313
313
|
<InputPasswordContext.Provider value={contextValue}>
|
|
314
|
-
<div
|
|
314
|
+
<div
|
|
315
|
+
className={cn("w-full", className)}
|
|
316
|
+
data-hook={dataHook}
|
|
317
|
+
data-slot="input-password"
|
|
318
|
+
>
|
|
319
|
+
{children}
|
|
320
|
+
</div>
|
|
315
321
|
</InputPasswordContext.Provider>
|
|
316
322
|
);
|
|
317
323
|
}
|
|
@@ -377,7 +383,7 @@ const InputPasswordField = React.forwardRef<
|
|
|
377
383
|
aria-label={showPassword ? "Hide password" : "Show password"}
|
|
378
384
|
data-hook={`${dataHook}-toggle`}
|
|
379
385
|
disabled={disabled}
|
|
380
|
-
size="icon"
|
|
386
|
+
size="icon-sm"
|
|
381
387
|
variant="ghost"
|
|
382
388
|
onClick={toggleVisibility}
|
|
383
389
|
>
|
package/src/components/input.tsx
CHANGED
|
@@ -119,7 +119,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
119
119
|
className={cn(
|
|
120
120
|
inputVariants({ hasIcon, hasSecondaryIcon }),
|
|
121
121
|
hasError &&
|
|
122
|
-
"focus-visible:border-destructive focus-visible:shadow-destructive
|
|
122
|
+
"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",
|
|
123
123
|
className
|
|
124
124
|
)}
|
|
125
125
|
data-hook={dataHook}
|
package/src/components/label.tsx
CHANGED
|
@@ -40,10 +40,7 @@ interface LabelProps extends React.ComponentPropsWithoutRef<"label"> {
|
|
|
40
40
|
optional?: boolean;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const Label = React.forwardRef<
|
|
44
|
-
HTMLLabelElement,
|
|
45
|
-
LabelProps
|
|
46
|
-
>(
|
|
43
|
+
const Label = React.forwardRef<HTMLLabelElement, LabelProps>(
|
|
47
44
|
(
|
|
48
45
|
{
|
|
49
46
|
className,
|
package/src/components/link.tsx
CHANGED
|
@@ -24,10 +24,9 @@ const linkVariants = cva([
|
|
|
24
24
|
"duration-300",
|
|
25
25
|
"cursor-pointer",
|
|
26
26
|
// Focus state
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"focus-visible:
|
|
30
|
-
"focus-visible:ring-offset-2",
|
|
27
|
+
"rounded-sm",
|
|
28
|
+
"outline-none",
|
|
29
|
+
"focus-visible:shadow-default",
|
|
31
30
|
]);
|
|
32
31
|
|
|
33
32
|
export interface LinkProps
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
import { Skeleton } from "@brightlocal/ui-components/skeleton";
|
|
6
|
+
|
|
7
|
+
/* -------------------------------------------------------------------------------------------------
|
|
8
|
+
* Item variants
|
|
9
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
10
|
+
|
|
11
|
+
const itemVariants = cva(
|
|
12
|
+
[
|
|
13
|
+
"flex",
|
|
14
|
+
"items-center",
|
|
15
|
+
"gap-4",
|
|
16
|
+
"rounded-lg",
|
|
17
|
+
"py-2",
|
|
18
|
+
"pr-2",
|
|
19
|
+
"pl-4",
|
|
20
|
+
"transition-colors",
|
|
21
|
+
"duration-200",
|
|
22
|
+
"ease-out",
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
variant: {
|
|
27
|
+
filled: ["bg-card"],
|
|
28
|
+
outline: ["bg-background", "border", "border-border"],
|
|
29
|
+
loading: ["flex-col", "gap-2", "px-0", "pt-0", "pb-2"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: "filled",
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/* -------------------------------------------------------------------------------------------------
|
|
39
|
+
* List
|
|
40
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Props for the List root container.
|
|
44
|
+
* Extends native `<ul>` props with testing and analytics attributes.
|
|
45
|
+
*/
|
|
46
|
+
export type ListProps = React.ComponentProps<"ul"> & {
|
|
47
|
+
/**
|
|
48
|
+
* Data hook for automated testing (required).
|
|
49
|
+
*/
|
|
50
|
+
dataHook: string;
|
|
51
|
+
/**
|
|
52
|
+
* Tracking element identifier for analytics.
|
|
53
|
+
*/
|
|
54
|
+
trackingEl?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Tracking label for analytics context.
|
|
57
|
+
*/
|
|
58
|
+
trackingLabel?: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Vertical list container for rendering a collection of Item rows.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <List dataHook="keywords-list">
|
|
67
|
+
* <Item variant="filled" dataHook="item-1">
|
|
68
|
+
* <ItemContent>
|
|
69
|
+
* <ItemTitle>Keyword</ItemTitle>
|
|
70
|
+
* </ItemContent>
|
|
71
|
+
* <ItemActions>
|
|
72
|
+
* <Button variant="ghost" size="icon" dataHook="remove"><XIcon /></Button>
|
|
73
|
+
* </ItemActions>
|
|
74
|
+
* </Item>
|
|
75
|
+
* </List>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
const List = React.forwardRef<HTMLUListElement, ListProps>(
|
|
79
|
+
({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
|
|
80
|
+
<ul
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={cn("flex flex-col gap-2", className)}
|
|
83
|
+
data-hook={dataHook}
|
|
84
|
+
data-slot="list"
|
|
85
|
+
data-tracking-el={trackingEl}
|
|
86
|
+
data-tracking-label={trackingLabel}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
List.displayName = "List";
|
|
92
|
+
|
|
93
|
+
/* -------------------------------------------------------------------------------------------------
|
|
94
|
+
* Item
|
|
95
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Props for an individual Item row within a List.
|
|
99
|
+
* Extends native `<li>` props with CVA variant styling and optional testing/analytics attributes.
|
|
100
|
+
*/
|
|
101
|
+
export type ItemProps = React.ComponentProps<"li"> & {
|
|
102
|
+
/**
|
|
103
|
+
* Visual style of the item row.
|
|
104
|
+
* - `filled` — card background (default)
|
|
105
|
+
* - `outline` — bordered row on page background
|
|
106
|
+
* - `loading` — skeleton placeholder
|
|
107
|
+
* @default "filled"
|
|
108
|
+
*/
|
|
109
|
+
variant?: "filled" | "outline" | "loading";
|
|
110
|
+
/**
|
|
111
|
+
* Data hook for automated testing.
|
|
112
|
+
*/
|
|
113
|
+
dataHook?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Tracking element identifier for analytics.
|
|
116
|
+
*/
|
|
117
|
+
trackingEl?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Tracking label for analytics context.
|
|
120
|
+
*/
|
|
121
|
+
trackingLabel?: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Row component within a List. Supports `filled`, `outline`, and `loading` variants.
|
|
126
|
+
* Compose with ItemMedia, ItemContent, ItemTitle, ItemDescription, and ItemActions.
|
|
127
|
+
*/
|
|
128
|
+
const Item = React.forwardRef<HTMLLIElement, ItemProps>(
|
|
129
|
+
(
|
|
130
|
+
{
|
|
131
|
+
className,
|
|
132
|
+
variant,
|
|
133
|
+
dataHook,
|
|
134
|
+
trackingEl,
|
|
135
|
+
trackingLabel,
|
|
136
|
+
children,
|
|
137
|
+
...props
|
|
138
|
+
},
|
|
139
|
+
ref
|
|
140
|
+
) => (
|
|
141
|
+
<li
|
|
142
|
+
ref={ref}
|
|
143
|
+
className={cn(itemVariants({ variant }), className)}
|
|
144
|
+
data-hook={dataHook}
|
|
145
|
+
data-slot="item"
|
|
146
|
+
data-tracking-el={trackingEl}
|
|
147
|
+
data-tracking-label={trackingLabel}
|
|
148
|
+
{...props}
|
|
149
|
+
>
|
|
150
|
+
{variant === "loading" ? (
|
|
151
|
+
<>
|
|
152
|
+
<Skeleton className="h-4 w-full" />
|
|
153
|
+
<Skeleton className="h-4 w-full" />
|
|
154
|
+
</>
|
|
155
|
+
) : (
|
|
156
|
+
children
|
|
157
|
+
)}
|
|
158
|
+
</li>
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
Item.displayName = "Item";
|
|
162
|
+
|
|
163
|
+
/* -------------------------------------------------------------------------------------------------
|
|
164
|
+
* ItemMedia
|
|
165
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
166
|
+
|
|
167
|
+
/** Props for the ItemMedia sub-component — optional left-side media slot. */
|
|
168
|
+
export type ItemMediaProps = React.ComponentProps<"div">;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Optional left-side media slot for icons or avatars.
|
|
172
|
+
*/
|
|
173
|
+
const ItemMedia = React.forwardRef<HTMLDivElement, ItemMediaProps>(
|
|
174
|
+
({ className, ...props }, ref) => (
|
|
175
|
+
<div
|
|
176
|
+
ref={ref}
|
|
177
|
+
className={cn("shrink-0", className)}
|
|
178
|
+
data-slot="item-media"
|
|
179
|
+
{...props}
|
|
180
|
+
/>
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
ItemMedia.displayName = "ItemMedia";
|
|
184
|
+
|
|
185
|
+
/* -------------------------------------------------------------------------------------------------
|
|
186
|
+
* ItemContent
|
|
187
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
188
|
+
|
|
189
|
+
/** Props for the ItemContent sub-component — flexible content area within an Item. */
|
|
190
|
+
export type ItemContentProps = React.ComponentProps<"div">;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Flexible content area that grows to fill available space.
|
|
194
|
+
* Place ItemTitle and ItemDescription inside.
|
|
195
|
+
*/
|
|
196
|
+
const ItemContent = React.forwardRef<HTMLDivElement, ItemContentProps>(
|
|
197
|
+
({ className, ...props }, ref) => (
|
|
198
|
+
<div
|
|
199
|
+
ref={ref}
|
|
200
|
+
className={cn("flex flex-1 flex-col gap-1", className)}
|
|
201
|
+
data-slot="item-content"
|
|
202
|
+
{...props}
|
|
203
|
+
/>
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
ItemContent.displayName = "ItemContent";
|
|
207
|
+
|
|
208
|
+
/* -------------------------------------------------------------------------------------------------
|
|
209
|
+
* ItemTitle
|
|
210
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
211
|
+
|
|
212
|
+
/** Props for the ItemTitle sub-component — primary text label within an Item. */
|
|
213
|
+
export type ItemTitleProps = React.ComponentProps<"div">;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Primary text label within an Item.
|
|
217
|
+
*/
|
|
218
|
+
const ItemTitle = React.forwardRef<HTMLDivElement, ItemTitleProps>(
|
|
219
|
+
({ className, ...props }, ref) => (
|
|
220
|
+
<div
|
|
221
|
+
ref={ref}
|
|
222
|
+
className={cn("text-foreground text-lg font-medium", className)}
|
|
223
|
+
data-slot="item-title"
|
|
224
|
+
{...props}
|
|
225
|
+
/>
|
|
226
|
+
)
|
|
227
|
+
);
|
|
228
|
+
ItemTitle.displayName = "ItemTitle";
|
|
229
|
+
|
|
230
|
+
/* -------------------------------------------------------------------------------------------------
|
|
231
|
+
* ItemDescription
|
|
232
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
233
|
+
|
|
234
|
+
/** Props for the ItemDescription sub-component — supporting text beneath ItemTitle. */
|
|
235
|
+
export type ItemDescriptionProps = React.ComponentProps<"div">;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Supporting description text beneath ItemTitle.
|
|
239
|
+
*/
|
|
240
|
+
const ItemDescription = React.forwardRef<HTMLDivElement, ItemDescriptionProps>(
|
|
241
|
+
({ className, ...props }, ref) => (
|
|
242
|
+
<div
|
|
243
|
+
ref={ref}
|
|
244
|
+
className={cn("text-muted-foreground text-base", className)}
|
|
245
|
+
data-slot="item-description"
|
|
246
|
+
{...props}
|
|
247
|
+
/>
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
ItemDescription.displayName = "ItemDescription";
|
|
251
|
+
|
|
252
|
+
/* -------------------------------------------------------------------------------------------------
|
|
253
|
+
* ItemActions
|
|
254
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
255
|
+
|
|
256
|
+
/** Props for the ItemActions sub-component — right-side slot for action controls. */
|
|
257
|
+
export type ItemActionsProps = React.ComponentProps<"div">;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Right-side slot for action controls such as remove buttons.
|
|
261
|
+
*/
|
|
262
|
+
const ItemActions = React.forwardRef<HTMLDivElement, ItemActionsProps>(
|
|
263
|
+
({ className, ...props }, ref) => (
|
|
264
|
+
<div
|
|
265
|
+
ref={ref}
|
|
266
|
+
className={cn(
|
|
267
|
+
"text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-full",
|
|
268
|
+
className
|
|
269
|
+
)}
|
|
270
|
+
data-slot="item-actions"
|
|
271
|
+
{...props}
|
|
272
|
+
/>
|
|
273
|
+
)
|
|
274
|
+
);
|
|
275
|
+
ItemActions.displayName = "ItemActions";
|
|
276
|
+
|
|
277
|
+
/* -------------------------------------------------------------------------------------------------
|
|
278
|
+
* Exports
|
|
279
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
280
|
+
|
|
281
|
+
export {
|
|
282
|
+
List,
|
|
283
|
+
Item,
|
|
284
|
+
ItemMedia,
|
|
285
|
+
ItemContent,
|
|
286
|
+
ItemTitle,
|
|
287
|
+
ItemDescription,
|
|
288
|
+
ItemActions,
|
|
289
|
+
itemVariants,
|
|
290
|
+
};
|