@brightlocal/ui-components 0.1.1 → 0.1.3
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.d.ts +74 -4
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +100 -105
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +30 -10
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +129 -132
- package/dist/alert.d.ts +22 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/aspect-ratio.cjs +1 -1
- package/dist/aspect-ratio.d.ts +11 -1
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/aspect-ratio.js +16 -20
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.d.ts +43 -3
- package/dist/avatar.d.ts.map +1 -1
- package/dist/avatar.js +18 -16
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +24 -9
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +34 -32
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +209 -202
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +154 -154
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +63 -8
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +97 -93
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +17 -45
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +49 -50
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +12 -0
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +10 -8
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +58 -18
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +60 -51
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +99 -9
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +142 -128
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +18 -2
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +46 -33
- package/dist/chart.cjs +4 -4
- package/dist/chart.d.ts +70 -7
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +71 -66
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts +9 -5
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +61 -82
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.d.ts +65 -8
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/collapsible.js +41 -55
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +29 -11
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +193 -159
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +115 -9
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +176 -152
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts +188 -20
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +119 -121
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +75 -9
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +220 -81
- package/dist/description.cjs +1 -0
- package/dist/description.d.ts +37 -0
- package/dist/description.d.ts.map +1 -0
- package/dist/description.js +25 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +73 -9
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +103 -112
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +92 -0
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +67 -52
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +95 -11
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +146 -106
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +23 -6
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +54 -53
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +27 -17
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +86 -79
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +36 -6
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +44 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +383 -387
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +21 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +51 -41
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +24 -25
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +38 -24
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +68 -136
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts +20 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +31 -18
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +3 -0
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +12 -10
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +40 -6
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +97 -76
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts +59 -4
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +42 -34
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +9 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +71 -59
- package/dist/radio-group.d.ts +40 -0
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/rating.d.ts +4 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +65 -4
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +53 -36
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +46 -5
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +42 -38
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +30 -0
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +64 -54
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +49 -2
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +48 -36
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +80 -9
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +117 -113
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +24 -2
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +15 -9
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +18 -4
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +72 -66
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +4 -2
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +29 -28
- package/dist/split-layout.d.ts +4 -1
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.js +1 -1
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.d.ts +3 -1
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +38 -36
- package/package.json +8 -2
- package/src/blocks/data-table.tsx +42 -32
- package/src/blocks/sidebar.tsx +4 -12
- package/src/components/accordion.tsx +163 -77
- package/src/components/alert-dialog.tsx +156 -111
- package/src/components/alert.tsx +26 -13
- package/src/components/aspect-ratio.tsx +25 -16
- package/src/components/avatar.tsx +56 -8
- package/src/components/badge.tsx +65 -42
- package/src/components/breadcrumb.tsx +158 -82
- package/src/components/button.tsx +41 -62
- package/src/components/calendar.tsx +16 -2
- package/src/components/card.tsx +92 -40
- package/src/components/carousel.tsx +240 -115
- package/src/components/centred-layout.tsx +67 -35
- package/src/components/chart.tsx +118 -47
- package/src/components/checkbox.tsx +42 -78
- package/src/components/collapsible.tsx +95 -26
- package/src/components/combobox.tsx +242 -144
- package/src/components/command.tsx +295 -121
- package/src/components/context-menu.tsx +278 -81
- package/src/components/date-picker.tsx +281 -30
- package/src/components/description.tsx +60 -0
- package/src/components/dialog.tsx +162 -86
- package/src/components/drawer.tsx +76 -2
- package/src/components/dropdown-menu.tsx +143 -37
- package/src/components/field.tsx +36 -11
- package/src/components/global-layout.tsx +116 -77
- package/src/components/hover-card.tsx +54 -14
- package/src/components/input-group.tsx +56 -18
- package/src/components/input-password.tsx +3 -4
- package/src/components/input.tsx +93 -186
- package/src/components/label.tsx +56 -15
- package/src/components/logo.tsx +3 -0
- package/src/components/menubar.tsx +58 -4
- package/src/components/popover.tsx +103 -20
- package/src/components/progress.tsx +82 -60
- package/src/components/radio-group.tsx +40 -0
- package/src/components/rating.tsx +4 -1
- package/src/components/resizable.tsx +119 -31
- package/src/components/scroll-area.tsx +123 -56
- package/src/components/select.tsx +21 -1
- package/src/components/separator.tsx +97 -20
- package/src/components/sheet.tsx +180 -79
- package/src/components/skeleton.tsx +40 -10
- package/src/components/slider.tsx +83 -57
- package/src/components/sonner.tsx +10 -7
- package/src/components/split-layout.tsx +4 -1
- package/src/components/table.tsx +1 -1
- package/src/components/toggle-group.tsx +4 -0
- package/src/index.ts +1 -1
- package/dist/input-base.cjs +0 -1
- package/dist/input-base.d.ts +0 -28
- package/dist/input-base.d.ts.map +0 -1
- package/dist/input-base.js +0 -56
- package/src/components/input-base.tsx +0 -86
|
@@ -4,6 +4,24 @@ import * as React from "react";
|
|
|
4
4
|
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
5
5
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* HoverCard props
|
|
9
|
+
*/
|
|
10
|
+
export interface HoverCardProps extends React.ComponentProps<
|
|
11
|
+
typeof HoverCardPrimitive.Root
|
|
12
|
+
> {
|
|
13
|
+
/**
|
|
14
|
+
* Time in milliseconds to delay opening the hover card
|
|
15
|
+
* @default 300
|
|
16
|
+
*/
|
|
17
|
+
openDelay?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Time in milliseconds to delay closing the hover card
|
|
20
|
+
* @default 300
|
|
21
|
+
*/
|
|
22
|
+
closeDelay?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
/**
|
|
8
26
|
* HoverCard - A component that displays content on hover
|
|
9
27
|
*
|
|
@@ -11,14 +29,14 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
11
29
|
* @see https://www.radix-ui.com/docs/primitives/components/hover-card
|
|
12
30
|
*
|
|
13
31
|
* Default timing:
|
|
14
|
-
* - openDelay:
|
|
15
|
-
* - closeDelay: 300ms
|
|
32
|
+
* - openDelay: 300ms
|
|
33
|
+
* - closeDelay: 300ms
|
|
16
34
|
*/
|
|
17
35
|
function HoverCard({
|
|
18
36
|
openDelay = 300,
|
|
19
37
|
closeDelay = 300,
|
|
20
38
|
...props
|
|
21
|
-
}:
|
|
39
|
+
}: HoverCardProps) {
|
|
22
40
|
// Note: HoverCardPrimitive.Root is a context provider that doesn't render to DOM
|
|
23
41
|
// Data attributes should be placed on HoverCardContent instead
|
|
24
42
|
return (
|
|
@@ -30,44 +48,66 @@ function HoverCard({
|
|
|
30
48
|
);
|
|
31
49
|
}
|
|
32
50
|
|
|
51
|
+
HoverCard.displayName = "HoverCard";
|
|
52
|
+
|
|
33
53
|
export interface HoverCardTriggerProps extends React.ComponentProps<
|
|
34
54
|
typeof HoverCardPrimitive.Trigger
|
|
35
55
|
> {
|
|
56
|
+
/**
|
|
57
|
+
* Data hook for automated testing
|
|
58
|
+
*/
|
|
59
|
+
dataHook?: string;
|
|
36
60
|
/**
|
|
37
61
|
* Whether the trigger is disabled
|
|
38
62
|
*/
|
|
39
63
|
disabled?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Optional analytics element identifier
|
|
66
|
+
*/
|
|
67
|
+
trackingEl?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Optional analytics label context
|
|
70
|
+
*/
|
|
71
|
+
trackingLabel?: string;
|
|
40
72
|
}
|
|
41
73
|
|
|
42
74
|
/**
|
|
43
75
|
* HoverCardTrigger - The element that triggers the hover card
|
|
44
76
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
77
|
+
const HoverCardTrigger = React.forwardRef<
|
|
78
|
+
React.ElementRef<typeof HoverCardPrimitive.Trigger>,
|
|
79
|
+
HoverCardTriggerProps
|
|
80
|
+
>(
|
|
81
|
+
(
|
|
82
|
+
{ className, disabled, dataHook, trackingEl, trackingLabel, ...props },
|
|
83
|
+
ref
|
|
84
|
+
) => (
|
|
51
85
|
<HoverCardPrimitive.Trigger
|
|
86
|
+
ref={ref}
|
|
52
87
|
aria-disabled={disabled}
|
|
53
88
|
className={cn(
|
|
54
89
|
"text-link cursor-pointer text-sm leading-5 font-medium underline",
|
|
55
90
|
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
56
91
|
className
|
|
57
92
|
)}
|
|
93
|
+
data-hook={dataHook}
|
|
58
94
|
data-slot="hover-card-trigger"
|
|
95
|
+
data-tracking-el={trackingEl}
|
|
96
|
+
data-tracking-label={trackingLabel}
|
|
59
97
|
{...props}
|
|
60
98
|
/>
|
|
61
|
-
)
|
|
62
|
-
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
HoverCardTrigger.displayName = "HoverCardTrigger";
|
|
63
103
|
|
|
64
104
|
export interface HoverCardContentProps extends React.ComponentPropsWithoutRef<
|
|
65
105
|
typeof HoverCardPrimitive.Content
|
|
66
106
|
> {
|
|
67
107
|
/**
|
|
68
|
-
*
|
|
108
|
+
* Data hook for automated testing
|
|
69
109
|
*/
|
|
70
|
-
dataHook
|
|
110
|
+
dataHook?: string;
|
|
71
111
|
/**
|
|
72
112
|
* Optional analytics element identifier
|
|
73
113
|
*/
|
|
@@ -116,6 +156,6 @@ const HoverCardContent = React.forwardRef<
|
|
|
116
156
|
</HoverCardPrimitive.Portal>
|
|
117
157
|
)
|
|
118
158
|
);
|
|
119
|
-
HoverCardContent.displayName =
|
|
159
|
+
HoverCardContent.displayName = "HoverCardContent";
|
|
120
160
|
|
|
121
161
|
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
|
@@ -5,7 +5,7 @@ import { Slot } from "@radix-ui/react-slot";
|
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
|
-
import {
|
|
8
|
+
import { Input, type InputProps } from "./input";
|
|
9
9
|
|
|
10
10
|
const inputGroupVariants = cva(
|
|
11
11
|
"relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",
|
|
@@ -26,14 +26,31 @@ const inputGroupVariants = cva(
|
|
|
26
26
|
interface InputGroupProps
|
|
27
27
|
extends
|
|
28
28
|
React.HTMLAttributes<HTMLDivElement>,
|
|
29
|
-
VariantProps<typeof inputGroupVariants> {
|
|
29
|
+
VariantProps<typeof inputGroupVariants> {
|
|
30
|
+
/**
|
|
31
|
+
* Data hook for automated testing (REQUIRED)
|
|
32
|
+
*/
|
|
33
|
+
dataHook: string;
|
|
34
|
+
/**
|
|
35
|
+
* Tracking element identifier for analytics
|
|
36
|
+
*/
|
|
37
|
+
trackingEl?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Tracking label for analytics context
|
|
40
|
+
*/
|
|
41
|
+
trackingLabel?: string;
|
|
42
|
+
}
|
|
30
43
|
|
|
31
44
|
const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
32
|
-
({ className, size, ...props }, ref) => {
|
|
45
|
+
({ className, size, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
33
46
|
return (
|
|
34
47
|
<div
|
|
35
48
|
ref={ref}
|
|
36
49
|
className={cn(inputGroupVariants({ size }), className)}
|
|
50
|
+
data-hook={dataHook}
|
|
51
|
+
data-slot="input-group"
|
|
52
|
+
data-tracking-el={trackingEl}
|
|
53
|
+
data-tracking-label={trackingLabel}
|
|
37
54
|
{...props}
|
|
38
55
|
/>
|
|
39
56
|
);
|
|
@@ -41,12 +58,17 @@ const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
|
41
58
|
);
|
|
42
59
|
InputGroup.displayName = "InputGroup";
|
|
43
60
|
|
|
61
|
+
type InputGroupInputProps = Omit<
|
|
62
|
+
InputProps,
|
|
63
|
+
"hasIcon" | "hasSecondaryIcon" | "dataHook"
|
|
64
|
+
>;
|
|
65
|
+
|
|
44
66
|
const InputGroupInput = React.forwardRef<
|
|
45
67
|
HTMLInputElement,
|
|
46
|
-
|
|
68
|
+
InputGroupInputProps
|
|
47
69
|
>(({ className, ...props }, ref) => {
|
|
48
70
|
return (
|
|
49
|
-
<
|
|
71
|
+
<Input
|
|
50
72
|
ref={ref}
|
|
51
73
|
className={cn(
|
|
52
74
|
// Override border and focus styles since InputGroup handles them
|
|
@@ -54,25 +76,29 @@ const InputGroupInput = React.forwardRef<
|
|
|
54
76
|
"h-full",
|
|
55
77
|
className
|
|
56
78
|
)}
|
|
79
|
+
dataHook="input-group-input"
|
|
57
80
|
{...props}
|
|
58
81
|
/>
|
|
59
82
|
);
|
|
60
83
|
});
|
|
61
84
|
InputGroupInput.displayName = "InputGroupInput";
|
|
62
85
|
|
|
63
|
-
const inputGroupAddonVariants = cva(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
const inputGroupAddonVariants = cva(
|
|
87
|
+
"flex shrink-0 items-center text-muted-foreground",
|
|
88
|
+
{
|
|
89
|
+
variants: {
|
|
90
|
+
align: {
|
|
91
|
+
"inline-start": "",
|
|
92
|
+
"inline-end": "ml-auto",
|
|
93
|
+
"block-start": "self-start",
|
|
94
|
+
"block-end": "self-end",
|
|
95
|
+
},
|
|
70
96
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
97
|
+
defaultVariants: {
|
|
98
|
+
align: "inline-start",
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
);
|
|
76
102
|
|
|
77
103
|
interface InputGroupAddonProps
|
|
78
104
|
extends
|
|
@@ -85,6 +111,7 @@ const InputGroupAddon = React.forwardRef<HTMLDivElement, InputGroupAddonProps>(
|
|
|
85
111
|
<div
|
|
86
112
|
ref={ref}
|
|
87
113
|
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
114
|
+
data-slot="input-group-addon"
|
|
88
115
|
{...props}
|
|
89
116
|
/>
|
|
90
117
|
);
|
|
@@ -129,6 +156,11 @@ interface InputGroupButtonProps
|
|
|
129
156
|
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
130
157
|
VariantProps<typeof inputGroupButtonVariants> {
|
|
131
158
|
asChild?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Size variant for the button.
|
|
161
|
+
* Options: "default" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg"
|
|
162
|
+
*/
|
|
163
|
+
size?: NonNullable<VariantProps<typeof inputGroupButtonVariants>["size"]>;
|
|
132
164
|
}
|
|
133
165
|
|
|
134
166
|
const InputGroupButton = React.forwardRef<
|
|
@@ -140,6 +172,7 @@ const InputGroupButton = React.forwardRef<
|
|
|
140
172
|
<Comp
|
|
141
173
|
ref={ref}
|
|
142
174
|
className={cn(inputGroupButtonVariants({ variant, size, className }))}
|
|
175
|
+
data-slot="input-group-button"
|
|
143
176
|
type={asChild ? undefined : "button"}
|
|
144
177
|
{...props}
|
|
145
178
|
/>
|
|
@@ -155,4 +188,9 @@ export {
|
|
|
155
188
|
inputGroupVariants,
|
|
156
189
|
inputGroupButtonVariants,
|
|
157
190
|
};
|
|
158
|
-
export type {
|
|
191
|
+
export type {
|
|
192
|
+
InputGroupProps,
|
|
193
|
+
InputGroupInputProps,
|
|
194
|
+
InputGroupAddonProps,
|
|
195
|
+
InputGroupButtonProps,
|
|
196
|
+
};
|
|
@@ -129,13 +129,12 @@ const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
|
|
|
129
129
|
|
|
130
130
|
return (
|
|
131
131
|
<div className="w-full">
|
|
132
|
-
<InputGroup className={className}>
|
|
132
|
+
<InputGroup className={className} dataHook={dataHook}>
|
|
133
133
|
<InputGroupInput
|
|
134
134
|
ref={ref}
|
|
135
|
-
data-hook={dataHook}
|
|
136
|
-
data-tracking-el={trackingEl}
|
|
137
|
-
data-tracking-label={trackingLabel}
|
|
138
135
|
id={inputId}
|
|
136
|
+
trackingEl={trackingEl}
|
|
137
|
+
trackingLabel={trackingLabel}
|
|
139
138
|
type={showPassword ? "text" : "password"}
|
|
140
139
|
value={value}
|
|
141
140
|
onChange={handleChange}
|
package/src/components/input.tsx
CHANGED
|
@@ -1,220 +1,127 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { cva } from "class-variance-authority";
|
|
5
|
-
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
5
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
-
import { Label } from "@brightlocal/ui-components/label";
|
|
8
|
-
import { BaseInputElement } from "@brightlocal/ui-components/input-base";
|
|
9
|
-
|
|
10
|
-
enum InputLayout {
|
|
11
|
-
VERTICAL = "vertical",
|
|
12
|
-
HORIZONTAL = "horizontal",
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enum InputState {
|
|
16
|
-
NORMAL = "normal",
|
|
17
|
-
}
|
|
18
6
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Shared input variant styles
|
|
9
|
+
* These can be reused across different input components
|
|
10
|
+
*/
|
|
11
|
+
export const inputVariants = cva(
|
|
12
|
+
[
|
|
13
|
+
// Layout & Size
|
|
14
|
+
"flex w-full min-w-0 h-9",
|
|
15
|
+
// Appearance
|
|
16
|
+
"border border-input bg-background rounded-sm",
|
|
17
|
+
"outline-none transition-all",
|
|
18
|
+
// Typography
|
|
19
|
+
"text-sm font-sans",
|
|
20
|
+
"text-foreground",
|
|
21
|
+
"overflow-hidden text-ellipsis",
|
|
22
|
+
// States - Focus
|
|
23
|
+
"focus-visible:outline-none focus-visible:border-ring focus-visible:bg-background",
|
|
24
|
+
"focus-visible:shadow-default",
|
|
25
|
+
// States - Disabled
|
|
26
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
27
|
+
// Pseudo-elements
|
|
28
|
+
"placeholder:text-muted-foreground",
|
|
29
|
+
"placeholder:overflow-hidden placeholder:text-ellipsis",
|
|
30
|
+
// Text input alignment - uses design token for text/sm line-height (20px)
|
|
31
|
+
"items-center px-3 pb-[1px] leading-5",
|
|
32
|
+
// Hide default browser icons for date/time inputs
|
|
33
|
+
"[&::-webkit-calendar-picker-indicator]:hidden",
|
|
34
|
+
],
|
|
35
|
+
{
|
|
36
|
+
variants: {
|
|
37
|
+
hasIcon: {
|
|
38
|
+
true: "pl-9",
|
|
39
|
+
false: "",
|
|
40
|
+
},
|
|
41
|
+
hasSecondaryIcon: {
|
|
42
|
+
true: "pr-9",
|
|
43
|
+
false: "",
|
|
44
|
+
},
|
|
23
45
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const linkVariants = cva([
|
|
31
|
-
"block text-sm font-normal leading-none text-muted-foreground font-sans mb-2",
|
|
32
|
-
"text-foreground hover:text-green-900",
|
|
33
|
-
"underline transition-colors cursor-pointer",
|
|
34
|
-
]);
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
hasIcon: false,
|
|
48
|
+
hasSecondaryIcon: false,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
);
|
|
35
52
|
|
|
36
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Simple styled input element
|
|
55
|
+
*
|
|
56
|
+
* For inputs with label/description, compose with Field, FieldLabel, FieldDescription:
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <Field>
|
|
59
|
+
* <FieldLabel htmlFor="email">Email</FieldLabel>
|
|
60
|
+
* <Input id="email" placeholder="Enter email" dataHook="email-input" />
|
|
61
|
+
* <FieldDescription>We'll never share your email</FieldDescription>
|
|
62
|
+
* </Field>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* For decorative icons, use InputGroup:
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <InputGroup>
|
|
68
|
+
* <InputGroupAddon><SearchIcon /></InputGroupAddon>
|
|
69
|
+
* <InputGroupInput placeholder="Search..." />
|
|
70
|
+
* </InputGroup>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export interface InputProps
|
|
74
|
+
extends
|
|
75
|
+
Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
|
|
76
|
+
VariantProps<typeof inputVariants> {
|
|
37
77
|
/**
|
|
38
|
-
*
|
|
39
|
-
* If not provided, use aria-label for accessibility.
|
|
78
|
+
* Required data-hook attribute for automated testing
|
|
40
79
|
*/
|
|
41
|
-
label?: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
link?: {
|
|
44
|
-
text: string & { length: 1 }; // Ensures non-empty string
|
|
45
|
-
href?: string;
|
|
46
|
-
onClick?: () => void;
|
|
47
|
-
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
48
|
-
};
|
|
49
80
|
dataHook: string;
|
|
50
|
-
|
|
51
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Optional tracking element identifier for analytics
|
|
83
|
+
*/
|
|
52
84
|
trackingEl?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional tracking label for analytics context
|
|
87
|
+
*/
|
|
53
88
|
trackingLabel?: string;
|
|
54
|
-
icon?: React.ReactNode;
|
|
55
|
-
secondaryIcon?: React.ReactNode;
|
|
56
89
|
}
|
|
57
90
|
|
|
58
|
-
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
91
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
59
92
|
(
|
|
60
93
|
{
|
|
61
94
|
className,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
description,
|
|
65
|
-
link,
|
|
66
|
-
icon,
|
|
67
|
-
secondaryIcon,
|
|
68
|
-
optional,
|
|
69
|
-
layout = InputLayout.VERTICAL,
|
|
95
|
+
hasIcon = false,
|
|
96
|
+
hasSecondaryIcon = false,
|
|
70
97
|
dataHook,
|
|
71
98
|
trackingEl,
|
|
72
99
|
trackingLabel,
|
|
73
|
-
id,
|
|
74
100
|
...props
|
|
75
101
|
},
|
|
76
102
|
ref
|
|
77
103
|
) => {
|
|
78
|
-
const generatedId = React.useId();
|
|
79
|
-
const inputId = id || generatedId;
|
|
80
|
-
const descriptionId = `${inputId}-description`;
|
|
81
|
-
|
|
82
104
|
// Check for error state from aria-invalid attribute
|
|
83
|
-
const
|
|
105
|
+
const hasError =
|
|
84
106
|
props["aria-invalid"] === true || props["aria-invalid"] === "true";
|
|
85
107
|
|
|
86
|
-
const inputElement = (
|
|
87
|
-
<div className="relative flex items-center">
|
|
88
|
-
{icon && (
|
|
89
|
-
<div
|
|
90
|
-
className={cn(
|
|
91
|
-
"text-muted-foreground pointer-events-none absolute left-3 flex items-center",
|
|
92
|
-
props.disabled && "opacity-50"
|
|
93
|
-
)}
|
|
94
|
-
>
|
|
95
|
-
{icon}
|
|
96
|
-
</div>
|
|
97
|
-
)}
|
|
98
|
-
<BaseInputElement
|
|
99
|
-
ref={ref}
|
|
100
|
-
aria-label={!label ? props["aria-label"] : undefined}
|
|
101
|
-
className={cn(
|
|
102
|
-
hasErrorStyling &&
|
|
103
|
-
"border-destructive dark:border-destructive focus-visible:border-destructive focus-visible:shadow-destructive",
|
|
104
|
-
type === "time" &&
|
|
105
|
-
"appearance-none [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none",
|
|
106
|
-
className
|
|
107
|
-
)}
|
|
108
|
-
data-hook={dataHook}
|
|
109
|
-
data-tracking-el={trackingEl}
|
|
110
|
-
data-tracking-label={trackingLabel}
|
|
111
|
-
hasIcon={!!icon}
|
|
112
|
-
hasSecondaryIcon={!!secondaryIcon}
|
|
113
|
-
id={inputId}
|
|
114
|
-
type={type}
|
|
115
|
-
{...props}
|
|
116
|
-
/>
|
|
117
|
-
{secondaryIcon && (
|
|
118
|
-
<div
|
|
119
|
-
className={cn(
|
|
120
|
-
"text-muted-foreground pointer-events-none absolute right-3 flex items-center",
|
|
121
|
-
props.disabled && "opacity-50"
|
|
122
|
-
)}
|
|
123
|
-
>
|
|
124
|
-
{secondaryIcon}
|
|
125
|
-
</div>
|
|
126
|
-
)}
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const labelElement = label && (
|
|
131
|
-
<Label
|
|
132
|
-
className={cn(layout === InputLayout.VERTICAL && "mb-2")}
|
|
133
|
-
data-hook={dataHook ? `${dataHook}-label` : undefined}
|
|
134
|
-
htmlFor={inputId}
|
|
135
|
-
optional={optional}
|
|
136
|
-
>
|
|
137
|
-
{label}
|
|
138
|
-
</Label>
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const descriptionElement = description && (
|
|
142
|
-
<div
|
|
143
|
-
className={cn(
|
|
144
|
-
descriptionStates({
|
|
145
|
-
state: InputState.NORMAL,
|
|
146
|
-
}),
|
|
147
|
-
layout === InputLayout.HORIZONTAL && "mt-2"
|
|
148
|
-
)}
|
|
149
|
-
data-hook={dataHook ? `${dataHook}-${"description"}` : undefined}
|
|
150
|
-
id={descriptionId}
|
|
151
|
-
>
|
|
152
|
-
{description}
|
|
153
|
-
</div>
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const linkText = link?.text?.trim();
|
|
157
|
-
const linkElement = linkText && (
|
|
158
|
-
<div>
|
|
159
|
-
{link?.href ? (
|
|
160
|
-
<a
|
|
161
|
-
className={linkVariants()}
|
|
162
|
-
data-hook={dataHook ? `${dataHook}-link` : undefined}
|
|
163
|
-
href={link.href}
|
|
164
|
-
target={link.target}
|
|
165
|
-
{...(link.target === "_blank" && {
|
|
166
|
-
rel: "noopener noreferrer",
|
|
167
|
-
})}
|
|
168
|
-
>
|
|
169
|
-
{linkText}
|
|
170
|
-
</a>
|
|
171
|
-
) : linkText ? (
|
|
172
|
-
<button
|
|
173
|
-
aria-label={linkText}
|
|
174
|
-
className={linkVariants()}
|
|
175
|
-
data-hook={dataHook ? `${dataHook}-link` : undefined}
|
|
176
|
-
type="button"
|
|
177
|
-
onClick={link?.onClick}
|
|
178
|
-
>
|
|
179
|
-
{linkText}
|
|
180
|
-
</button>
|
|
181
|
-
) : null}
|
|
182
|
-
</div>
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
if (layout === InputLayout.HORIZONTAL) {
|
|
186
|
-
return (
|
|
187
|
-
<div className="flex items-start gap-4">
|
|
188
|
-
<div className="flex h-9 flex-shrink-0 items-center">
|
|
189
|
-
{labelElement}
|
|
190
|
-
</div>
|
|
191
|
-
<div className="flex-1">
|
|
192
|
-
{inputElement}
|
|
193
|
-
{descriptionElement}
|
|
194
|
-
</div>
|
|
195
|
-
</div>
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
108
|
return (
|
|
200
|
-
<
|
|
201
|
-
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
labelElement
|
|
109
|
+
<input
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn(
|
|
112
|
+
inputVariants({ hasIcon, hasSecondaryIcon }),
|
|
113
|
+
hasError &&
|
|
114
|
+
"border-destructive dark:border-destructive focus-visible:border-destructive focus-visible:shadow-destructive",
|
|
115
|
+
className
|
|
208
116
|
)}
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
117
|
+
data-hook={dataHook}
|
|
118
|
+
data-slot="input"
|
|
119
|
+
data-tracking-el={trackingEl}
|
|
120
|
+
data-tracking-label={trackingLabel}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
212
123
|
);
|
|
213
124
|
}
|
|
214
125
|
);
|
|
215
126
|
|
|
216
127
|
Input.displayName = "Input";
|
|
217
|
-
|
|
218
|
-
export { Input, InputLayout };
|
|
219
|
-
|
|
220
|
-
export type { InputProps };
|
package/src/components/label.tsx
CHANGED
|
@@ -18,24 +18,65 @@ const labelVariants = cva(
|
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
interface LabelProps extends React.ComponentProps<typeof LabelPrimitive.Root> {
|
|
21
|
+
/**
|
|
22
|
+
* Data hook for automated testing
|
|
23
|
+
* Used to identify component in tests and E2E automation
|
|
24
|
+
*/
|
|
25
|
+
dataHook?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Tracking element identifier for analytics
|
|
28
|
+
* Defaults to "label" if not provided
|
|
29
|
+
*/
|
|
30
|
+
trackingEl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Tracking label for analytics context
|
|
33
|
+
* Additional context for tracking events
|
|
34
|
+
*/
|
|
35
|
+
trackingLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Display "(optional)" suffix after label text
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
21
40
|
optional?: boolean;
|
|
22
41
|
}
|
|
23
42
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
const Label = React.forwardRef<
|
|
44
|
+
React.ComponentRef<typeof LabelPrimitive.Root>,
|
|
45
|
+
LabelProps
|
|
46
|
+
>(
|
|
47
|
+
(
|
|
48
|
+
{
|
|
49
|
+
className,
|
|
50
|
+
optional,
|
|
51
|
+
dataHook,
|
|
52
|
+
trackingEl,
|
|
53
|
+
trackingLabel,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
56
|
+
},
|
|
57
|
+
ref
|
|
58
|
+
) => {
|
|
59
|
+
return (
|
|
60
|
+
<LabelPrimitive.Root
|
|
61
|
+
ref={ref}
|
|
62
|
+
className={cn(
|
|
63
|
+
"flex items-center select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
64
|
+
labelVariants({ optional }),
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
data-hook={dataHook}
|
|
68
|
+
data-slot="label"
|
|
69
|
+
data-tracking-el={trackingEl || "label"}
|
|
70
|
+
data-tracking-label={trackingLabel}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</LabelPrimitive.Root>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
Label.displayName = "Label";
|
|
39
80
|
|
|
40
81
|
export { Label, labelVariants };
|
|
41
82
|
|
package/src/components/logo.tsx
CHANGED
|
@@ -49,6 +49,7 @@ function Logo({
|
|
|
49
49
|
aria-label="BrightLocal Logo"
|
|
50
50
|
className={cn(logoVariants({ variant }), className)}
|
|
51
51
|
data-hook={dataHook}
|
|
52
|
+
data-slot="logo"
|
|
52
53
|
data-tracking-el={trackingEl}
|
|
53
54
|
data-tracking-label={trackingLabel}
|
|
54
55
|
role="img"
|
|
@@ -94,4 +95,6 @@ function Logo({
|
|
|
94
95
|
);
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
Logo.displayName = "Logo";
|
|
99
|
+
|
|
97
100
|
export { Logo };
|