@brightlocal/ui-components 3.1.0 → 3.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.
Files changed (176) hide show
  1. package/README.md +6 -1
  2. package/component-meta.json +663 -38
  3. package/deprecations.json +1 -1
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts +32 -3
  6. package/dist/alert-dialog.d.ts.map +1 -1
  7. package/dist/alert-dialog.js +61 -58
  8. package/dist/alert.cjs +1 -1
  9. package/dist/alert.d.ts.map +1 -1
  10. package/dist/alert.js +58 -57
  11. package/dist/badge.cjs +1 -1
  12. package/dist/badge.d.ts +9 -0
  13. package/dist/badge.d.ts.map +1 -1
  14. package/dist/badge.js +50 -30
  15. package/dist/banner.cjs +1 -0
  16. package/dist/banner.d.ts +81 -0
  17. package/dist/banner.d.ts.map +1 -0
  18. package/dist/banner.js +176 -0
  19. package/dist/blocks/empty-state.cjs +1 -1
  20. package/dist/blocks/empty-state.d.ts +4 -3
  21. package/dist/blocks/empty-state.d.ts.map +1 -1
  22. package/dist/blocks/empty-state.js +21 -20
  23. package/dist/blocks/progress-state.d.ts +2 -2
  24. package/dist/blocks/sidebar.cjs +1 -1
  25. package/dist/blocks/sidebar.d.ts +17 -0
  26. package/dist/blocks/sidebar.d.ts.map +1 -1
  27. package/dist/blocks/sidebar.js +8 -2
  28. package/dist/brand-illustration-motif.d.ts +1 -1
  29. package/dist/card.cjs +1 -1
  30. package/dist/card.d.ts +86 -6
  31. package/dist/card.d.ts.map +1 -1
  32. package/dist/card.js +185 -96
  33. package/dist/chart.cjs +3 -3
  34. package/dist/chart.d.ts +231 -13
  35. package/dist/chart.d.ts.map +1 -1
  36. package/dist/chart.js +466 -306
  37. package/dist/checkbox.cjs +1 -1
  38. package/dist/checkbox.d.ts +1 -1
  39. package/dist/checkbox.d.ts.map +1 -1
  40. package/dist/checkbox.js +2 -1
  41. package/dist/combobox.cjs +1 -1
  42. package/dist/combobox.js +2 -2
  43. package/dist/command.cjs +1 -1
  44. package/dist/command.js +1 -1
  45. package/dist/data-table.cjs +1 -1
  46. package/dist/data-table.d.ts +169 -22
  47. package/dist/data-table.d.ts.map +1 -1
  48. package/dist/data-table.js +695 -561
  49. package/dist/grid.d.ts +24 -1
  50. package/dist/grid.d.ts.map +1 -1
  51. package/dist/hooks/use-breakpoint.cjs +1 -1
  52. package/dist/hooks/use-breakpoint.d.ts +1 -1
  53. package/dist/hooks/use-breakpoint.d.ts.map +1 -1
  54. package/dist/hooks/use-breakpoint.js +1 -0
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.d.ts +5 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +593 -561
  59. package/dist/info-tooltip.cjs +1 -0
  60. package/dist/info-tooltip.d.ts +39 -0
  61. package/dist/info-tooltip.d.ts.map +1 -0
  62. package/dist/info-tooltip.js +41 -0
  63. package/dist/input-chip.cjs +1 -1
  64. package/dist/input-chip.js +1 -1
  65. package/dist/input-group.cjs +1 -1
  66. package/dist/input-group.d.ts +33 -2
  67. package/dist/input-group.d.ts.map +1 -1
  68. package/dist/input-group.js +167 -54
  69. package/dist/input-otp.cjs +1 -1
  70. package/dist/input-otp.js +9 -9
  71. package/dist/input-password.cjs +1 -1
  72. package/dist/input-password.d.ts +28 -6
  73. package/dist/input-password.d.ts.map +1 -1
  74. package/dist/input-password.js +5 -5
  75. package/dist/input.cjs +1 -1
  76. package/dist/input.js +10 -10
  77. package/dist/lib/block-illustration.cjs +1 -1
  78. package/dist/lib/block-illustration.d.ts +4 -1
  79. package/dist/lib/block-illustration.d.ts.map +1 -1
  80. package/dist/lib/block-illustration.js +12 -11
  81. package/dist/lib/utils.cjs +1 -1
  82. package/dist/lib/utils.d.ts.map +1 -1
  83. package/dist/lib/utils.js +4 -3
  84. package/dist/list.cjs +1 -1
  85. package/dist/list.js +1 -1
  86. package/dist/multi-select-filter.cjs +1 -0
  87. package/dist/multi-select-filter.d.ts +178 -0
  88. package/dist/multi-select-filter.d.ts.map +1 -0
  89. package/dist/multi-select-filter.js +463 -0
  90. package/dist/progress.cjs +1 -1
  91. package/dist/progress.d.ts +123 -16
  92. package/dist/progress.d.ts.map +1 -1
  93. package/dist/progress.js +89 -75
  94. package/dist/rating.cjs +1 -1
  95. package/dist/rating.js +18 -18
  96. package/dist/relative-date.cjs +1 -0
  97. package/dist/relative-date.d.ts +65 -0
  98. package/dist/relative-date.d.ts.map +1 -0
  99. package/dist/relative-date.js +128 -0
  100. package/dist/select.cjs +2 -2
  101. package/dist/select.d.ts +11 -1
  102. package/dist/select.d.ts.map +1 -1
  103. package/dist/select.js +97 -81
  104. package/dist/sheet.cjs +1 -1
  105. package/dist/sheet.d.ts +78 -2
  106. package/dist/sheet.d.ts.map +1 -1
  107. package/dist/sheet.js +192 -85
  108. package/dist/single-select-filter.cjs +1 -0
  109. package/dist/single-select-filter.d.ts +81 -0
  110. package/dist/single-select-filter.d.ts.map +1 -0
  111. package/dist/single-select-filter.js +226 -0
  112. package/dist/sonner.cjs +1 -1
  113. package/dist/sonner.d.ts.map +1 -1
  114. package/dist/sonner.js +22 -22
  115. package/dist/split-layout.cjs +1 -1
  116. package/dist/split-layout.d.ts +1 -1
  117. package/dist/split-layout.js +13 -13
  118. package/dist/table.cjs +1 -1
  119. package/dist/table.d.ts +45 -4
  120. package/dist/table.d.ts.map +1 -1
  121. package/dist/table.js +90 -73
  122. package/dist/tabs.cjs +1 -1
  123. package/dist/tabs.d.ts +12 -1
  124. package/dist/tabs.d.ts.map +1 -1
  125. package/dist/tabs.js +148 -126
  126. package/dist/textarea.cjs +1 -1
  127. package/dist/textarea.js +1 -1
  128. package/dist/tooltip.cjs +1 -1
  129. package/dist/tooltip.d.ts +38 -36
  130. package/dist/tooltip.d.ts.map +1 -1
  131. package/dist/tooltip.js +262 -73
  132. package/dist/typography-text.d.ts +1 -2
  133. package/dist/typography-text.d.ts.map +1 -1
  134. package/dist/typography.d.ts +1 -1
  135. package/package.json +5 -6
  136. package/src/blocks/empty-state.tsx +8 -3
  137. package/src/blocks/progress-state.tsx +2 -2
  138. package/src/blocks/sidebar.tsx +26 -2
  139. package/src/components/alert-dialog.tsx +50 -5
  140. package/src/components/alert.tsx +16 -8
  141. package/src/components/badge.tsx +40 -3
  142. package/src/components/banner.tsx +288 -0
  143. package/src/components/brand-illustration-motif.tsx +1 -1
  144. package/src/components/card.tsx +211 -24
  145. package/src/components/chart.tsx +523 -35
  146. package/src/components/checkbox.tsx +1 -1
  147. package/src/components/combobox.tsx +2 -2
  148. package/src/components/command.tsx +1 -1
  149. package/src/components/data-table.tsx +778 -195
  150. package/src/components/grid.tsx +32 -1
  151. package/src/components/info-tooltip.tsx +94 -0
  152. package/src/components/input-chip.tsx +1 -1
  153. package/src/components/input-group.tsx +246 -11
  154. package/src/components/input-otp.tsx +1 -1
  155. package/src/components/input-password.tsx +33 -11
  156. package/src/components/input.tsx +1 -1
  157. package/src/components/list.tsx +1 -1
  158. package/src/components/multi-select-filter.tsx +912 -0
  159. package/src/components/progress.tsx +190 -31
  160. package/src/components/rating.tsx +1 -1
  161. package/src/components/relative-date.tsx +230 -0
  162. package/src/components/select.tsx +35 -5
  163. package/src/components/sheet.tsx +240 -4
  164. package/src/components/single-select-filter.tsx +443 -0
  165. package/src/components/sonner.tsx +16 -5
  166. package/src/components/split-layout.tsx +2 -2
  167. package/src/components/table.tsx +71 -11
  168. package/src/components/tabs.tsx +93 -46
  169. package/src/components/textarea.tsx +1 -1
  170. package/src/components/tooltip.tsx +440 -68
  171. package/src/components/typography-text.tsx +1 -2
  172. package/src/components/typography.tsx +1 -1
  173. package/src/hooks/use-breakpoint.ts +2 -1
  174. package/src/index.ts +5 -0
  175. package/src/lib/block-illustration.tsx +5 -1
  176. package/src/lib/utils.ts +1 -0
@@ -3,9 +3,10 @@
3
3
  import * as React from "react";
4
4
  import * as SheetPrimitive from "@radix-ui/react-dialog";
5
5
  import { cva, type VariantProps } from "class-variance-authority";
6
- import { X } from "@brightlocal/icons";
6
+ import { ChevronDown, ChevronUp, X } from "@brightlocal/icons";
7
7
 
8
8
  import { cn } from "@brightlocal/ui-components/lib/utils";
9
+ import { Button } from "@brightlocal/ui-components/button";
9
10
  import { ScrollArea } from "@brightlocal/ui-components/scroll-area";
10
11
  import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
11
12
 
@@ -273,9 +274,18 @@ const SheetContent = React.forwardRef<
273
274
  {...props}
274
275
  >
275
276
  {children}
276
- <SheetPrimitive.Close className="ring-offset-background focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground duration-fast absolute top-4 right-4 rounded-xs opacity-70 outline-hidden transition-opacity ease-out hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0">
277
- <X />
278
- <span className="sr-only">{closeLabel ?? "Close"}</span>
277
+ {/* Ghost icon button (DS-1035) — standard hover/focus states, and its
278
+ 36px box at top-6 lines up with a SheetPagination row. */}
279
+ <SheetPrimitive.Close asChild>
280
+ <Button
281
+ iconOnly
282
+ className="absolute top-6 right-4"
283
+ dataHook="sheet-close"
284
+ variant="ghost"
285
+ >
286
+ <X />
287
+ <span className="sr-only">{closeLabel ?? "Close"}</span>
288
+ </Button>
279
289
  </SheetPrimitive.Close>
280
290
  </SheetPrimitive.Content>
281
291
  </SheetPortal>
@@ -301,6 +311,229 @@ const SheetHeader = React.forwardRef<
301
311
  ));
302
312
  SheetHeader.displayName = "SheetHeader";
303
313
 
314
+ /**
315
+ * Numbers a `SheetPagination` position indicator is built from.
316
+ */
317
+ interface SheetPaginationPositionInfo {
318
+ /** 1-based position of the item shown in the sheet. */
319
+ current: number;
320
+ /** Total number of items in the list being stepped through. */
321
+ total: number;
322
+ }
323
+
324
+ /**
325
+ * Props for the SheetPagination component
326
+ */
327
+ interface SheetPaginationProps extends Omit<
328
+ React.ComponentProps<"div">,
329
+ "children"
330
+ > {
331
+ /** Called when the user steps to the previous item. */
332
+ onPrevious: () => void;
333
+ /** Called when the user steps to the next item. */
334
+ onNext: () => void;
335
+ /**
336
+ * 1-based position of the item shown in the sheet. Together with `total`,
337
+ * drives the position indicator and the default boundary state.
338
+ */
339
+ current?: number;
340
+ /** Total number of items in the list being stepped through. */
341
+ total?: number;
342
+ /**
343
+ * Whether a previous item exists. Disables the previous button when false.
344
+ * @default current > 1 (true when `current` is not set)
345
+ */
346
+ hasPrevious?: boolean;
347
+ /**
348
+ * Whether a next item exists. Disables the next button when false.
349
+ * @default current < total (true when either is not set)
350
+ */
351
+ hasNext?: boolean;
352
+ /**
353
+ * Render the position indicator. Receives the current position and total;
354
+ * you own the wording. Return `null` to hide it.
355
+ * @default Renders "{current} of {total}", or nothing when either is unset.
356
+ */
357
+ renderPosition?:
358
+ | ((info: SheetPaginationPositionInfo) => React.ReactNode)
359
+ | null;
360
+ /**
361
+ * Accessible label for the item navigation group.
362
+ * @default "Item navigation"
363
+ */
364
+ ariaLabel?: string;
365
+ /**
366
+ * Accessible label for the previous button.
367
+ * @default "Previous item"
368
+ */
369
+ prevAriaLabel?: string;
370
+ /**
371
+ * Accessible label for the next button.
372
+ * @default "Next item"
373
+ */
374
+ nextAriaLabel?: string;
375
+ /**
376
+ * Data hook for automated testing. The buttons get `{dataHook}-previous`
377
+ * and `{dataHook}-next`.
378
+ */
379
+ dataHook: string;
380
+ /**
381
+ * Tracking element identifier for analytics
382
+ */
383
+ trackingEl?: string;
384
+ /**
385
+ * Tracking label for analytics context
386
+ */
387
+ trackingLabel?: string;
388
+ }
389
+
390
+ /**
391
+ * Previous/next controls for stepping through a list of items without
392
+ * closing the sheet — e.g. a detail sheet drilled into from a table row.
393
+ * Place it as the first child of SheetContent, above SheetHeader; it shares
394
+ * the close button's row. The arrow keys step while focus is on the controls.
395
+ */
396
+ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
397
+ (
398
+ {
399
+ className,
400
+ onPrevious,
401
+ onNext,
402
+ current,
403
+ total,
404
+ hasPrevious,
405
+ hasNext,
406
+ renderPosition,
407
+ ariaLabel,
408
+ prevAriaLabel,
409
+ nextAriaLabel,
410
+ dataHook,
411
+ trackingEl,
412
+ trackingLabel,
413
+ ...props
414
+ },
415
+ ref
416
+ ) => {
417
+ const canPrevious = hasPrevious ?? (current == null || current > 1);
418
+ const canNext =
419
+ hasNext ?? (current == null || total == null || current < total);
420
+
421
+ const prevRef = React.useRef<HTMLButtonElement>(null);
422
+ const nextRef = React.useRef<HTMLButtonElement>(null);
423
+ // The button that just triggered a step. Set only by our own
424
+ // navigation, consumed on the next commit.
425
+ const pendingRef = React.useRef<HTMLButtonElement | null>(null);
426
+
427
+ // Reaching a boundary disables the button that was just pressed, which
428
+ // drops focus to <body>. Hand it to the sibling instead so keyboard users
429
+ // stay in the control.
430
+ React.useEffect(() => {
431
+ const pending = pendingRef.current;
432
+ pendingRef.current = null;
433
+ if (!pending) return;
434
+ const active = document.activeElement;
435
+ if (active !== pending && active !== document.body) return;
436
+ if (!canPrevious && pending === prevRef.current && canNext) {
437
+ nextRef.current?.focus();
438
+ } else if (!canNext && pending === nextRef.current && canPrevious) {
439
+ prevRef.current?.focus();
440
+ }
441
+ });
442
+
443
+ const handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {
444
+ // Focus left on purpose (to anything but the sibling) — drop any
445
+ // pending hand-off. A disabled button blurs with a null relatedTarget.
446
+ const next = event.relatedTarget;
447
+ if (next && next !== prevRef.current && next !== nextRef.current) {
448
+ pendingRef.current = null;
449
+ }
450
+ };
451
+
452
+ const step = (
453
+ direction: "previous" | "next",
454
+ trigger: HTMLButtonElement
455
+ ) => {
456
+ if (direction === "previous") {
457
+ if (!canPrevious) return;
458
+ pendingRef.current = trigger;
459
+ onPrevious();
460
+ } else {
461
+ if (!canNext) return;
462
+ pendingRef.current = trigger;
463
+ onNext();
464
+ }
465
+ };
466
+
467
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
468
+ if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
469
+ event.preventDefault();
470
+ step("previous", event.currentTarget);
471
+ } else if (event.key === "ArrowDown" || event.key === "ArrowRight") {
472
+ event.preventDefault();
473
+ step("next", event.currentTarget);
474
+ }
475
+ };
476
+
477
+ let position: React.ReactNode = null;
478
+ if (renderPosition !== null && current != null && total != null) {
479
+ position = renderPosition
480
+ ? renderPosition({ current, total })
481
+ : `${current} of ${total}`;
482
+ }
483
+
484
+ return (
485
+ <div
486
+ ref={ref}
487
+ aria-label={ariaLabel ?? "Item navigation"}
488
+ // mb-2 on top of SheetContent's gap-4 gives the 24px Figma gap to
489
+ // the header below.
490
+ className={cn("mb-2 flex items-center gap-1", className)}
491
+ data-hook={dataHook}
492
+ data-slot="sheet-pagination"
493
+ data-tracking-el={trackingEl}
494
+ data-tracking-label={trackingLabel}
495
+ role="group"
496
+ {...props}
497
+ >
498
+ <Button
499
+ ref={prevRef}
500
+ ariaLabel={prevAriaLabel ?? "Previous item"}
501
+ dataHook={`${dataHook}-previous`}
502
+ disabled={!canPrevious}
503
+ variant="ghost"
504
+ onBlur={handleBlur}
505
+ onClick={(event) => step("previous", event.currentTarget)}
506
+ onKeyDown={handleKeyDown}
507
+ >
508
+ <ChevronUp />
509
+ </Button>
510
+ <Button
511
+ ref={nextRef}
512
+ ariaLabel={nextAriaLabel ?? "Next item"}
513
+ dataHook={`${dataHook}-next`}
514
+ disabled={!canNext}
515
+ variant="ghost"
516
+ onBlur={handleBlur}
517
+ onClick={(event) => step("next", event.currentTarget)}
518
+ onKeyDown={handleKeyDown}
519
+ >
520
+ <ChevronDown />
521
+ </Button>
522
+ {position != null && (
523
+ <span
524
+ aria-live="polite"
525
+ className="text-body-sm text-muted-foreground"
526
+ data-slot="sheet-pagination-position"
527
+ >
528
+ {position}
529
+ </span>
530
+ )}
531
+ </div>
532
+ );
533
+ }
534
+ );
535
+ SheetPagination.displayName = "SheetPagination";
536
+
304
537
  /**
305
538
  * Props for the SheetBody component
306
539
  */
@@ -450,6 +683,7 @@ export {
450
683
  SheetFooter,
451
684
  SheetHeader,
452
685
  SheetOverlay,
686
+ SheetPagination,
453
687
  SheetPortal,
454
688
  SheetTitle,
455
689
  SheetTrigger,
@@ -459,6 +693,8 @@ export type {
459
693
  SheetBodyProps,
460
694
  SheetContentProps,
461
695
  SheetDescriptionProps,
696
+ SheetPaginationPositionInfo,
697
+ SheetPaginationProps,
462
698
  SheetTitleProps,
463
699
  SheetTriggerProps,
464
700
  };