@brightlocal/ui-components 1.0.1 → 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.
@@ -212,14 +212,15 @@ const q = g(
212
212
  "data-slot": "typography-code",
213
213
  "data-tracking-el": e,
214
214
  "data-tracking-label": r,
215
+ tabIndex: 0,
215
216
  ...n
216
217
  }
217
218
  )
218
219
  );
219
220
  v.displayName = "TypographyCode";
220
- const S = g(
221
+ const I = g(
221
222
  "text-muted-foreground text-xl font-normal font-sans leading-7"
222
- ), j = d.forwardRef(
223
+ ), S = d.forwardRef(
223
224
  ({
224
225
  className: a,
225
226
  asChild: t = !1,
@@ -231,7 +232,7 @@ const S = g(
231
232
  t ? p : "p",
232
233
  {
233
234
  ref: s,
234
- className: c(S(), a),
235
+ className: c(I(), a),
235
236
  "data-hook": o,
236
237
  "data-slot": "typography-lead",
237
238
  "data-tracking-el": e,
@@ -240,10 +241,10 @@ const S = g(
240
241
  }
241
242
  )
242
243
  );
243
- j.displayName = "TypographyLead";
244
- const B = g(
244
+ S.displayName = "TypographyLead";
245
+ const j = g(
245
246
  "text-foreground text-lg font-semibold font-sans leading-7"
246
- ), I = d.forwardRef(
247
+ ), B = d.forwardRef(
247
248
  ({
248
249
  className: a,
249
250
  asChild: t = !1,
@@ -255,7 +256,7 @@ const B = g(
255
256
  t ? p : "div",
256
257
  {
257
258
  ref: s,
258
- className: c(B(), a),
259
+ className: c(j(), a),
259
260
  "data-hook": o,
260
261
  "data-slot": "typography-large",
261
262
  "data-tracking-el": e,
@@ -264,7 +265,7 @@ const B = g(
264
265
  }
265
266
  )
266
267
  );
267
- I.displayName = "TypographyLarge";
268
+ B.displayName = "TypographyLarge";
268
269
  const M = g(
269
270
  "text-foreground text-sm font-medium font-sans leading-5"
270
271
  ), P = d.forwardRef(
@@ -321,8 +322,8 @@ export {
321
322
  k as TypographyH3,
322
323
  b as TypographyH4,
323
324
  L as TypographyInlineCode,
324
- I as TypographyLarge,
325
- j as TypographyLead,
325
+ B as TypographyLarge,
326
+ S as TypographyLead,
326
327
  V as TypographyList,
327
328
  A as TypographyMuted,
328
329
  N as TypographyP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightlocal/ui-components",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "BrightLocal Design System UI Components",
5
5
  "type": "module",
6
6
  "private": false,
@@ -172,15 +172,20 @@ function Calendar({
172
172
  defaultClassNames.day
173
173
  ),
174
174
  range_start: cn(
175
- "rounded-l-md bg-accent",
175
+ "rounded-l-md rounded-r-none bg-accent",
176
176
  defaultClassNames.range_start
177
177
  ),
178
+ // !important overrides the `today` class's rounded-md which applies
179
+ // to the same <td> cell and would otherwise round range-middle corners.
178
180
  range_middle: cn(
179
- "rounded-none bg-accent",
180
- "first:rounded-l-md last:rounded-r-md",
181
+ "!rounded-none bg-accent",
182
+ "first:!rounded-l-md last:!rounded-r-md",
181
183
  defaultClassNames.range_middle
182
184
  ),
183
- range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
185
+ range_end: cn(
186
+ "rounded-r-md rounded-l-none bg-accent",
187
+ defaultClassNames.range_end
188
+ ),
184
189
  today: cn(
185
190
  "bg-accent text-accent-foreground rounded-md",
186
191
  defaultClassNames.today
@@ -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
- className={cn(comboboxTriggerVariants({ variant }), className)}
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={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}
@@ -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 overflow-hidden rounded-md px-3 py-1.5 text-xs leading-4 font-normal",
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}
@@ -444,6 +444,7 @@ const TypographyCode = React.forwardRef<HTMLPreElement, TypographyCodeProps>(
444
444
  data-slot="typography-code"
445
445
  data-tracking-el={trackingEl}
446
446
  data-tracking-label={trackingLabel}
447
+ tabIndex={0}
447
448
  {...props}
448
449
  />
449
450
  );