@brightlocal/ui-components 1.0.2 → 1.1.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/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +17 -12
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +2 -0
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +91 -87
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +4 -0
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +123 -111
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +2 -0
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +14 -14
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts.map +1 -1
- package/dist/typography.js +11 -10
- package/package.json +1 -1
- package/src/components/calendar.tsx +9 -4
- package/src/components/combobox.tsx +16 -4
- package/src/components/date-picker.tsx +35 -5
- package/src/components/field.tsx +2 -0
- package/src/components/tooltip.tsx +1 -1
- package/src/components/typography.tsx +1 -0
|
@@ -178,9 +178,6 @@ const comboboxTriggerVariants = cva(
|
|
|
178
178
|
// Placeholder state
|
|
179
179
|
"data-[placeholder=true]:text-muted-foreground",
|
|
180
180
|
|
|
181
|
-
// Hover state
|
|
182
|
-
"hover:bg-accent",
|
|
183
|
-
|
|
184
181
|
// Focus state
|
|
185
182
|
"focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background",
|
|
186
183
|
"focus-visible:shadow-default",
|
|
@@ -220,6 +217,8 @@ export interface ComboboxTriggerProps
|
|
|
220
217
|
"aria-label"?: string;
|
|
221
218
|
/** ID reference to a label element that provides the accessible name */
|
|
222
219
|
"aria-labelledby"?: string;
|
|
220
|
+
/** Whether the combobox trigger has an error state */
|
|
221
|
+
error?: boolean;
|
|
223
222
|
/** Tracking element identifier for analytics */
|
|
224
223
|
trackingEl?: string;
|
|
225
224
|
/** Tracking label for analytics context */
|
|
@@ -235,6 +234,7 @@ const ComboboxTrigger = React.forwardRef<
|
|
|
235
234
|
className,
|
|
236
235
|
variant,
|
|
237
236
|
dataHook,
|
|
237
|
+
error,
|
|
238
238
|
trackingEl,
|
|
239
239
|
trackingLabel,
|
|
240
240
|
children,
|
|
@@ -246,6 +246,12 @@ const ComboboxTrigger = React.forwardRef<
|
|
|
246
246
|
const listboxId = React.useId();
|
|
247
247
|
const isPlaceholder = !value;
|
|
248
248
|
|
|
249
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
250
|
+
const hasError =
|
|
251
|
+
error ||
|
|
252
|
+
props["aria-invalid"] === true ||
|
|
253
|
+
props["aria-invalid"] === "true";
|
|
254
|
+
|
|
249
255
|
return (
|
|
250
256
|
<PopoverTrigger asChild>
|
|
251
257
|
<button
|
|
@@ -253,7 +259,13 @@ const ComboboxTrigger = React.forwardRef<
|
|
|
253
259
|
aria-controls={open ? listboxId : undefined}
|
|
254
260
|
aria-expanded={open}
|
|
255
261
|
aria-haspopup="listbox"
|
|
256
|
-
|
|
262
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
263
|
+
className={cn(
|
|
264
|
+
comboboxTriggerVariants({ variant }),
|
|
265
|
+
hasError &&
|
|
266
|
+
"border-red-600/40 dark:border-red-400/60 focus-visible:border-destructive dark:focus-visible:border-red-400/60 focus-visible:shadow-destructive data-[state=open]:border-destructive dark:data-[state=open]:border-red-400/60",
|
|
267
|
+
className
|
|
268
|
+
)}
|
|
257
269
|
data-hook={dataHook}
|
|
258
270
|
data-placeholder={isPlaceholder}
|
|
259
271
|
data-slot="combobox-trigger"
|
|
@@ -248,6 +248,10 @@ export interface DatePickerTriggerProps extends Omit<
|
|
|
248
248
|
* If not provided, displays formatted date or placeholder
|
|
249
249
|
*/
|
|
250
250
|
children?: React.ReactNode;
|
|
251
|
+
/**
|
|
252
|
+
* Whether the trigger has an error state
|
|
253
|
+
*/
|
|
254
|
+
error?: boolean;
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
/**
|
|
@@ -256,10 +260,32 @@ export interface DatePickerTriggerProps extends Omit<
|
|
|
256
260
|
const DatePickerTrigger = React.forwardRef<
|
|
257
261
|
HTMLButtonElement,
|
|
258
262
|
DatePickerTriggerProps
|
|
259
|
-
>(({ className, children, id, ...props }, ref) => {
|
|
260
|
-
const { mode, date, dateRange, dateFormat, placeholder, disabled, dataHook } =
|
|
263
|
+
>(({ className, children, id, error, ...props }, ref) => {
|
|
264
|
+
const { mode, date, dateRange, dateFormat, placeholder, disabled, dataHook, open } =
|
|
261
265
|
useDatePickerContext();
|
|
262
266
|
|
|
267
|
+
const hasError = !!error;
|
|
268
|
+
|
|
269
|
+
const triggerRef = React.useRef<HTMLButtonElement>(null);
|
|
270
|
+
|
|
271
|
+
const combinedRef = React.useCallback(
|
|
272
|
+
(node: HTMLButtonElement | null) => {
|
|
273
|
+
triggerRef.current = node;
|
|
274
|
+
if (typeof ref === "function") ref(node);
|
|
275
|
+
else if (ref) ref.current = node;
|
|
276
|
+
},
|
|
277
|
+
[ref]
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
// Radix sets aria-controls referencing the popover content ID, but the
|
|
281
|
+
// content is only in the DOM when open (Portal). Remove aria-controls when
|
|
282
|
+
// closed to prevent an invalid ARIA reference (axe: aria-valid-attr-value).
|
|
283
|
+
React.useLayoutEffect(() => {
|
|
284
|
+
if (!open && triggerRef.current) {
|
|
285
|
+
triggerRef.current.removeAttribute("aria-controls");
|
|
286
|
+
}
|
|
287
|
+
}, [open]);
|
|
288
|
+
|
|
263
289
|
const formatDisplayValue = () => {
|
|
264
290
|
if (mode === "single") {
|
|
265
291
|
return date ? format(date, dateFormat) : null;
|
|
@@ -276,17 +302,20 @@ const DatePickerTrigger = React.forwardRef<
|
|
|
276
302
|
return (
|
|
277
303
|
<PopoverTrigger asChild>
|
|
278
304
|
<button
|
|
279
|
-
ref={
|
|
305
|
+
ref={combinedRef}
|
|
280
306
|
aria-label={
|
|
281
307
|
props["aria-label"] ??
|
|
282
308
|
(mode === "single" ? "Select date" : "Select date range")
|
|
283
309
|
}
|
|
284
310
|
className={cn(
|
|
285
311
|
inputVariants({ hasIcon: true }),
|
|
286
|
-
"relative cursor-pointer justify-start text-left",
|
|
312
|
+
"relative cursor-pointer justify-start pb-0 text-left group-hover/field:bg-accent dark:group-hover/field:bg-input/50",
|
|
287
313
|
!hasValue && "text-muted-foreground",
|
|
314
|
+
hasError &&
|
|
315
|
+
"border-red-600/40 dark:border-red-400/60 focus-visible:border-destructive focus-visible:shadow-destructive",
|
|
288
316
|
className
|
|
289
317
|
)}
|
|
318
|
+
data-error={hasError || undefined}
|
|
290
319
|
data-hook={`${dataHook}-trigger`}
|
|
291
320
|
data-slot="date-picker-trigger"
|
|
292
321
|
disabled={disabled}
|
|
@@ -330,12 +359,13 @@ const DatePickerContent = React.forwardRef<
|
|
|
330
359
|
HTMLDivElement,
|
|
331
360
|
DatePickerContentProps
|
|
332
361
|
>(({ className, children, ...props }, ref) => {
|
|
333
|
-
const { dataHook } = useDatePickerContext();
|
|
362
|
+
const { dataHook, mode } = useDatePickerContext();
|
|
334
363
|
|
|
335
364
|
return (
|
|
336
365
|
<PopoverContent
|
|
337
366
|
ref={ref}
|
|
338
367
|
align="start"
|
|
368
|
+
aria-label={mode === "single" ? "Date picker" : "Date range picker"}
|
|
339
369
|
className={cn("w-auto rounded-lg p-0", className)}
|
|
340
370
|
dataHook={`${dataHook}-content`}
|
|
341
371
|
{...props}
|
package/src/components/field.tsx
CHANGED
|
@@ -69,6 +69,8 @@ const fieldVariants = cva(
|
|
|
69
69
|
"group/field flex w-full gap-2",
|
|
70
70
|
// RadioGroup context: positioned ancestor for RadioGroupItem click overlay + pointer cursor
|
|
71
71
|
"[[data-slot=radio-group]_&]:relative [[data-slot=radio-group]_&]:cursor-pointer [[data-slot=radio-group]_&]:gap-3 [[data-slot=radio-group]_&]:has-[[data-disabled]]:cursor-not-allowed",
|
|
72
|
+
// RadioGroup context: label overlay spans the full Field for clickable row
|
|
73
|
+
"[[data-slot=radio-group]_&_[data-slot=field-label]]:after:absolute [[data-slot=radio-group]_&_[data-slot=field-label]]:after:inset-0 [[data-slot=radio-group]_&_[data-slot=field-label]]:after:cursor-pointer [[data-slot=radio-group]_&:has([data-disabled])_[data-slot=field-label]]:after:cursor-not-allowed",
|
|
72
74
|
// Label leading overrides: use leading-normal for wrap-capable labels (checkbox)
|
|
73
75
|
"has-[>[role=checkbox]]:[&_[data-slot=field-label]]:leading-normal",
|
|
74
76
|
],
|
|
@@ -126,7 +126,7 @@ const TooltipContent = React.forwardRef<
|
|
|
126
126
|
<TooltipPrimitive.Content
|
|
127
127
|
ref={ref}
|
|
128
128
|
className={cn(
|
|
129
|
-
"bg-secondary text-secondary-foreground z-50
|
|
129
|
+
"bg-secondary text-secondary-foreground z-50 rounded-md px-3 py-1.5 text-xs leading-4 font-normal",
|
|
130
130
|
className
|
|
131
131
|
)}
|
|
132
132
|
data-hook={dataHook}
|