@brightlocal/ui-components 3.0.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 (235) hide show
  1. package/README.md +7 -1
  2. package/component-meta.json +749 -53
  3. package/deprecations.json +114 -4
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.d.ts +36 -0
  6. package/dist/accordion.d.ts.map +1 -1
  7. package/dist/accordion.js +74 -61
  8. package/dist/alert-dialog.cjs +1 -1
  9. package/dist/alert-dialog.d.ts +32 -3
  10. package/dist/alert-dialog.d.ts.map +1 -1
  11. package/dist/alert-dialog.js +61 -58
  12. package/dist/alert.cjs +1 -1
  13. package/dist/alert.d.ts.map +1 -1
  14. package/dist/alert.js +58 -57
  15. package/dist/badge.cjs +1 -1
  16. package/dist/badge.d.ts +9 -0
  17. package/dist/badge.d.ts.map +1 -1
  18. package/dist/badge.js +50 -30
  19. package/dist/banner.cjs +1 -0
  20. package/dist/banner.d.ts +81 -0
  21. package/dist/banner.d.ts.map +1 -0
  22. package/dist/banner.js +176 -0
  23. package/dist/blocks/empty-state.cjs +1 -1
  24. package/dist/blocks/empty-state.d.ts +4 -3
  25. package/dist/blocks/empty-state.d.ts.map +1 -1
  26. package/dist/blocks/empty-state.js +50 -57
  27. package/dist/blocks/progress-state.d.ts +2 -2
  28. package/dist/blocks/sidebar.cjs +1 -1
  29. package/dist/blocks/sidebar.d.ts +17 -0
  30. package/dist/blocks/sidebar.d.ts.map +1 -1
  31. package/dist/blocks/sidebar.js +8 -2
  32. package/dist/brand-illustration-motif.d.ts +1 -1
  33. package/dist/button-group.cjs +1 -0
  34. package/dist/button-group.d.ts +36 -0
  35. package/dist/button-group.d.ts.map +1 -0
  36. package/dist/button-group.js +47 -0
  37. package/dist/button.cjs +1 -1
  38. package/dist/button.js +1 -1
  39. package/dist/card.cjs +1 -1
  40. package/dist/card.d.ts +105 -7
  41. package/dist/card.d.ts.map +1 -1
  42. package/dist/card.js +198 -101
  43. package/dist/chart.cjs +3 -3
  44. package/dist/chart.d.ts +270 -24
  45. package/dist/chart.d.ts.map +1 -1
  46. package/dist/chart.js +497 -322
  47. package/dist/checkbox.cjs +1 -1
  48. package/dist/checkbox.d.ts +1 -1
  49. package/dist/checkbox.d.ts.map +1 -1
  50. package/dist/checkbox.js +2 -1
  51. package/dist/chip.cjs +1 -1
  52. package/dist/chip.d.ts +38 -4
  53. package/dist/chip.d.ts.map +1 -1
  54. package/dist/chip.js +95 -81
  55. package/dist/combobox.cjs +1 -1
  56. package/dist/combobox.js +2 -2
  57. package/dist/command.cjs +1 -1
  58. package/dist/command.d.ts +23 -1
  59. package/dist/command.d.ts.map +1 -1
  60. package/dist/command.js +251 -225
  61. package/dist/data-table.cjs +1 -1
  62. package/dist/data-table.d.ts +201 -23
  63. package/dist/data-table.d.ts.map +1 -1
  64. package/dist/data-table.js +712 -568
  65. package/dist/date-picker.cjs +1 -1
  66. package/dist/date-picker.d.ts +13 -5
  67. package/dist/date-picker.d.ts.map +1 -1
  68. package/dist/date-picker.js +54 -53
  69. package/dist/field.cjs +1 -1
  70. package/dist/field.d.ts +8 -1
  71. package/dist/field.d.ts.map +1 -1
  72. package/dist/field.js +79 -52
  73. package/dist/global-layout.cjs +1 -1
  74. package/dist/global-layout.d.ts +105 -13
  75. package/dist/global-layout.d.ts.map +1 -1
  76. package/dist/global-layout.js +146 -129
  77. package/dist/grid.d.ts +26 -3
  78. package/dist/grid.d.ts.map +1 -1
  79. package/dist/hooks/use-breakpoint.cjs +1 -1
  80. package/dist/hooks/use-breakpoint.d.ts +1 -1
  81. package/dist/hooks/use-breakpoint.d.ts.map +1 -1
  82. package/dist/hooks/use-breakpoint.js +1 -0
  83. package/dist/hooks/use-mobile.cjs +1 -0
  84. package/dist/hooks/use-mobile.js +8 -0
  85. package/dist/index.cjs +1 -1
  86. package/dist/index.d.ts +6 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +594 -553
  89. package/dist/info-tooltip.cjs +1 -0
  90. package/dist/info-tooltip.d.ts +39 -0
  91. package/dist/info-tooltip.d.ts.map +1 -0
  92. package/dist/info-tooltip.js +41 -0
  93. package/dist/input-chip.cjs +1 -1
  94. package/dist/input-chip.js +1 -1
  95. package/dist/input-group.cjs +1 -1
  96. package/dist/input-group.d.ts +33 -2
  97. package/dist/input-group.d.ts.map +1 -1
  98. package/dist/input-group.js +167 -54
  99. package/dist/input-otp.cjs +1 -1
  100. package/dist/input-otp.js +9 -9
  101. package/dist/input-password.cjs +1 -1
  102. package/dist/input-password.d.ts +45 -15
  103. package/dist/input-password.d.ts.map +1 -1
  104. package/dist/input-password.js +31 -30
  105. package/dist/input.cjs +1 -1
  106. package/dist/input.js +10 -10
  107. package/dist/lib/block-illustration.cjs +1 -1
  108. package/dist/lib/block-illustration.d.ts +4 -1
  109. package/dist/lib/block-illustration.d.ts.map +1 -1
  110. package/dist/lib/block-illustration.js +12 -11
  111. package/dist/lib/empty-chip.cjs +1 -0
  112. package/dist/lib/empty-chip.d.ts +4 -0
  113. package/dist/lib/empty-chip.d.ts.map +1 -0
  114. package/dist/lib/empty-chip.js +13 -0
  115. package/dist/lib/utils.cjs +1 -1
  116. package/dist/lib/utils.d.ts.map +1 -1
  117. package/dist/lib/utils.js +4 -3
  118. package/dist/list.cjs +1 -1
  119. package/dist/list.js +1 -1
  120. package/dist/multi-select-filter.cjs +1 -0
  121. package/dist/multi-select-filter.d.ts +178 -0
  122. package/dist/multi-select-filter.d.ts.map +1 -0
  123. package/dist/multi-select-filter.js +463 -0
  124. package/dist/pagination.cjs +1 -1
  125. package/dist/pagination.d.ts +3 -0
  126. package/dist/pagination.d.ts.map +1 -1
  127. package/dist/pagination.js +57 -57
  128. package/dist/progress.cjs +1 -1
  129. package/dist/progress.d.ts +123 -16
  130. package/dist/progress.d.ts.map +1 -1
  131. package/dist/progress.js +89 -75
  132. package/dist/rating.cjs +1 -1
  133. package/dist/rating.js +18 -18
  134. package/dist/relative-date.cjs +1 -0
  135. package/dist/relative-date.d.ts +65 -0
  136. package/dist/relative-date.d.ts.map +1 -0
  137. package/dist/relative-date.js +128 -0
  138. package/dist/scroll-area.cjs +1 -1
  139. package/dist/scroll-area.d.ts +15 -6
  140. package/dist/scroll-area.d.ts.map +1 -1
  141. package/dist/scroll-area.js +38 -36
  142. package/dist/select.cjs +2 -2
  143. package/dist/select.d.ts +24 -3
  144. package/dist/select.d.ts.map +1 -1
  145. package/dist/select.js +130 -110
  146. package/dist/sheet.cjs +1 -1
  147. package/dist/sheet.d.ts +78 -2
  148. package/dist/sheet.d.ts.map +1 -1
  149. package/dist/sheet.js +192 -85
  150. package/dist/single-select-filter.cjs +1 -0
  151. package/dist/single-select-filter.d.ts +81 -0
  152. package/dist/single-select-filter.d.ts.map +1 -0
  153. package/dist/single-select-filter.js +226 -0
  154. package/dist/sonner.cjs +1 -1
  155. package/dist/sonner.d.ts.map +1 -1
  156. package/dist/sonner.js +22 -22
  157. package/dist/split-layout.cjs +1 -1
  158. package/dist/split-layout.d.ts +1 -1
  159. package/dist/split-layout.js +13 -13
  160. package/dist/table.cjs +1 -1
  161. package/dist/table.d.ts +45 -4
  162. package/dist/table.d.ts.map +1 -1
  163. package/dist/table.js +90 -73
  164. package/dist/tabs.cjs +1 -1
  165. package/dist/tabs.d.ts +12 -1
  166. package/dist/tabs.d.ts.map +1 -1
  167. package/dist/tabs.js +148 -126
  168. package/dist/textarea.cjs +1 -1
  169. package/dist/textarea.js +1 -1
  170. package/dist/tooltip.cjs +1 -1
  171. package/dist/tooltip.d.ts +38 -36
  172. package/dist/tooltip.d.ts.map +1 -1
  173. package/dist/tooltip.js +262 -73
  174. package/dist/typography-heading.cjs +1 -1
  175. package/dist/typography-heading.d.ts +13 -0
  176. package/dist/typography-heading.d.ts.map +1 -1
  177. package/dist/typography-heading.js +32 -21
  178. package/dist/typography-text.cjs +1 -1
  179. package/dist/typography-text.d.ts +15 -2
  180. package/dist/typography-text.d.ts.map +1 -1
  181. package/dist/typography-text.js +35 -24
  182. package/dist/typography.d.ts +1 -1
  183. package/package.json +5 -6
  184. package/src/blocks/empty-state.tsx +17 -24
  185. package/src/blocks/progress-state.tsx +2 -2
  186. package/src/blocks/sidebar.tsx +26 -2
  187. package/src/components/accordion.tsx +82 -27
  188. package/src/components/alert-dialog.tsx +50 -5
  189. package/src/components/alert.tsx +16 -8
  190. package/src/components/badge.tsx +40 -3
  191. package/src/components/banner.tsx +288 -0
  192. package/src/components/brand-illustration-motif.tsx +1 -1
  193. package/src/components/button-group.tsx +112 -0
  194. package/src/components/button.tsx +1 -1
  195. package/src/components/card.tsx +249 -27
  196. package/src/components/chart.tsx +586 -53
  197. package/src/components/checkbox.tsx +1 -1
  198. package/src/components/chip.tsx +83 -10
  199. package/src/components/combobox.tsx +2 -2
  200. package/src/components/command.tsx +56 -4
  201. package/src/components/data-table.tsx +842 -199
  202. package/src/components/date-picker.tsx +18 -7
  203. package/src/components/field.tsx +81 -12
  204. package/src/components/global-layout.tsx +176 -38
  205. package/src/components/grid.tsx +34 -3
  206. package/src/components/info-tooltip.tsx +94 -0
  207. package/src/components/input-chip.tsx +1 -1
  208. package/src/components/input-group.tsx +246 -11
  209. package/src/components/input-otp.tsx +1 -1
  210. package/src/components/input-password.tsx +56 -22
  211. package/src/components/input.tsx +1 -1
  212. package/src/components/list.tsx +1 -1
  213. package/src/components/multi-select-filter.tsx +912 -0
  214. package/src/components/pagination.tsx +10 -3
  215. package/src/components/progress.tsx +190 -31
  216. package/src/components/rating.tsx +1 -1
  217. package/src/components/relative-date.tsx +230 -0
  218. package/src/components/scroll-area.tsx +23 -10
  219. package/src/components/select.tsx +65 -11
  220. package/src/components/sheet.tsx +240 -4
  221. package/src/components/single-select-filter.tsx +443 -0
  222. package/src/components/sonner.tsx +16 -5
  223. package/src/components/split-layout.tsx +2 -2
  224. package/src/components/table.tsx +71 -11
  225. package/src/components/tabs.tsx +93 -46
  226. package/src/components/textarea.tsx +1 -1
  227. package/src/components/tooltip.tsx +440 -68
  228. package/src/components/typography-heading.tsx +24 -0
  229. package/src/components/typography-text.tsx +27 -3
  230. package/src/components/typography.tsx +1 -1
  231. package/src/hooks/use-breakpoint.ts +2 -1
  232. package/src/index.ts +6 -0
  233. package/src/lib/block-illustration.tsx +5 -1
  234. package/src/lib/empty-chip.ts +24 -0
  235. package/src/lib/utils.ts +1 -0
@@ -126,6 +126,14 @@ type AlertContentProps = AlertContentBaseProps &
126
126
  }
127
127
  );
128
128
 
129
+ // DS-1031: below `md` the action drops under the text, left-aligned with
130
+ // it (pl-7 = 16px icon + 12px gap), so the copy keeps the full width on
131
+ // phones. From `md` up the action sits beside the text, vertically centered.
132
+ const ALERT_CONTENT_LAYOUT =
133
+ "max-md:flex-col max-md:items-stretch items-center";
134
+ const ALERT_ACTION_LAYOUT =
135
+ "shrink-0 self-center max-md:self-start max-md:pl-7";
136
+
129
137
  function AlertSuccess({
130
138
  title,
131
139
  description,
@@ -137,7 +145,7 @@ function AlertSuccess({
137
145
  }: AlertContentProps) {
138
146
  return (
139
147
  <Alert
140
- className={cn("items-center", className)}
148
+ className={cn(ALERT_CONTENT_LAYOUT, className)}
141
149
  data-hook={dataHook}
142
150
  data-tracking-el={trackingEl}
143
151
  data-tracking-label={trackingLabel}
@@ -152,7 +160,7 @@ function AlertSuccess({
152
160
  )}
153
161
  </div>
154
162
  </div>
155
- {action && <div className="shrink-0 self-center">{action}</div>}
163
+ {action && <div className={ALERT_ACTION_LAYOUT}>{action}</div>}
156
164
  </Alert>
157
165
  );
158
166
  }
@@ -168,7 +176,7 @@ function AlertInfo({
168
176
  }: AlertContentProps) {
169
177
  return (
170
178
  <Alert
171
- className={cn("items-center", className)}
179
+ className={cn(ALERT_CONTENT_LAYOUT, className)}
172
180
  data-hook={dataHook}
173
181
  data-tracking-el={trackingEl}
174
182
  data-tracking-label={trackingLabel}
@@ -183,7 +191,7 @@ function AlertInfo({
183
191
  )}
184
192
  </div>
185
193
  </div>
186
- {action && <div className="shrink-0 self-center">{action}</div>}
194
+ {action && <div className={ALERT_ACTION_LAYOUT}>{action}</div>}
187
195
  </Alert>
188
196
  );
189
197
  }
@@ -199,7 +207,7 @@ function AlertDestructive({
199
207
  }: AlertContentProps) {
200
208
  return (
201
209
  <Alert
202
- className={cn("items-center", className)}
210
+ className={cn(ALERT_CONTENT_LAYOUT, className)}
203
211
  data-hook={dataHook}
204
212
  data-tracking-el={trackingEl}
205
213
  data-tracking-label={trackingLabel}
@@ -214,7 +222,7 @@ function AlertDestructive({
214
222
  )}
215
223
  </div>
216
224
  </div>
217
- {action && <div className="shrink-0 self-center">{action}</div>}
225
+ {action && <div className={ALERT_ACTION_LAYOUT}>{action}</div>}
218
226
  </Alert>
219
227
  );
220
228
  }
@@ -230,7 +238,7 @@ function AlertWarning({
230
238
  }: AlertContentProps) {
231
239
  return (
232
240
  <Alert
233
- className={cn("items-center", className)}
241
+ className={cn(ALERT_CONTENT_LAYOUT, className)}
234
242
  data-hook={dataHook}
235
243
  data-tracking-el={trackingEl}
236
244
  data-tracking-label={trackingLabel}
@@ -245,7 +253,7 @@ function AlertWarning({
245
253
  )}
246
254
  </div>
247
255
  </div>
248
- {action && <div className="shrink-0 self-center">{action}</div>}
256
+ {action && <div className={ALERT_ACTION_LAYOUT}>{action}</div>}
249
257
  </Alert>
250
258
  );
251
259
  }
@@ -3,6 +3,7 @@ import { Slot } from "@radix-ui/react-slot";
3
3
  import { cva, type VariantProps } from "class-variance-authority";
4
4
 
5
5
  import { cn } from "@brightlocal/ui-components/lib/utils";
6
+ import { useDevWarning } from "@brightlocal/ui-components/lib/use-dev-warning";
6
7
 
7
8
  const badgeVariants = cva(
8
9
  [
@@ -16,8 +17,11 @@ const badgeVariants = cva(
16
17
  // Typography — type-scale role for badges (12/16 Figma 500; the weight
17
18
  // drop from the old semibold is intentional, DS-925)
18
19
  "text-label-sm whitespace-nowrap",
19
- // Icons
20
+ // Icons — direct children, plus the one `srLabel` wrapper (display:
21
+ // contents) so an icon inside it keeps its size without resizing any
22
+ // other nested SVG
20
23
  "[&>svg]:size-3 [&>svg]:pointer-events-none",
24
+ "[&>.contents>svg]:size-3 [&>.contents>svg]:pointer-events-none",
21
25
  // Transition
22
26
  "transition-[color,background-color,border-color,box-shadow] duration-fast ease-out",
23
27
  // Focus
@@ -67,6 +71,15 @@ interface BadgeProps
67
71
  * Tracking label for analytics context
68
72
  */
69
73
  trackingLabel?: string;
74
+ /**
75
+ * Screen-reader phrase that replaces the visible content. A bare numeral
76
+ * tells a screen-reader user nothing about what it counts, so a count
77
+ * badge passes the phrase here ("3 active", "2 selected") and the numeral
78
+ * stays visual only. Ignored with `asChild` — the Slot's single child is
79
+ * the consumer's element, so put the phrase inside it instead.
80
+ * @example srLabel="3 active"
81
+ */
82
+ srLabel?: string;
70
83
  }
71
84
 
72
85
  /**
@@ -82,12 +95,21 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
82
95
  dataHook,
83
96
  trackingEl,
84
97
  trackingLabel,
98
+ srLabel,
85
99
  children,
86
100
  ...props
87
101
  },
88
102
  ref
89
103
  ) => {
90
104
  const Comp = asChild ? Slot : "span";
105
+ const srLabelApplies = srLabel !== undefined && !asChild;
106
+
107
+ useDevWarning(
108
+ () => asChild && srLabel !== undefined,
109
+ "srLabel is set on a <Badge asChild>. Slot renders the child element as-is, " +
110
+ "so the phrase cannot be injected — add an sr-only span inside the child instead.",
111
+ [asChild, srLabel]
112
+ );
91
113
 
92
114
  // Check if children is a single digit number (0-9)
93
115
  const isNumberBadge =
@@ -96,7 +118,13 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
96
118
  return (
97
119
  <Comp
98
120
  ref={ref}
99
- className={cn(badgeVariants({ variant }), className)}
121
+ className={cn(
122
+ badgeVariants({ variant }),
123
+ /* sr-only is absolutely positioned: the badge is its positioning
124
+ context so the phrase never escapes a scroll viewport. */
125
+ srLabelApplies && "relative",
126
+ className
127
+ )}
100
128
  data-hook={dataHook}
101
129
  data-number={isNumberBadge}
102
130
  data-slot="badge"
@@ -104,7 +132,16 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
104
132
  data-tracking-label={trackingLabel}
105
133
  {...props}
106
134
  >
107
- {children}
135
+ {srLabelApplies ? (
136
+ <>
137
+ <span aria-hidden="true" className="contents">
138
+ {children}
139
+ </span>
140
+ <span className="sr-only">{srLabel}</span>
141
+ </>
142
+ ) : (
143
+ children
144
+ )}
108
145
  </Comp>
109
146
  );
110
147
  }
@@ -0,0 +1,288 @@
1
+ import * as React from "react";
2
+ import { cva } from "class-variance-authority";
3
+ import { X } from "@brightlocal/icons";
4
+
5
+ import { Button } from "@brightlocal/ui-components/button";
6
+ import { cn } from "@brightlocal/ui-components/lib/utils";
7
+
8
+ /** Highlight surface the banner sits on — one per `highlight-*` token role */
9
+ type BannerVariant = "sky" | "violet";
10
+
11
+ /** Document outline level for the banner title */
12
+ type BannerTitleLevel = 1 | 2 | 3 | 4 | 5 | 6;
13
+
14
+ // Compact on purpose: a banner is a note, not a hero. Below `md` the parts
15
+ // stack (illustration, content, actions); from `md` they sit in one row with
16
+ // the actions vertically centred on the right.
17
+ const bannerVariants = cva(
18
+ "relative flex w-full flex-col gap-3 rounded-xl p-4 md:flex-row md:items-center md:gap-5 md:pl-5",
19
+ {
20
+ variants: {
21
+ variant: {
22
+ sky: "bg-highlight-sky text-highlight-sky-foreground",
23
+ violet: "bg-highlight-violet text-highlight-violet-foreground",
24
+ },
25
+ dismissible: {
26
+ // Keep the content clear of the absolutely positioned close button.
27
+ true: "pr-12 md:pr-14",
28
+ false: "",
29
+ },
30
+ },
31
+ defaultVariants: {
32
+ variant: "sky",
33
+ dismissible: false,
34
+ },
35
+ }
36
+ );
37
+
38
+ const descriptionColorMap: Record<BannerVariant, string> = {
39
+ sky: "text-highlight-sky-muted-foreground",
40
+ violet: "text-highlight-violet-muted-foreground",
41
+ };
42
+
43
+ const dismissColorMap: Record<BannerVariant, string> = {
44
+ sky: "text-highlight-sky-foreground hover:bg-highlight-sky-foreground/10",
45
+ violet:
46
+ "text-highlight-violet-foreground hover:bg-highlight-violet-foreground/10",
47
+ };
48
+
49
+ // The parts read the surface from the root, so colours and the region's
50
+ // accessible name stay the component's job whatever the composition.
51
+ interface BannerContextValue {
52
+ variant: BannerVariant;
53
+ titleId: string;
54
+ registerTitle: () => () => void;
55
+ }
56
+
57
+ const BannerContext = React.createContext<BannerContextValue>({
58
+ variant: "sky",
59
+ titleId: "",
60
+ registerTitle: () => () => {},
61
+ });
62
+
63
+ /** Props for the Banner root */
64
+ interface BannerProps extends React.ComponentPropsWithoutRef<"section"> {
65
+ /** Required test hook identifier */
66
+ dataHook: string;
67
+ /**
68
+ * Highlight surface. Sky is the default; violet is the alternative when
69
+ * two banners must read as different invitations.
70
+ * @default "sky"
71
+ */
72
+ variant?: BannerVariant;
73
+ /**
74
+ * Called when the close button is pressed. The close button renders only
75
+ * when this is set; the consumer decides where the dismissal is remembered.
76
+ */
77
+ onDismiss?: () => void;
78
+ /**
79
+ * Accessible label for the close button.
80
+ * @default "Dismiss"
81
+ */
82
+ dismissLabel?: string;
83
+ /** Analytics element identifier */
84
+ trackingEl?: string;
85
+ /** Analytics label */
86
+ trackingLabel?: string;
87
+ }
88
+
89
+ /**
90
+ * Branded, dismissible banner that invites the user to do something optional
91
+ * — an invitation, not a fault. Use an Alert when something happened.
92
+ *
93
+ * Compose it from `BannerIllustration`, `BannerContent` (with `BannerTitle`
94
+ * and `BannerDescription`) and `BannerActions`. The root owns the surface,
95
+ * the layout and the close button.
96
+ */
97
+ const Banner = React.forwardRef<HTMLElement, BannerProps>(
98
+ (
99
+ {
100
+ className,
101
+ variant = "sky",
102
+ onDismiss,
103
+ dismissLabel,
104
+ dataHook,
105
+ trackingEl,
106
+ trackingLabel,
107
+ children,
108
+ ...props
109
+ },
110
+ ref
111
+ ) => {
112
+ const titleId = React.useId();
113
+ // Only point aria-labelledby at a title that is actually rendered.
114
+ const [titleCount, setTitleCount] = React.useState(0);
115
+ const registerTitle = React.useCallback(() => {
116
+ setTitleCount((count) => count + 1);
117
+ return () => setTitleCount((count) => count - 1);
118
+ }, []);
119
+ const context = React.useMemo(
120
+ () => ({ variant, titleId, registerTitle }),
121
+ [variant, titleId, registerTitle]
122
+ );
123
+ const dismissible = onDismiss != null;
124
+
125
+ return (
126
+ <BannerContext.Provider value={context}>
127
+ <section
128
+ ref={ref}
129
+ aria-labelledby={titleCount > 0 ? titleId : undefined}
130
+ className={cn(bannerVariants({ variant, dismissible }), className)}
131
+ data-hook={dataHook}
132
+ data-slot="banner"
133
+ data-tracking-el={trackingEl || `banner-${variant}`}
134
+ data-tracking-label={trackingLabel}
135
+ {...props}
136
+ >
137
+ {children}
138
+ {dismissible && (
139
+ <Button
140
+ iconOnly
141
+ className={cn("absolute top-2 right-2", dismissColorMap[variant])}
142
+ dataHook={`${dataHook}-dismiss`}
143
+ variant="ghost"
144
+ onClick={onDismiss}
145
+ >
146
+ <X />
147
+ <span className="sr-only">{dismissLabel ?? "Dismiss"}</span>
148
+ </Button>
149
+ )}
150
+ </section>
151
+ </BannerContext.Provider>
152
+ );
153
+ }
154
+ );
155
+ Banner.displayName = "Banner";
156
+
157
+ /** Shared props for the Banner parts */
158
+ interface BannerPartProps extends React.HTMLAttributes<HTMLDivElement> {
159
+ /** Test hook identifier */
160
+ dataHook?: string;
161
+ }
162
+
163
+ /**
164
+ * Decorative illustration from `@brightlocal/illustrations`, sized by the
165
+ * banner (56px, 64px from `md`). Hidden from assistive technologies. Leave
166
+ * the illustration's `variant` unset so it follows light/dark mode.
167
+ */
168
+ const BannerIllustration = React.forwardRef<HTMLDivElement, BannerPartProps>(
169
+ ({ className, dataHook, ...props }, ref) => (
170
+ <div
171
+ ref={ref}
172
+ aria-hidden="true"
173
+ className={cn(
174
+ "flex size-14 shrink-0 md:size-16 [&>svg]:size-full",
175
+ className
176
+ )}
177
+ data-hook={dataHook}
178
+ data-slot="banner-illustration"
179
+ {...props}
180
+ />
181
+ )
182
+ );
183
+ BannerIllustration.displayName = "BannerIllustration";
184
+
185
+ /**
186
+ * The text column — takes the remaining width. Holds `BannerTitle` and
187
+ * `BannerDescription`, plus anything else the composition needs.
188
+ */
189
+ const BannerContent = React.forwardRef<HTMLDivElement, BannerPartProps>(
190
+ ({ className, dataHook, ...props }, ref) => (
191
+ <div
192
+ ref={ref}
193
+ className={cn("flex min-w-0 flex-1 flex-col gap-1", className)}
194
+ data-hook={dataHook}
195
+ data-slot="banner-content"
196
+ {...props}
197
+ />
198
+ )
199
+ );
200
+ BannerContent.displayName = "BannerContent";
201
+
202
+ /** Props for BannerTitle */
203
+ interface BannerTitleProps extends Omit<BannerPartProps, "id"> {
204
+ /**
205
+ * Document outline level — renders the title as the corresponding heading
206
+ * element (`h1`–`h6`). With no `level` the title renders a `div`; it still
207
+ * names the banner region either way.
208
+ * @example <BannerTitle level={2}>Connect Facebook</BannerTitle>
209
+ */
210
+ level?: BannerTitleLevel;
211
+ }
212
+
213
+ /** Heading — what the user is being invited to do. Names the banner region. */
214
+ const BannerTitle = React.forwardRef<HTMLHeadingElement, BannerTitleProps>(
215
+ ({ className, level, dataHook, ...props }, ref) => {
216
+ const { titleId, registerTitle } = React.useContext(BannerContext);
217
+ React.useLayoutEffect(() => registerTitle(), [registerTitle]);
218
+ const Title = level ? (`h${level}` as const) : "div";
219
+
220
+ return (
221
+ <Title
222
+ ref={ref}
223
+ className={cn("text-heading-subsection break-words", className)}
224
+ data-hook={dataHook}
225
+ data-slot="banner-title"
226
+ id={titleId}
227
+ {...props}
228
+ />
229
+ );
230
+ }
231
+ );
232
+ BannerTitle.displayName = "BannerTitle";
233
+
234
+ /** One or two lines of supporting copy, in the surface's muted text role */
235
+ const BannerDescription = React.forwardRef<HTMLDivElement, BannerPartProps>(
236
+ ({ className, dataHook, ...props }, ref) => {
237
+ const { variant } = React.useContext(BannerContext);
238
+
239
+ return (
240
+ <div
241
+ ref={ref}
242
+ className={cn(
243
+ "text-body-sm break-words",
244
+ descriptionColorMap[variant],
245
+ className
246
+ )}
247
+ data-hook={dataHook}
248
+ data-slot="banner-description"
249
+ {...props}
250
+ />
251
+ );
252
+ }
253
+ );
254
+ BannerDescription.displayName = "BannerDescription";
255
+
256
+ /**
257
+ * The action(s) — usually one outline `sm` Button. Sits on the right from
258
+ * `md`, under the text on phones.
259
+ */
260
+ const BannerActions = React.forwardRef<HTMLDivElement, BannerPartProps>(
261
+ ({ className, dataHook, ...props }, ref) => (
262
+ <div
263
+ ref={ref}
264
+ className={cn("flex shrink-0 flex-wrap items-center gap-2", className)}
265
+ data-hook={dataHook}
266
+ data-slot="banner-actions"
267
+ {...props}
268
+ />
269
+ )
270
+ );
271
+ BannerActions.displayName = "BannerActions";
272
+
273
+ export {
274
+ Banner,
275
+ BannerIllustration,
276
+ BannerContent,
277
+ BannerTitle,
278
+ BannerDescription,
279
+ BannerActions,
280
+ bannerVariants,
281
+ };
282
+ export type {
283
+ BannerProps,
284
+ BannerPartProps,
285
+ BannerTitleProps,
286
+ BannerVariant,
287
+ BannerTitleLevel,
288
+ };
@@ -65,7 +65,7 @@ interface BrandIllustrationMotifProps
65
65
  size?: "sm" | "md" | "lg";
66
66
  /**
67
67
  * The illustration to render over the motif backdrop — typically a brand
68
- * illustration such as RobotAiA at 144px. Only rendered for the `lg`
68
+ * illustration such as Robot at 144px. Only rendered for the `lg`
69
69
  * size; `sm`/`md` show the motif mark alone.
70
70
  */
71
71
  children?: React.ReactNode;
@@ -0,0 +1,112 @@
1
+ import * as React from "react";
2
+ import { cva } from "class-variance-authority";
3
+
4
+ import { cn } from "@brightlocal/ui-components/lib/utils";
5
+
6
+ /* The group owns only the joining: it zeroes the radii on the shared edges,
7
+ collapses the doubled border between bordered neighbours, and raises the
8
+ focused/open child above its siblings so the focus shadow paints over the
9
+ joined edge. Children keep their own outer-edge shape — a Button end stays
10
+ a pill, a SelectTrigger end stays rounded-sm — because the child's variant,
11
+ not the group, owns its identity.
12
+
13
+ A joined SelectTrigger keeps BOTH its side borders and the neighbour
14
+ touching it gives up its own: Button borders are border (neutral-200) while
15
+ the trigger's are input (neutral-300), so letting each seam fall to "the
16
+ child on the left" would draw the trigger's two seams in different colours.
17
+
18
+ Base order: layout, the corner/border joins, the z-raise that lets a
19
+ focused/open child paint its shadow over the joined neighbour's edge, then
20
+ the SelectTrigger width fix: a joined trigger hugs its value instead of
21
+ stretching. The `.w-full` guard is the discriminator — SelectTrigger runs
22
+ className through twMerge, so its default `w-full` survives only when the
23
+ consumer set no width; an explicit width (e.g. `w-44`) replaces it and
24
+ this rule stops matching. */
25
+ const buttonGroupVariants = cva([
26
+ "flex w-fit items-stretch",
27
+ "[&>*:not(:first-child)]:rounded-l-none",
28
+ "[&>*:not(:last-child)]:rounded-r-none",
29
+ "[&>*:not(:first-child):not([data-slot=select-trigger])]:border-l-0",
30
+ "[&>*:has(+[data-slot=select-trigger])]:border-r-0",
31
+ "[&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
32
+ "[&>*]:data-[state=open]:relative [&>*]:data-[state=open]:z-10",
33
+ "[&>[data-slot=select-trigger].w-full]:w-fit",
34
+ ]);
35
+
36
+ /**
37
+ * Props for the ButtonGroup component.
38
+ * Joins Buttons and a Select trigger into one attached row with merged
39
+ * borders. Children must be direct children of the group.
40
+ */
41
+ interface ButtonGroupProps extends React.ComponentPropsWithoutRef<"div"> {
42
+ /**
43
+ * Data hook for automated testing (REQUIRED)
44
+ * @example "run-navigator"
45
+ */
46
+ dataHook: string;
47
+ /**
48
+ * Tracking element identifier for analytics
49
+ */
50
+ trackingEl?: string;
51
+ /**
52
+ * Tracking label for analytics context
53
+ */
54
+ trackingLabel?: string;
55
+ }
56
+
57
+ const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(
58
+ ({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
59
+ return (
60
+ <div
61
+ ref={ref}
62
+ className={cn(buttonGroupVariants(), className)}
63
+ data-hook={dataHook}
64
+ data-slot="button-group"
65
+ data-tracking-el={trackingEl || "button-group"}
66
+ data-tracking-label={trackingLabel}
67
+ role="group"
68
+ {...props}
69
+ />
70
+ );
71
+ }
72
+ );
73
+
74
+ ButtonGroup.displayName = "ButtonGroup";
75
+
76
+ /**
77
+ * Props for the ButtonGroupSeparator component.
78
+ */
79
+ interface ButtonGroupSeparatorProps extends React.ComponentPropsWithoutRef<"div"> {
80
+ /**
81
+ * Data hook for automated testing
82
+ */
83
+ dataHook?: string;
84
+ }
85
+
86
+ /* A black scrim darkens whatever fill it sits on, so one default works on a
87
+ primary green split, a destructive red one, and an outline group alike —
88
+ no per-variant separator colour and nothing to redefine in dark mode.
89
+ -ml-px pulls the line over the previous segment's edge (net width 0), so it
90
+ reads as a darker shade of the fill, not a gap showing the page behind. */
91
+ const ButtonGroupSeparator = React.forwardRef<
92
+ HTMLDivElement,
93
+ ButtonGroupSeparatorProps
94
+ >(({ className, dataHook, ...props }, ref) => {
95
+ return (
96
+ <div
97
+ ref={ref}
98
+ aria-orientation="vertical"
99
+ className={cn("-ml-px w-px shrink-0 self-stretch bg-black/15", className)}
100
+ data-hook={dataHook}
101
+ data-slot="button-group-separator"
102
+ role="separator"
103
+ {...props}
104
+ />
105
+ );
106
+ });
107
+
108
+ ButtonGroupSeparator.displayName = "ButtonGroupSeparator";
109
+
110
+ export { ButtonGroup, ButtonGroupSeparator, buttonGroupVariants };
111
+
112
+ export type { ButtonGroupProps, ButtonGroupSeparatorProps };
@@ -89,7 +89,7 @@ const ButtonVariants = cva(
89
89
  ],
90
90
  outline: [
91
91
  "border",
92
- "border-border",
92
+ "border-input",
93
93
  "border-solid",
94
94
  "bg-background",
95
95
  "hover:bg-accent",