@brightlocal/ui-components 2.23.0 → 2.24.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 (90) hide show
  1. package/AI_USAGE.md +1 -1
  2. package/README.md +3 -2
  3. package/component-meta.json +116 -25
  4. package/deprecations.json +22 -0
  5. package/dist/alert.cjs +1 -1
  6. package/dist/alert.d.ts.map +1 -1
  7. package/dist/alert.js +6 -9
  8. package/dist/blocks/sidebar.cjs +1 -1
  9. package/dist/blocks/sidebar.d.ts.map +1 -1
  10. package/dist/blocks/sidebar.js +151 -156
  11. package/dist/brand-illustration-motif.cjs +1 -0
  12. package/dist/brand-illustration-motif.d.ts +55 -0
  13. package/dist/brand-illustration-motif.d.ts.map +1 -0
  14. package/dist/brand-illustration-motif.js +67 -0
  15. package/dist/chart.cjs +7 -7
  16. package/dist/chart.d.ts +287 -2
  17. package/dist/chart.d.ts.map +1 -1
  18. package/dist/chart.js +408 -152
  19. package/dist/combobox.cjs +3 -3
  20. package/dist/combobox.d.ts +14 -1
  21. package/dist/combobox.d.ts.map +1 -1
  22. package/dist/combobox.js +387 -376
  23. package/dist/data-table.cjs +1 -0
  24. package/dist/{blocks/data-table.d.ts → data-table.d.ts} +159 -4
  25. package/dist/data-table.d.ts.map +1 -0
  26. package/dist/data-table.js +721 -0
  27. package/dist/field.cjs +1 -1
  28. package/dist/field.d.ts +16 -1
  29. package/dist/field.d.ts.map +1 -1
  30. package/dist/field.js +23 -7
  31. package/dist/global-layout.cjs +1 -1
  32. package/dist/global-layout.d.ts +32 -2
  33. package/dist/global-layout.d.ts.map +1 -1
  34. package/dist/global-layout.js +179 -109
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +2 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +526 -511
  39. package/dist/label.cjs +1 -1
  40. package/dist/label.d.ts +9 -0
  41. package/dist/label.d.ts.map +1 -1
  42. package/dist/label.js +26 -22
  43. package/dist/lib/spring-settle.cjs +1 -0
  44. package/dist/lib/spring-settle.d.ts +20 -0
  45. package/dist/lib/spring-settle.d.ts.map +1 -0
  46. package/dist/lib/spring-settle.js +4 -0
  47. package/dist/link.cjs +1 -1
  48. package/dist/link.d.ts +3 -2
  49. package/dist/link.d.ts.map +1 -1
  50. package/dist/link.js +22 -11
  51. package/dist/loading.cjs +1 -1
  52. package/dist/loading.d.ts +2 -1
  53. package/dist/loading.d.ts.map +1 -1
  54. package/dist/loading.js +106 -85
  55. package/dist/select.cjs +2 -2
  56. package/dist/select.d.ts +16 -1
  57. package/dist/select.d.ts.map +1 -1
  58. package/dist/select.js +112 -79
  59. package/dist/table.cjs +1 -1
  60. package/dist/table.d.ts +29 -0
  61. package/dist/table.d.ts.map +1 -1
  62. package/dist/table.js +2 -2
  63. package/dist/text-reveal-motion.cjs +1 -1
  64. package/dist/text-reveal-motion.d.ts.map +1 -1
  65. package/dist/text-reveal-motion.js +236 -219
  66. package/dist/typography.cjs +1 -1
  67. package/dist/typography.d.ts +20 -4
  68. package/dist/typography.d.ts.map +1 -1
  69. package/dist/typography.js +263 -228
  70. package/package.json +7 -7
  71. package/src/blocks/sidebar.tsx +11 -23
  72. package/src/components/alert.tsx +1 -4
  73. package/src/components/brand-illustration-motif.tsx +143 -0
  74. package/src/components/chart.tsx +632 -1
  75. package/src/components/combobox.tsx +47 -0
  76. package/src/{blocks → components}/data-table.tsx +270 -16
  77. package/src/components/field.tsx +31 -0
  78. package/src/components/global-layout.tsx +144 -5
  79. package/src/components/label.tsx +13 -1
  80. package/src/components/link.tsx +13 -1
  81. package/src/components/loading.tsx +71 -38
  82. package/src/components/select.tsx +82 -2
  83. package/src/components/table.tsx +31 -2
  84. package/src/components/text-reveal-motion.tsx +90 -64
  85. package/src/components/typography.tsx +74 -18
  86. package/src/index.ts +2 -1
  87. package/src/lib/spring-settle.ts +19 -0
  88. package/dist/blocks/data-table.cjs +0 -1
  89. package/dist/blocks/data-table.d.ts.map +0 -1
  90. package/dist/blocks/data-table.js +0 -654
@@ -177,7 +177,10 @@ export enum SidebarCollapseIconType {
177
177
 
178
178
  const SIDEBAR_COOKIE_NAME = "sidebar:state";
179
179
  const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
180
- const SIDEBAR_WIDTH = "224px";
180
+ // Outer wrapper width: the designed 224px content (full-bleed menu buttons)
181
+ // plus the ScrollArea viewport's 4px padding per side, which keeps the 3px
182
+ // focus ring and the 4px overlay scrollbar from being clipped at the edges.
183
+ const SIDEBAR_WIDTH = "232px";
181
184
  const SIDEBAR_WIDTH_MOBILE = "336px";
182
185
  const SIDEBAR_WIDTH_ICON = "48px";
183
186
  const SIDEBAR_KEYBOARD_SHORTCUT = "b";
@@ -793,15 +796,12 @@ interface SidebarContentProps extends Omit<React.ComponentProps<"div">, "dir"> {
793
796
  const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
794
797
  ({ className, dataHook, ariaLabel = "Sidebar", children, ...props }, ref) => {
795
798
  const { isMobile, setFooterPortalEl } = useSidebar();
796
- const viewportRef = React.useRef<HTMLElement | null>(null);
797
- const [hasOverflow, setHasOverflow] = React.useState(false);
798
799
 
799
800
  const scrollAreaRef = React.useCallback(
800
801
  (node: HTMLDivElement | null) => {
801
802
  const viewport = node?.querySelector<HTMLElement>(
802
803
  '[data-slot="scroll-area-viewport"]'
803
804
  );
804
- viewportRef.current = viewport ?? null;
805
805
  if (viewport) viewport.tabIndex = -1;
806
806
  if (typeof ref === "function") ref(node);
807
807
  else if (ref) ref.current = node;
@@ -809,23 +809,11 @@ const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
809
809
  [ref]
810
810
  );
811
811
 
812
- React.useEffect(() => {
813
- const vp = viewportRef.current;
814
- if (!vp) return;
815
-
816
- const check = () => setHasOverflow(vp.scrollHeight > vp.clientHeight);
817
- const ro = new ResizeObserver(check);
818
- ro.observe(vp);
819
- if (vp.firstElementChild) ro.observe(vp.firstElementChild);
820
-
821
- return () => ro.disconnect();
822
- }, []);
823
-
824
812
  return (
825
813
  <ScrollArea
826
814
  ref={scrollAreaRef}
827
815
  className={cn(
828
- "min-h-0 flex-1 group-data-[collapsible=icon]:overflow-hidden **:data-[slot=scroll-area-scrollbar]:w-1.5 **:data-[slot=scroll-area-scrollbar]:border-l-0 **:data-[slot=scroll-area-scrollbar]:p-0 [&_[data-slot=scroll-area-viewport]>div]:flex! [&_[data-slot=scroll-area-viewport]>div]:min-h-full [&_[data-slot=scroll-area-viewport]>div]:flex-col",
816
+ "min-h-0 flex-1 group-data-[collapsible=icon]:overflow-hidden **:data-[slot=scroll-area-scrollbar]:w-1 **:data-[slot=scroll-area-scrollbar]:border-l-0 **:data-[slot=scroll-area-scrollbar]:p-0 [&_[data-slot=scroll-area-viewport]>div]:flex! [&_[data-slot=scroll-area-viewport]>div]:min-h-full [&_[data-slot=scroll-area-viewport]>div]:flex-col",
829
817
  className
830
818
  )}
831
819
  dataHook={dataHook ?? "sidebar-content-scroll"}
@@ -834,7 +822,7 @@ const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
834
822
  >
835
823
  <nav
836
824
  aria-label={ariaLabel}
837
- className={cn("flex flex-col gap-2", hasOverflow && "pr-2")}
825
+ className="flex flex-col gap-2"
838
826
  data-slot="sidebar-content"
839
827
  >
840
828
  {children}
@@ -859,7 +847,7 @@ const SidebarGroup = React.forwardRef<HTMLDivElement, SidebarGroupProps>(
859
847
  return (
860
848
  <div
861
849
  ref={ref}
862
- className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
850
+ className={cn("relative flex w-full min-w-0 flex-col py-2", className)}
863
851
  data-hook={dataHook}
864
852
  data-slot="sidebar-group"
865
853
  {...props}
@@ -1167,7 +1155,7 @@ SidebarCollapseIcon.displayName = "SidebarCollapseIcon";
1167
1155
 
1168
1156
  const sidebarMenuButtonVariants = cva(
1169
1157
  [
1170
- "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-full px-6 py-2 text-left text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,opacity,width,height,padding] duration-150 ease-in-out hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-semibold data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:rounded-md [&>span:last-of-type]:truncate [&>svg]:shrink-0 [&>svg]:opacity-70 data-[active=true]:[&>svg]:opacity-100 group-data-[collapsible=icon]:[&>span]:hidden group-data-[collapsible=icon]:[&>div]:hidden",
1158
+ "peer/menu-button flex w-full items-center gap-3 overflow-hidden rounded-full px-6 py-2 text-left text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,opacity,width,height,padding] duration-150 ease-in-out hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-semibold data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:rounded-md [&>span:not([data-slot])]:truncate [&>svg]:shrink-0 [&>svg]:opacity-70 data-[active=true]:[&>svg]:opacity-100 group-data-[collapsible=icon]:[&>span]:hidden group-data-[collapsible=icon]:[&>div]:hidden",
1171
1159
  SIDEBAR_FOCUS_RING,
1172
1160
  ],
1173
1161
  {
@@ -1179,9 +1167,9 @@ const sidebarMenuButtonVariants = cva(
1179
1167
  collapsible:
1180
1168
  "[&>[data-collapse-icon]]:ml-auto [&>[data-collapse-icon]]:transition-transform data-[state=open]:[&>[data-collapse-icon]]:rotate-90",
1181
1169
  // Dropdown - has action menu (dots) on hover
1182
- dropdown: "group-has-[[data-sidebar=menu-action]]/menu-item:pr-8",
1170
+ dropdown: "group-has-[[data-slot=sidebar-menu-action]]/menu-item:pr-8",
1183
1171
  // Badge - has a number badge on the right (handled via SidebarMenuBadge)
1184
- badge: "group-has-[[data-sidebar=menu-badge]]/menu-item:pr-16",
1172
+ badge: "group-has-[[data-slot=sidebar-menu-badge]]/menu-item:pr-16",
1185
1173
  // Big Icon - larger icon with title and subtitle
1186
1174
  bigIcon:
1187
1175
  "h-auto flex-col items-start gap-1 rounded-lg p-3 [&>svg]:size-6 [&>svg]:rounded-md [&>svg]:bg-sidebar-foreground [&>svg]:p-1 [&>svg]:text-sidebar-background [&>svg]:opacity-100 hover:[&>svg]:bg-sidebar-foreground hover:[&>svg]:text-sidebar-background group-data-[collapsible=icon]:!size-10 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:[&>svg]:size-6",
@@ -1531,7 +1519,7 @@ const SidebarMenuSubButton = React.forwardRef<
1531
1519
  <Comp
1532
1520
  ref={ref}
1533
1521
  className={cn(
1534
- "text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-foreground flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 transition-[color,background-color,box-shadow,opacity] duration-150 ease-in-out outline-none disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-of-type]:truncate [&>svg]:shrink-0",
1522
+ "text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-foreground flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 transition-[color,background-color,box-shadow,opacity] duration-150 ease-in-out outline-none disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:not([data-slot])]:truncate [&>svg]:shrink-0",
1535
1523
  SIDEBAR_FOCUS_RING,
1536
1524
  "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
1537
1525
  size === SidebarMenuSubButtonSize.SM && "text-xs",
@@ -43,10 +43,7 @@ const AlertTitle = React.forwardRef<
43
43
  >(({ className, ...props }, ref) => (
44
44
  <div
45
45
  ref={ref}
46
- className={cn(
47
- "overflow-hidden leading-5 font-medium text-ellipsis whitespace-nowrap",
48
- className
49
- )}
46
+ className={cn("leading-5 font-medium break-words", className)}
50
47
  data-slot="alert-title"
51
48
  {...props}
52
49
  />
@@ -0,0 +1,143 @@
1
+ import * as React from "react";
2
+ import { cva, type VariantProps } from "class-variance-authority";
3
+ import {
4
+ MotifCircle,
5
+ MotifSparkle,
6
+ MotifStarburst,
7
+ MotifSunrise,
8
+ } from "@brightlocal/icons";
9
+ import { cn } from "@brightlocal/ui-components/lib/utils";
10
+
11
+ /**
12
+ * Brand motif shape rendered as the backdrop (lg) or as a standalone mark (sm/md).
13
+ */
14
+ type BrandIllustrationMotifShape =
15
+ | "sparkle"
16
+ | "starburst"
17
+ | "circle"
18
+ | "sunrise";
19
+
20
+ const motifIcons: Record<
21
+ BrandIllustrationMotifShape,
22
+ React.ComponentType<{ size?: number | string; className?: string }>
23
+ > = {
24
+ sparkle: MotifSparkle,
25
+ starburst: MotifStarburst,
26
+ circle: MotifCircle,
27
+ sunrise: MotifSunrise,
28
+ };
29
+
30
+ const brandIllustrationMotifStyles = cva(
31
+ "relative inline-flex items-center justify-center",
32
+ {
33
+ variants: {
34
+ size: {
35
+ sm: "size-6 text-primary",
36
+ md: "size-12 text-primary",
37
+ lg: "size-80 text-muted",
38
+ },
39
+ },
40
+ defaultVariants: {
41
+ size: "lg",
42
+ },
43
+ }
44
+ );
45
+
46
+ interface BrandIllustrationMotifProps
47
+ extends
48
+ React.HTMLAttributes<HTMLDivElement>,
49
+ VariantProps<typeof brandIllustrationMotifStyles> {
50
+ /**
51
+ * Required data-hook attribute for testing and component identification
52
+ */
53
+ dataHook: string;
54
+ /**
55
+ * Which brand motif shape to render.
56
+ */
57
+ motif: BrandIllustrationMotifShape;
58
+ /**
59
+ * Size of the composition.
60
+ * - `"lg"`: 320px muted motif backdrop with a centred illustration slot
61
+ * - `"md"`: 48px standalone green motif mark
62
+ * - `"sm"`: 24px standalone green motif mark
63
+ * @default "lg"
64
+ */
65
+ size?: "sm" | "md" | "lg";
66
+ /**
67
+ * The illustration to render over the motif backdrop — typically a brand
68
+ * illustration such as RobotAiA at 144px. Only rendered for the `lg`
69
+ * size; `sm`/`md` show the motif mark alone.
70
+ */
71
+ children?: React.ReactNode;
72
+ /**
73
+ * Optional tracking element identifier for analytics
74
+ */
75
+ trackingEl?: string;
76
+ /**
77
+ * Optional tracking label for analytics
78
+ */
79
+ trackingLabel?: string;
80
+ }
81
+
82
+ /**
83
+ * BrandIllustrationMotif — a brand illustration composed over a decorative
84
+ * motif shape (Figma: BrandIllustrationsMotifs).
85
+ *
86
+ * At `lg` the motif renders as a muted 320px backdrop behind the illustration
87
+ * passed as children; at `sm`/`md` it renders as a small green motif mark.
88
+ * The `sunrise` + `lg` combination slowly rotates its backdrop (60s linear,
89
+ * per the design motion spec); the global reduced-motion handling disables
90
+ * the rotation automatically.
91
+ */
92
+ const BrandIllustrationMotif = React.forwardRef<
93
+ HTMLDivElement,
94
+ BrandIllustrationMotifProps
95
+ >(
96
+ (
97
+ {
98
+ className,
99
+ motif,
100
+ size = "lg",
101
+ dataHook,
102
+ trackingEl,
103
+ trackingLabel,
104
+ children,
105
+ ...props
106
+ },
107
+ ref
108
+ ) => {
109
+ const MotifIcon = motifIcons[motif];
110
+ const spinning = motif === "sunrise" && size === "lg";
111
+
112
+ return (
113
+ <div
114
+ ref={ref}
115
+ className={cn(brandIllustrationMotifStyles({ size }), className)}
116
+ data-hook={dataHook}
117
+ data-motif={motif}
118
+ data-size={size}
119
+ data-slot="brand-illustration-motif"
120
+ data-tracking-el={trackingEl ?? "brand-illustration-motif"}
121
+ data-tracking-label={trackingLabel}
122
+ {...props}
123
+ >
124
+ <div
125
+ aria-hidden="true"
126
+ className={cn("absolute inset-0", spinning && "animate-motif-spin")}
127
+ >
128
+ <MotifIcon className="size-full" size="100%" />
129
+ </div>
130
+ {size === "lg" && children ? (
131
+ <div className="relative flex size-36 items-center justify-center">
132
+ {children}
133
+ </div>
134
+ ) : null}
135
+ </div>
136
+ );
137
+ }
138
+ );
139
+
140
+ BrandIllustrationMotif.displayName = "BrandIllustrationMotif";
141
+
142
+ export { BrandIllustrationMotif };
143
+ export type { BrandIllustrationMotifProps, BrandIllustrationMotifShape };