@brightlocal/ui-components 0.1.4 → 0.2.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/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +75 -59
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +241 -191
- package/dist/index.cjs +1 -1
- package/dist/index.js +354 -344
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +5 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +47 -39
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +6 -0
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +79 -76
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +4 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +32 -31
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +26 -24
- package/dist/logo.cjs +1 -1
- package/dist/logo.js +13 -13
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +4 -0
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +49 -47
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +3 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +57 -56
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +19 -18
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +17 -17
- package/package.json +1 -1
- package/src/components/checkbox.tsx +4 -5
- package/src/components/combobox.tsx +482 -294
- package/src/components/input-group.tsx +14 -2
- package/src/components/input-otp.tsx +16 -1
- package/src/components/input-password.tsx +6 -1
- package/src/components/input.tsx +11 -3
- package/src/components/logo.tsx +1 -1
- package/src/components/radio-group.tsx +11 -0
- package/src/components/select.tsx +7 -2
- package/src/components/textarea.tsx +12 -5
- package/src/components/toggle.tsx +13 -15
|
@@ -16,9 +16,17 @@ const inputGroupVariants = cva(
|
|
|
16
16
|
sm: "h-8",
|
|
17
17
|
lg: "h-10",
|
|
18
18
|
},
|
|
19
|
+
error: {
|
|
20
|
+
true: [
|
|
21
|
+
"border-red-600/40 dark:border-red-400/60",
|
|
22
|
+
"has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive",
|
|
23
|
+
],
|
|
24
|
+
false: "",
|
|
25
|
+
},
|
|
19
26
|
},
|
|
20
27
|
defaultVariants: {
|
|
21
28
|
size: "default",
|
|
29
|
+
error: false,
|
|
22
30
|
},
|
|
23
31
|
}
|
|
24
32
|
);
|
|
@@ -39,14 +47,18 @@ interface InputGroupProps
|
|
|
39
47
|
* Tracking label for analytics context
|
|
40
48
|
*/
|
|
41
49
|
trackingLabel?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the input group has an error state
|
|
52
|
+
*/
|
|
53
|
+
error?: boolean;
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
45
|
-
({ className, size, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
57
|
+
({ className, size, error, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
46
58
|
return (
|
|
47
59
|
<div
|
|
48
60
|
ref={ref}
|
|
49
|
-
className={cn(inputGroupVariants({ size }), className)}
|
|
61
|
+
className={cn(inputGroupVariants({ size, error }), className)}
|
|
50
62
|
data-hook={dataHook}
|
|
51
63
|
data-slot="input-group"
|
|
52
64
|
data-tracking-el={trackingEl}
|
|
@@ -19,11 +19,13 @@ type InputOTPProps = React.ComponentProps<typeof OTPInput> & {
|
|
|
19
19
|
trackingEl?: string;
|
|
20
20
|
dataHook: string;
|
|
21
21
|
trackingLabel?: string;
|
|
22
|
+
/** Whether the input has an error state */
|
|
23
|
+
error?: boolean;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const InputOTP = React.forwardRef<HTMLInputElement, InputOTPProps>(
|
|
25
27
|
(
|
|
26
|
-
{ trackingEl, trackingLabel, dataHook, containerClassName, ...props },
|
|
28
|
+
{ trackingEl, trackingLabel, dataHook, containerClassName, error, ...props },
|
|
27
29
|
ref
|
|
28
30
|
) => {
|
|
29
31
|
// Ensure we always have an accessible label if none is provided
|
|
@@ -32,9 +34,16 @@ const InputOTP = React.forwardRef<HTMLInputElement, InputOTPProps>(
|
|
|
32
34
|
? "One-time password"
|
|
33
35
|
: props["aria-label"];
|
|
34
36
|
|
|
37
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
38
|
+
const hasError =
|
|
39
|
+
error ||
|
|
40
|
+
props["aria-invalid"] === true ||
|
|
41
|
+
props["aria-invalid"] === "true";
|
|
42
|
+
|
|
35
43
|
return (
|
|
36
44
|
<OTPInput
|
|
37
45
|
ref={ref}
|
|
46
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
38
47
|
aria-label={effectiveAriaLabel}
|
|
39
48
|
className="disabled:cursor-not-allowed"
|
|
40
49
|
containerClassName={cn(
|
|
@@ -132,6 +141,8 @@ interface InputOTPFieldProps {
|
|
|
132
141
|
disabled?: boolean;
|
|
133
142
|
className?: string;
|
|
134
143
|
"aria-label"?: string;
|
|
144
|
+
/** Whether the input has an error state */
|
|
145
|
+
error?: boolean;
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
const InputOTPField = React.forwardRef<HTMLInputElement, InputOTPFieldProps>(
|
|
@@ -144,6 +155,7 @@ const InputOTPField = React.forwardRef<HTMLInputElement, InputOTPFieldProps>(
|
|
|
144
155
|
trackingLabel,
|
|
145
156
|
containerClassName,
|
|
146
157
|
children,
|
|
158
|
+
error,
|
|
147
159
|
"aria-label": ariaLabel,
|
|
148
160
|
...props
|
|
149
161
|
},
|
|
@@ -172,6 +184,7 @@ const InputOTPField = React.forwardRef<HTMLInputElement, InputOTPFieldProps>(
|
|
|
172
184
|
aria-label={effectiveAriaLabel}
|
|
173
185
|
containerClassName={containerClassName}
|
|
174
186
|
dataHook={dataHook}
|
|
187
|
+
error={error}
|
|
175
188
|
id={label ? inputId : undefined}
|
|
176
189
|
trackingEl={trackingEl}
|
|
177
190
|
trackingLabel={trackingLabel}
|
|
@@ -198,6 +211,8 @@ interface VariantInputOTPProps extends Omit<
|
|
|
198
211
|
autoFocus?: boolean;
|
|
199
212
|
pattern?: string;
|
|
200
213
|
"aria-label"?: string;
|
|
214
|
+
/** Whether the input has an error state */
|
|
215
|
+
error?: boolean;
|
|
201
216
|
}
|
|
202
217
|
|
|
203
218
|
const InputOTPDigitsOnly = React.forwardRef<
|
|
@@ -52,6 +52,10 @@ interface InputPasswordProps extends Omit<
|
|
|
52
52
|
* Optional tracking label
|
|
53
53
|
*/
|
|
54
54
|
trackingLabel?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the input has an error state
|
|
57
|
+
*/
|
|
58
|
+
error?: boolean;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
/**
|
|
@@ -93,6 +97,7 @@ const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
|
|
|
93
97
|
onChange,
|
|
94
98
|
value,
|
|
95
99
|
id,
|
|
100
|
+
error,
|
|
96
101
|
...props
|
|
97
102
|
},
|
|
98
103
|
ref
|
|
@@ -129,7 +134,7 @@ const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
|
|
|
129
134
|
|
|
130
135
|
return (
|
|
131
136
|
<div className="w-full">
|
|
132
|
-
<InputGroup className={className} dataHook={dataHook}>
|
|
137
|
+
<InputGroup className={className} dataHook={dataHook} error={error}>
|
|
133
138
|
<InputGroupInput
|
|
134
139
|
ref={ref}
|
|
135
140
|
id={inputId}
|
package/src/components/input.tsx
CHANGED
|
@@ -78,6 +78,10 @@ export interface InputProps
|
|
|
78
78
|
* Required data-hook attribute for automated testing
|
|
79
79
|
*/
|
|
80
80
|
dataHook: string;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the input has an error state
|
|
83
|
+
*/
|
|
84
|
+
error?: boolean;
|
|
81
85
|
/**
|
|
82
86
|
* Optional tracking element identifier for analytics
|
|
83
87
|
*/
|
|
@@ -95,23 +99,27 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
95
99
|
hasIcon = false,
|
|
96
100
|
hasSecondaryIcon = false,
|
|
97
101
|
dataHook,
|
|
102
|
+
error,
|
|
98
103
|
trackingEl,
|
|
99
104
|
trackingLabel,
|
|
100
105
|
...props
|
|
101
106
|
},
|
|
102
107
|
ref
|
|
103
108
|
) => {
|
|
104
|
-
//
|
|
109
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
105
110
|
const hasError =
|
|
106
|
-
|
|
111
|
+
error ||
|
|
112
|
+
props["aria-invalid"] === true ||
|
|
113
|
+
props["aria-invalid"] === "true";
|
|
107
114
|
|
|
108
115
|
return (
|
|
109
116
|
<input
|
|
110
117
|
ref={ref}
|
|
118
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
111
119
|
className={cn(
|
|
112
120
|
inputVariants({ hasIcon, hasSecondaryIcon }),
|
|
113
121
|
hasError &&
|
|
114
|
-
"border-
|
|
122
|
+
"border-red-600/40 dark:border-red-400/60 focus-visible:border-destructive focus-visible:shadow-destructive",
|
|
115
123
|
className
|
|
116
124
|
)}
|
|
117
125
|
data-hook={dataHook}
|
package/src/components/logo.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
8
8
|
*/
|
|
9
9
|
export type LogoVariant = "logotype" | "mark";
|
|
10
10
|
|
|
11
|
-
const logoVariants = cva("inline-flex [&_path]:fill-primary", {
|
|
11
|
+
const logoVariants = cva("inline-flex [&_path]:fill-brand-primary-foreground", {
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
14
14
|
logotype: "h-6",
|
|
@@ -154,6 +154,10 @@ interface RadioGroupProps
|
|
|
154
154
|
* Tracking label for analytics context
|
|
155
155
|
*/
|
|
156
156
|
trackingLabel?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Whether the radio group has an error state
|
|
159
|
+
*/
|
|
160
|
+
error?: boolean;
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
/**
|
|
@@ -196,16 +200,23 @@ const RadioGroup = React.forwardRef<
|
|
|
196
200
|
dataHook,
|
|
197
201
|
trackingEl,
|
|
198
202
|
trackingLabel,
|
|
203
|
+
error,
|
|
199
204
|
...props
|
|
200
205
|
},
|
|
201
206
|
ref
|
|
202
207
|
) => {
|
|
203
208
|
const contextVariant = variant || "default";
|
|
209
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
210
|
+
const hasError =
|
|
211
|
+
error ||
|
|
212
|
+
props["aria-invalid"] === true ||
|
|
213
|
+
props["aria-invalid"] === "true";
|
|
204
214
|
|
|
205
215
|
return (
|
|
206
216
|
<RadioGroupContext.Provider value={{ variant: contextVariant }}>
|
|
207
217
|
<RadioGroupPrimitive.Root
|
|
208
218
|
ref={ref}
|
|
219
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
209
220
|
className={cn(radioGroupVariants({ variant }), className)}
|
|
210
221
|
data-hook={dataHook}
|
|
211
222
|
data-slot="radio-group"
|
|
@@ -184,6 +184,8 @@ interface SelectTriggerProps extends React.ComponentProps<
|
|
|
184
184
|
placeholder?: string;
|
|
185
185
|
/** Data hook for testing and automation */
|
|
186
186
|
dataHook?: string;
|
|
187
|
+
/** Whether the select trigger has an error state */
|
|
188
|
+
error?: boolean;
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
// ============================================================================
|
|
@@ -198,11 +200,14 @@ function SelectTrigger({
|
|
|
198
200
|
children,
|
|
199
201
|
placeholder,
|
|
200
202
|
dataHook,
|
|
203
|
+
error,
|
|
201
204
|
...props
|
|
202
205
|
}: SelectTriggerProps) {
|
|
203
|
-
//
|
|
206
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
204
207
|
const isError =
|
|
205
|
-
|
|
208
|
+
error ||
|
|
209
|
+
props["aria-invalid"] === true ||
|
|
210
|
+
props["aria-invalid"] === "true";
|
|
206
211
|
const isRequired =
|
|
207
212
|
props["aria-required"] === true || props["aria-required"] === "true";
|
|
208
213
|
|
|
@@ -35,6 +35,10 @@ interface TextareaProps extends Omit<
|
|
|
35
35
|
* Optional id attribute for linking with label via htmlFor
|
|
36
36
|
*/
|
|
37
37
|
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the textarea has an error state
|
|
40
|
+
*/
|
|
41
|
+
error?: boolean;
|
|
38
42
|
/**
|
|
39
43
|
* Optional tracking prop for analytics tracking element identifier
|
|
40
44
|
*/
|
|
@@ -46,17 +50,20 @@ interface TextareaProps extends Omit<
|
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
49
|
-
({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
50
|
-
//
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
+
({ className, dataHook, error, trackingEl, trackingLabel, ...props }, ref) => {
|
|
54
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
55
|
+
const hasError =
|
|
56
|
+
error ||
|
|
57
|
+
props["aria-invalid"] === true ||
|
|
58
|
+
props["aria-invalid"] === "true";
|
|
53
59
|
|
|
54
60
|
return (
|
|
55
61
|
<textarea
|
|
56
62
|
ref={ref}
|
|
63
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
57
64
|
className={cn(
|
|
58
65
|
textareaVariants(),
|
|
59
|
-
|
|
66
|
+
hasError &&
|
|
60
67
|
"border-destructive dark:border-destructive focus-visible:border-destructive focus-visible:shadow-destructive",
|
|
61
68
|
className
|
|
62
69
|
)}
|
|
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-150 ease-in-out
|
|
10
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-150 ease-in-out whitespace-nowrap",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
@@ -68,20 +68,18 @@ const Toggle = React.forwardRef<
|
|
|
68
68
|
...props
|
|
69
69
|
},
|
|
70
70
|
ref
|
|
71
|
-
) =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
}
|
|
71
|
+
) => (
|
|
72
|
+
<TogglePrimitive.Root
|
|
73
|
+
ref={ref}
|
|
74
|
+
aria-label={ariaLabel}
|
|
75
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
76
|
+
data-hook={dataHook}
|
|
77
|
+
data-slot="toggle"
|
|
78
|
+
data-tracking-el={trackingEl || `toggle-${variant}`}
|
|
79
|
+
data-tracking-label={trackingLabel}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
85
83
|
);
|
|
86
84
|
|
|
87
85
|
Toggle.displayName = "Toggle";
|