@brightlocal/ui-components 2.27.0 → 3.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.
Files changed (289) hide show
  1. package/README.md +7 -1
  2. package/component-meta.json +568 -143
  3. package/deprecations.json +298 -1
  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.js +18 -18
  10. package/dist/alert.cjs +1 -1
  11. package/dist/alert.d.ts +11 -1
  12. package/dist/alert.d.ts.map +1 -1
  13. package/dist/alert.js +31 -28
  14. package/dist/avatar.cjs +1 -1
  15. package/dist/avatar.js +4 -4
  16. package/dist/badge.cjs +1 -1
  17. package/dist/badge.d.ts.map +1 -1
  18. package/dist/badge.js +15 -11
  19. package/dist/blocks/empty-state.cjs +1 -0
  20. package/dist/blocks/empty-state.d.ts +172 -0
  21. package/dist/blocks/empty-state.d.ts.map +1 -0
  22. package/dist/blocks/empty-state.js +147 -0
  23. package/dist/blocks/input-list.cjs +2 -2
  24. package/dist/blocks/input-list.d.ts.map +1 -1
  25. package/dist/blocks/input-list.js +124 -108
  26. package/dist/blocks/progress-state.cjs +1 -0
  27. package/dist/blocks/{progress-screen.d.ts → progress-state.d.ts} +30 -18
  28. package/dist/blocks/progress-state.d.ts.map +1 -0
  29. package/dist/blocks/{progress-screen.js → progress-state.js} +100 -71
  30. package/dist/blocks/sidebar.cjs +1 -1
  31. package/dist/blocks/sidebar.d.ts.map +1 -1
  32. package/dist/blocks/sidebar.js +160 -161
  33. package/dist/breadcrumb.cjs +1 -1
  34. package/dist/breadcrumb.js +1 -1
  35. package/dist/button-group.cjs +1 -0
  36. package/dist/button-group.d.ts +36 -0
  37. package/dist/button-group.d.ts.map +1 -0
  38. package/dist/button-group.js +47 -0
  39. package/dist/button.cjs +1 -1
  40. package/dist/button.js +12 -12
  41. package/dist/calendar.cjs +1 -1
  42. package/dist/calendar.d.ts.map +1 -1
  43. package/dist/calendar.js +37 -38
  44. package/dist/callout.cjs +1 -1
  45. package/dist/callout.d.ts +24 -2
  46. package/dist/callout.d.ts.map +1 -1
  47. package/dist/callout.js +57 -55
  48. package/dist/card.cjs +1 -1
  49. package/dist/card.d.ts +42 -3
  50. package/dist/card.d.ts.map +1 -1
  51. package/dist/card.js +102 -91
  52. package/dist/chart-empty.cjs +1 -0
  53. package/dist/chart-empty.d.ts +59 -0
  54. package/dist/chart-empty.d.ts.map +1 -0
  55. package/dist/chart-empty.js +29 -0
  56. package/dist/chart.cjs +6 -6
  57. package/dist/chart.d.ts +46 -13
  58. package/dist/chart.d.ts.map +1 -1
  59. package/dist/chart.js +172 -157
  60. package/dist/chip.cjs +1 -1
  61. package/dist/chip.d.ts +38 -4
  62. package/dist/chip.d.ts.map +1 -1
  63. package/dist/chip.js +100 -84
  64. package/dist/combobox.cjs +2 -2
  65. package/dist/combobox.d.ts.map +1 -1
  66. package/dist/combobox.js +81 -79
  67. package/dist/command.cjs +1 -1
  68. package/dist/command.d.ts +23 -1
  69. package/dist/command.d.ts.map +1 -1
  70. package/dist/command.js +248 -225
  71. package/dist/context-menu.cjs +1 -1
  72. package/dist/context-menu.d.ts.map +1 -1
  73. package/dist/context-menu.js +26 -29
  74. package/dist/data-table.cjs +1 -1
  75. package/dist/data-table.d.ts +75 -10
  76. package/dist/data-table.d.ts.map +1 -1
  77. package/dist/data-table.js +346 -334
  78. package/dist/date-picker.cjs +1 -1
  79. package/dist/date-picker.d.ts +13 -5
  80. package/dist/date-picker.d.ts.map +1 -1
  81. package/dist/date-picker.js +54 -53
  82. package/dist/description.cjs +1 -1
  83. package/dist/description.js +5 -5
  84. package/dist/dialog.cjs +1 -1
  85. package/dist/dialog.js +20 -20
  86. package/dist/drawer.cjs +1 -1
  87. package/dist/drawer.d.ts.map +1 -1
  88. package/dist/drawer.js +8 -11
  89. package/dist/dropdown-menu.cjs +1 -1
  90. package/dist/dropdown-menu.d.ts.map +1 -1
  91. package/dist/dropdown-menu.js +17 -20
  92. package/dist/field.cjs +1 -1
  93. package/dist/field.d.ts +8 -1
  94. package/dist/field.d.ts.map +1 -1
  95. package/dist/field.js +96 -65
  96. package/dist/global-layout.cjs +1 -1
  97. package/dist/global-layout.d.ts +130 -12
  98. package/dist/global-layout.d.ts.map +1 -1
  99. package/dist/global-layout.js +146 -127
  100. package/dist/grid.cjs +1 -0
  101. package/dist/grid.d.ts +56 -0
  102. package/dist/grid.d.ts.map +1 -0
  103. package/dist/grid.js +32 -0
  104. package/dist/header.d.ts +13 -0
  105. package/dist/header.d.ts.map +1 -1
  106. package/dist/hooks/use-delayed-pending.cjs +1 -0
  107. package/dist/hooks/use-delayed-pending.d.ts +34 -0
  108. package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
  109. package/dist/hooks/use-delayed-pending.js +17 -0
  110. package/dist/hooks/use-mobile.cjs +1 -0
  111. package/dist/hooks/use-mobile.js +8 -0
  112. package/dist/hover-card.cjs +1 -1
  113. package/dist/hover-card.js +13 -13
  114. package/dist/index.cjs +1 -1
  115. package/dist/index.d.ts +9 -1
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +554 -527
  118. package/dist/input-chip.cjs +1 -1
  119. package/dist/input-chip.js +25 -25
  120. package/dist/input-group.cjs +1 -1
  121. package/dist/input-group.js +9 -9
  122. package/dist/input-otp.cjs +1 -1
  123. package/dist/input-otp.js +9 -9
  124. package/dist/input-password.cjs +1 -1
  125. package/dist/input-password.d.ts +17 -9
  126. package/dist/input-password.d.ts.map +1 -1
  127. package/dist/input-password.js +73 -72
  128. package/dist/input.cjs +1 -1
  129. package/dist/input.js +9 -9
  130. package/dist/label.cjs +1 -1
  131. package/dist/label.d.ts.map +1 -1
  132. package/dist/label.js +25 -28
  133. package/dist/lib/block-illustration.cjs +1 -0
  134. package/dist/lib/block-illustration.d.ts +28 -0
  135. package/dist/lib/block-illustration.d.ts.map +1 -0
  136. package/dist/lib/block-illustration.js +21 -0
  137. package/dist/lib/empty-canvas.cjs +1 -0
  138. package/dist/lib/empty-canvas.d.ts +27 -0
  139. package/dist/lib/empty-canvas.d.ts.map +1 -0
  140. package/dist/lib/empty-canvas.js +62 -0
  141. package/dist/lib/empty-chip.cjs +1 -0
  142. package/dist/lib/empty-chip.d.ts +4 -0
  143. package/dist/lib/empty-chip.d.ts.map +1 -0
  144. package/dist/lib/empty-chip.js +13 -0
  145. package/dist/lib/optical-center.cjs +1 -0
  146. package/dist/lib/optical-center.d.ts +12 -0
  147. package/dist/lib/optical-center.d.ts.map +1 -0
  148. package/dist/lib/optical-center.js +11 -0
  149. package/dist/lib/utils.cjs +1 -1
  150. package/dist/lib/utils.d.ts.map +1 -1
  151. package/dist/lib/utils.js +28 -5
  152. package/dist/list.cjs +1 -1
  153. package/dist/list.d.ts.map +1 -1
  154. package/dist/list.js +62 -58
  155. package/dist/map.cjs +1 -1
  156. package/dist/map.d.ts +60 -2
  157. package/dist/map.d.ts.map +1 -1
  158. package/dist/map.js +187 -164
  159. package/dist/media-empty.cjs +1 -0
  160. package/dist/media-empty.d.ts +72 -0
  161. package/dist/media-empty.d.ts.map +1 -0
  162. package/dist/media-empty.js +45 -0
  163. package/dist/menubar.cjs +1 -1
  164. package/dist/menubar.d.ts.map +1 -1
  165. package/dist/menubar.js +17 -20
  166. package/dist/navigation-menu.cjs +1 -1
  167. package/dist/navigation-menu.js +7 -7
  168. package/dist/pagination.cjs +1 -1
  169. package/dist/pagination.d.ts +130 -1
  170. package/dist/pagination.d.ts.map +1 -1
  171. package/dist/pagination.js +193 -102
  172. package/dist/progress.cjs +1 -1
  173. package/dist/progress.d.ts +2 -26
  174. package/dist/progress.d.ts.map +1 -1
  175. package/dist/progress.js +79 -118
  176. package/dist/scroll-area.cjs +1 -1
  177. package/dist/scroll-area.d.ts +15 -6
  178. package/dist/scroll-area.d.ts.map +1 -1
  179. package/dist/scroll-area.js +38 -36
  180. package/dist/select.cjs +2 -2
  181. package/dist/select.d.ts +13 -2
  182. package/dist/select.d.ts.map +1 -1
  183. package/dist/select.js +92 -87
  184. package/dist/separator.cjs +1 -1
  185. package/dist/separator.js +8 -8
  186. package/dist/sheet.cjs +1 -1
  187. package/dist/sheet.js +2 -2
  188. package/dist/skeleton.cjs +1 -1
  189. package/dist/skeleton.d.ts +38 -3
  190. package/dist/skeleton.d.ts.map +1 -1
  191. package/dist/skeleton.js +43 -20
  192. package/dist/sonner.cjs +1 -1
  193. package/dist/sonner.js +26 -26
  194. package/dist/stepper.cjs +1 -1
  195. package/dist/stepper.js +40 -40
  196. package/dist/table.cjs +1 -1
  197. package/dist/table.d.ts.map +1 -1
  198. package/dist/table.js +31 -28
  199. package/dist/tabs.cjs +1 -1
  200. package/dist/tabs.js +1 -1
  201. package/dist/text-reveal-motion.d.ts +10 -0
  202. package/dist/text-reveal-motion.d.ts.map +1 -1
  203. package/dist/textarea.cjs +1 -1
  204. package/dist/textarea.js +11 -11
  205. package/dist/toggle.cjs +1 -1
  206. package/dist/toggle.js +8 -8
  207. package/dist/tooltip.cjs +1 -1
  208. package/dist/tooltip.js +8 -8
  209. package/dist/typography-heading.cjs +1 -0
  210. package/dist/typography-heading.d.ts +129 -0
  211. package/dist/typography-heading.d.ts.map +1 -0
  212. package/dist/typography-heading.js +95 -0
  213. package/dist/typography-text.cjs +1 -0
  214. package/dist/typography-text.d.ts +127 -0
  215. package/dist/typography-text.d.ts.map +1 -0
  216. package/dist/typography-text.js +92 -0
  217. package/dist/typography.d.ts +13 -0
  218. package/dist/typography.d.ts.map +1 -1
  219. package/package.json +35 -7
  220. package/src/blocks/empty-state.tsx +412 -0
  221. package/src/blocks/input-list.tsx +66 -36
  222. package/src/blocks/{progress-screen.tsx → progress-state.tsx} +154 -93
  223. package/src/blocks/sidebar.tsx +25 -26
  224. package/src/components/accordion.tsx +82 -27
  225. package/src/components/alert-dialog.tsx +2 -2
  226. package/src/components/alert.tsx +27 -13
  227. package/src/components/avatar.tsx +1 -1
  228. package/src/components/badge.tsx +8 -4
  229. package/src/components/breadcrumb.tsx +1 -1
  230. package/src/components/button-group.tsx +112 -0
  231. package/src/components/button.tsx +4 -4
  232. package/src/components/calendar.tsx +5 -6
  233. package/src/components/callout.tsx +48 -15
  234. package/src/components/card.tsx +89 -19
  235. package/src/components/chart-empty.tsx +116 -0
  236. package/src/components/chart.tsx +103 -32
  237. package/src/components/chip.tsx +88 -13
  238. package/src/components/combobox.tsx +12 -10
  239. package/src/components/command.tsx +64 -13
  240. package/src/components/context-menu.tsx +6 -9
  241. package/src/components/data-table.tsx +135 -20
  242. package/src/components/date-picker.tsx +18 -7
  243. package/src/components/description.tsx +1 -1
  244. package/src/components/dialog.tsx +2 -2
  245. package/src/components/drawer.tsx +2 -5
  246. package/src/components/dropdown-menu.tsx +8 -11
  247. package/src/components/field.tsx +89 -16
  248. package/src/components/global-layout.tsx +210 -39
  249. package/src/components/grid.tsx +130 -0
  250. package/src/components/header.tsx +13 -0
  251. package/src/components/hover-card.tsx +1 -1
  252. package/src/components/input-chip.tsx +1 -1
  253. package/src/components/input-group.tsx +1 -1
  254. package/src/components/input-otp.tsx +1 -1
  255. package/src/components/input-password.tsx +24 -12
  256. package/src/components/input.tsx +1 -1
  257. package/src/components/label.tsx +10 -13
  258. package/src/components/list.tsx +13 -9
  259. package/src/components/map.tsx +101 -5
  260. package/src/components/media-empty.tsx +156 -0
  261. package/src/components/menubar.tsx +7 -10
  262. package/src/components/navigation-menu.tsx +1 -1
  263. package/src/components/pagination.tsx +286 -1
  264. package/src/components/progress.tsx +35 -113
  265. package/src/components/scroll-area.tsx +23 -10
  266. package/src/components/select.tsx +35 -10
  267. package/src/components/separator.tsx +1 -1
  268. package/src/components/sheet.tsx +2 -2
  269. package/src/components/skeleton.tsx +78 -7
  270. package/src/components/sonner.tsx +2 -2
  271. package/src/components/stepper.tsx +3 -3
  272. package/src/components/table.tsx +6 -3
  273. package/src/components/tabs.tsx +1 -1
  274. package/src/components/text-reveal-motion.tsx +10 -0
  275. package/src/components/textarea.tsx +1 -1
  276. package/src/components/toggle.tsx +1 -1
  277. package/src/components/tooltip.tsx +1 -1
  278. package/src/components/typography-heading.tsx +253 -0
  279. package/src/components/typography-text.tsx +250 -0
  280. package/src/components/typography.tsx +13 -0
  281. package/src/hooks/use-delayed-pending.ts +60 -0
  282. package/src/index.ts +11 -1
  283. package/src/lib/block-illustration.tsx +88 -0
  284. package/src/lib/empty-canvas.tsx +128 -0
  285. package/src/lib/empty-chip.ts +24 -0
  286. package/src/lib/optical-center.tsx +45 -0
  287. package/src/lib/utils.ts +26 -0
  288. package/dist/blocks/progress-screen.cjs +0 -1
  289. package/dist/blocks/progress-screen.d.ts.map +0 -1
@@ -124,7 +124,7 @@ const ChartContainer = React.forwardRef<HTMLDivElement, ChartContainerProps>(
124
124
  <div
125
125
  ref={ref}
126
126
  className={cn(
127
- "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-polar-radius-axis-tick-value]:fill-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-pie-sector]:stroke-background flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-pie-sector]:stroke-2 [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_svg_g]:outline-none [&_svg_g]:focus:outline-none",
127
+ "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-polar-radius-axis-tick-value]:fill-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-pie-sector]:stroke-background text-body-xs flex aspect-video justify-center [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-pie-sector]:stroke-2 [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_svg_g]:outline-none [&_svg_g]:focus:outline-none",
128
128
  className
129
129
  )}
130
130
  data-chart={chartId}
@@ -200,6 +200,43 @@ function ChartStyle({ id, config }: { id: string; config: ChartConfig }) {
200
200
  // Chart Tooltip
201
201
  // ============================================================================
202
202
 
203
+ /**
204
+ * A single entry of the Recharts tooltip payload, as `ChartTooltipContent`
205
+ * receives it. This is the `item` argument given to `formatter` and the
206
+ * element type of the `payload` arrays given to `formatter` and
207
+ * `labelFormatter`, so consumers can read e.g. `item.color` or
208
+ * `item.payload` without hand-rolled narrowing.
209
+ */
210
+ interface ChartTooltipPayloadItem {
211
+ /** The series `dataKey` this row belongs to. */
212
+ dataKey?: string | number;
213
+ /** The row's value. `undefined` when the datum carries no value. */
214
+ value?: number | string;
215
+ /** The series name Recharts resolves for this row. */
216
+ name?: string;
217
+ /** The series stroke colour Recharts injects. */
218
+ color?: string;
219
+ /** The series fill colour Recharts injects (bars, pie slices). */
220
+ fill?: string;
221
+ /** The underlying data point for this row. */
222
+ payload: Record<string, unknown>;
223
+ }
224
+
225
+ /**
226
+ * Whether a tooltip row has a value worth printing. Zero is a real value and
227
+ * must render; NaN/Infinity (a dataKey over a non-numeric field, a ratio with
228
+ * a zero denominator) and blank strings have nothing to show, so the value
229
+ * slot stays empty rather than reading "NaN".
230
+ */
231
+ function isRenderableValue(
232
+ value: number | string | null | undefined
233
+ ): value is number | string {
234
+ if (value == null || value === "") {
235
+ return false;
236
+ }
237
+ return typeof value === "number" ? Number.isFinite(value) : true;
238
+ }
239
+
203
240
  /**
204
241
  * Props for the ChartTooltip component.
205
242
  */
@@ -237,17 +274,33 @@ interface ChartTooltipContentProps
237
274
  ChartTooltipProps,
238
275
  "hideLabel" | "hideIndicator" | "indicator" | "nameKey" | "labelKey"
239
276
  > {
240
- /** Custom label formatter function */
241
- labelFormatter?: (value: unknown, payload: unknown[]) => React.ReactNode;
277
+ /**
278
+ * Custom label formatter function.
279
+ * @param value - The resolved tooltip label (the config label when one
280
+ * matches, otherwise the raw axis label).
281
+ * @param payload - The tooltip payload entries for the hovered datum.
282
+ */
283
+ labelFormatter?: (
284
+ value: React.ReactNode,
285
+ payload: ChartTooltipPayloadItem[]
286
+ ) => React.ReactNode;
242
287
  /** Additional CSS class for the label */
243
288
  labelClassName?: string;
244
- /** Custom value formatter function */
289
+ /**
290
+ * Custom value formatter function. Replaces the default row (indicator,
291
+ * name, and value) for every entry with a renderable value.
292
+ * @param value - The entry's value (`0` is real data and is passed through).
293
+ * @param name - The entry's series name.
294
+ * @param item - The full payload entry (colour, dataKey, data point, …).
295
+ * @param index - The entry's index within the tooltip payload.
296
+ * @param payload - All payload entries for the hovered datum.
297
+ */
245
298
  formatter?: (
246
- value: unknown,
299
+ value: number | string,
247
300
  name: string,
248
- item: unknown,
301
+ item: ChartTooltipPayloadItem,
249
302
  index: number,
250
- payload: unknown[]
303
+ payload: ChartTooltipPayloadItem[]
251
304
  ) => React.ReactNode;
252
305
  }
253
306
 
@@ -270,13 +323,7 @@ function ChartTooltipContent({
270
323
  labelKey,
271
324
  }: ChartTooltipContentProps & {
272
325
  active?: boolean;
273
- payload?: Array<{
274
- dataKey: string;
275
- value: number | string;
276
- name?: string;
277
- color?: string;
278
- payload: Record<string, unknown>;
279
- }>;
326
+ payload?: ChartTooltipPayloadItem[];
280
327
  label?: string;
281
328
  color?: string;
282
329
  }) {
@@ -330,7 +377,7 @@ function ChartTooltipContent({
330
377
  return (
331
378
  <div
332
379
  className={cn(
333
- "border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
380
+ "border-border/50 bg-background text-body-xs grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 shadow-xl",
334
381
  className
335
382
  )}
336
383
  data-slot="chart-tooltip-content"
@@ -350,8 +397,9 @@ function ChartTooltipContent({
350
397
  "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2",
351
398
  indicator === "dot" && "items-center"
352
399
  )}
400
+ data-slot="chart-tooltip-item"
353
401
  >
354
- {formatter && item?.value !== undefined && item.name ? (
402
+ {formatter && isRenderableValue(item.value) && item.name ? (
355
403
  formatter(item.value, item.name, item, index, payload)
356
404
  ) : (
357
405
  <>
@@ -379,20 +427,29 @@ function ChartTooltipContent({
379
427
  />
380
428
  )
381
429
  )}
430
+ {/* gap-2 keeps the name and value apart once the row grows
431
+ wider than the tooltip min-width, where justify-between
432
+ alone would render them flush together (DS-897). */}
382
433
  <div
383
434
  className={cn(
384
- "flex flex-1 justify-between leading-none",
435
+ "flex flex-1 justify-between gap-2 leading-none",
385
436
  nestLabel ? "items-end" : "items-center"
386
437
  )}
387
438
  >
388
439
  <div className="grid gap-1.5">
389
440
  {nestLabel ? tooltipLabel : null}
390
- <span className="text-muted-foreground">
441
+ <span
442
+ className="text-muted-foreground"
443
+ data-slot="chart-tooltip-item-name"
444
+ >
391
445
  {itemConfig?.label || item.name}
392
446
  </span>
393
447
  </div>
394
- {item.value && (
395
- <span className="text-foreground font-mono font-medium tabular-nums">
448
+ {isRenderableValue(item.value) && (
449
+ <span
450
+ className="text-foreground tabular-nums"
451
+ data-slot="chart-tooltip-item-value"
452
+ >
396
453
  {typeof item.value === "number"
397
454
  ? item.value.toLocaleString()
398
455
  : item.value}
@@ -874,7 +931,7 @@ function ChartRadarLabelWrapper({
874
931
 
875
932
  return (
876
933
  <text
877
- className="text-xs"
934
+ className="text-body-xs"
878
935
  data-slot="chart-radar-label-wrapper"
879
936
  textAnchor={textAnchor}
880
937
  x={x}
@@ -966,7 +1023,7 @@ function ChartPieLabelList({
966
1023
 
967
1024
  return (
968
1025
  <text
969
- className="fill-foreground text-xs"
1026
+ className="fill-foreground text-body-xs"
970
1027
  data-slot="chart-pie-label-list"
971
1028
  dominantBaseline="middle"
972
1029
  textAnchor="middle"
@@ -1024,7 +1081,7 @@ function ChartPieLabelWrapper({
1024
1081
 
1025
1082
  return (
1026
1083
  <text
1027
- className="fill-foreground text-xs"
1084
+ className="fill-foreground text-body-xs"
1028
1085
  data-slot="chart-pie-label-wrapper"
1029
1086
  dominantBaseline="middle"
1030
1087
  textAnchor={textAnchor}
@@ -1056,7 +1113,8 @@ interface ChartCenterLabelProps {
1056
1113
  /** Secondary label shown beneath the primary value. */
1057
1114
  secondary?: React.ReactNode;
1058
1115
  /**
1059
- * Size of the primary value text.
1116
+ * Size of the primary value text. Every size keeps the `text-metric`
1117
+ * identity (Inter semibold); only the figure size scales.
1060
1118
  * @default "3xl"
1061
1119
  */
1062
1120
  size?: ChartCenterLabelSize;
@@ -1064,14 +1122,20 @@ interface ChartCenterLabelProps {
1064
1122
  viewBox?: unknown;
1065
1123
  }
1066
1124
 
1125
+ /* Only text-metric (24/28) exists on the type scale; the larger sizes are
1126
+ scaled variants of it carrying the same metric identity (Inter semibold)
1127
+ spelled out — twMerge registers scale styles as font-size atoms, so
1128
+ `text-metric text-4xl` would drop text-metric. */
1067
1129
  const chartCenterLabelPrimarySize: Record<ChartCenterLabelSize, string> = {
1068
- "2xl": "text-2xl leading-8",
1069
- "3xl": "text-3xl",
1070
- "4xl": "text-4xl leading-10",
1130
+ "2xl": "text-metric",
1131
+ "3xl": "font-sans text-3xl font-semibold",
1132
+ "4xl": "font-sans text-4xl font-semibold",
1071
1133
  };
1072
1134
 
1073
1135
  /**
1074
1136
  * ChartCenterLabel renders a centred primary value with an optional label.
1137
+ * The primary value is a KPI figure in the `text-metric` type-scale style;
1138
+ * `size` scales the figure.
1075
1139
  */
1076
1140
  function ChartCenterLabel({
1077
1141
  primary,
@@ -1099,10 +1163,7 @@ function ChartCenterLabel({
1099
1163
  y={cy}
1100
1164
  >
1101
1165
  <tspan
1102
- className={cn(
1103
- "fill-foreground font-sans font-bold",
1104
- chartCenterLabelPrimarySize[size]
1105
- )}
1166
+ className={cn("fill-foreground", chartCenterLabelPrimarySize[size])}
1106
1167
  x={cx}
1107
1168
  y={cy}
1108
1169
  >
@@ -1110,7 +1171,7 @@ function ChartCenterLabel({
1110
1171
  </tspan>
1111
1172
  {secondary != null && (
1112
1173
  <tspan
1113
- className="fill-muted-foreground font-sans text-xs font-normal"
1174
+ className="fill-muted-foreground text-body-xs"
1114
1175
  x={cx}
1115
1176
  y={cy + 24}
1116
1177
  >
@@ -1147,6 +1208,7 @@ export type {
1147
1208
  ChartContainerProps,
1148
1209
  ChartTooltipProps,
1149
1210
  ChartTooltipContentProps,
1211
+ ChartTooltipPayloadItem,
1150
1212
  ChartLegendProps,
1151
1213
  ChartLegendContentProps,
1152
1214
  ChartDotProps,
@@ -1163,6 +1225,15 @@ export type {
1163
1225
  ChartCenterLabelSize,
1164
1226
  };
1165
1227
 
1228
+ /* ChartEmpty is defined in its own file so that a card showing "no data yet"
1229
+ need not pull Recharts in to say so — but it belongs to the chart family, so
1230
+ `/chart` exports it too and either import path works. It stays below the
1231
+ primary exports: the MCP indexer treats the file's first value export as the
1232
+ primary component when no export matches the file name, and `/chart`'s
1233
+ primary is ChartContainer. */
1234
+ export { ChartEmpty } from "./chart-empty";
1235
+ export type { ChartEmptyProps } from "./chart-empty";
1236
+
1166
1237
  // Re-export Recharts components with aliases to avoid naming conflicts
1167
1238
  export {
1168
1239
  Area,
@@ -18,6 +18,25 @@ import {
18
18
  */
19
19
  type ChipSize = "md" | "lg";
20
20
 
21
+ /**
22
+ * The event a chip removal hands to `onRemove`: a mouse event from the
23
+ * delete button, or a keyboard event from Backspace/Delete on the chip root.
24
+ */
25
+ type ChipRemoveEvent =
26
+ | React.MouseEvent<HTMLButtonElement>
27
+ | React.KeyboardEvent<HTMLDivElement>;
28
+
29
+ /**
30
+ * Removal callback. Declared with the bivariance hack — the same shape React
31
+ * uses for its own event handlers — so handlers annotated against the
32
+ * pre-keyboard, mouse-only contract
33
+ * (`(event: React.MouseEvent<HTMLButtonElement>) => void`) stay assignable
34
+ * under strict function-parameter checking (DS-949).
35
+ */
36
+ type ChipRemoveHandler = {
37
+ bivarianceHack(event: ChipRemoveEvent): void;
38
+ }["bivarianceHack"];
39
+
21
40
  const chipVariants = cva(
22
41
  [
23
42
  // Base styles
@@ -26,7 +45,6 @@ const chipVariants = cva(
26
45
  "justify-center",
27
46
  "gap-0.5",
28
47
  "rounded-full",
29
- "font-medium",
30
48
  "whitespace-nowrap",
31
49
  "shrink-0",
32
50
  "select-none",
@@ -40,7 +58,7 @@ const chipVariants = cva(
40
58
  // Hover state
41
59
  "hover:bg-secondary/80",
42
60
  // Focus state - direct focus on chip (for keyboard navigation)
43
- "focus:outline-none",
61
+ "outline-none",
44
62
  "focus-visible:shadow-default",
45
63
  // Disabled state
46
64
  "disabled:pointer-events-none",
@@ -51,8 +69,11 @@ const chipVariants = cva(
51
69
  {
52
70
  variants: {
53
71
  size: {
54
- md: ["h-7", "pl-2.5", "pr-1", "text-xs"],
55
- lg: ["h-8", "pl-4", "pr-2", "text-base"],
72
+ md: ["h-7", "pl-2.5", "pr-1", "text-label-sm"],
73
+ // A chip is a control: the bigger box steps up one label role, never
74
+ // onto a body size — mirrors Button (sm → label-sm, md/lg → label).
75
+ // Resolves the 16px off-scale flag from DS-925 (DS-966).
76
+ lg: ["h-8", "pl-4", "pr-2", "text-label"],
56
77
  },
57
78
  },
58
79
  defaultVariants: {
@@ -117,9 +138,10 @@ interface ChipProps extends Omit<React.ComponentProps<"div">, "children"> {
117
138
  */
118
139
  disabled?: boolean;
119
140
  /**
120
- * Callback when delete button is clicked
141
+ * Callback when the chip is removed — via the delete button (click) or
142
+ * the keyboard (Backspace/Delete while the chip is focused).
121
143
  */
122
- onRemove?: (event: React.MouseEvent<HTMLButtonElement>) => void;
144
+ onRemove?: ChipRemoveHandler;
123
145
  /**
124
146
  * Data hook for automated testing (required)
125
147
  */
@@ -144,15 +166,33 @@ interface ChipProps extends Omit<React.ComponentProps<"div">, "children"> {
144
166
  loadingLabel?: string;
145
167
  /**
146
168
  * Accessible label for the remove button.
147
- * Supports `{name}` placeholder for interpolation.
169
+ * Supports `{name}` placeholder for interpolation. The default `{name}` is
170
+ * derived from string or number children; for a JSX label, pass this prop
171
+ * with the resolved name.
148
172
  * @default "Remove {name}"
149
173
  */
150
174
  removeAriaLabel?: string;
175
+ /**
176
+ * Accessible label for the chip itself while it is keyboard-removable
177
+ * (focusable, with the Backspace/Delete removal hint).
178
+ * Supports `{name}` placeholder for interpolation. The default `{name}` is
179
+ * derived from string or number children; for a JSX label, pass this prop
180
+ * with the resolved name.
181
+ * @default "{name}, press Delete to remove"
182
+ */
183
+ removableAriaLabel?: string;
151
184
  }
152
185
 
153
186
  /**
154
187
  * Chip component for displaying removable tags or selections.
155
188
  * Used for filter selections, tag lists, and multi-select values.
189
+ *
190
+ * A removable chip is a single tab stop: the chip itself takes focus and
191
+ * Backspace/Delete removes it (DS-949). The delete button stays mouse-only
192
+ * (`tabIndex={-1}`) so each chip costs one tab stop, not two. When a removal
193
+ * unmounts the focused chip, the consumer hands focus onward per the
194
+ * Filtering pattern's cascade: source control → filter trigger → results
195
+ * region — never `<body>`.
156
196
  */
157
197
  const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
158
198
  (
@@ -169,12 +209,32 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
169
209
  maxWidth = 200,
170
210
  loadingLabel,
171
211
  removeAriaLabel,
212
+ removableAriaLabel,
213
+ onKeyDown,
172
214
  ...props
173
215
  },
174
216
  ref
175
217
  ) => {
176
218
  const isDisabled = disabled || loading;
177
219
  const iconSize = size === "lg" ? 16 : 14;
220
+ // The {name} fallback is derived from plain-text children only; a JSX
221
+ // label must supply removeAriaLabel/removableAriaLabel itself.
222
+ const chipName =
223
+ typeof children === "string" || typeof children === "number"
224
+ ? String(children)
225
+ : "chip";
226
+ const removable = onRemove !== undefined && !isDisabled;
227
+
228
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
229
+ onKeyDown?.(event);
230
+ // A composing parent (InputChip's roving focus) that already handled
231
+ // the key marks it consumed via preventDefault.
232
+ if (event.defaultPrevented || !removable) return;
233
+ if (event.key === "Backspace" || event.key === "Delete") {
234
+ event.preventDefault();
235
+ onRemove(event);
236
+ }
237
+ };
178
238
  const labelRef = React.useRef<HTMLSpanElement>(null);
179
239
  const [isTruncated, setIsTruncated] = React.useState(false);
180
240
 
@@ -204,14 +264,32 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
204
264
  );
205
265
 
206
266
  return (
267
+ /* Keyboard removal lives on the chip root: when removable it carries
268
+ role="group" and tabIndex=0 below — the rule can't see the
269
+ conditional role. */
270
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
207
271
  <div
208
272
  ref={ref}
209
273
  aria-disabled={isDisabled ? "true" : undefined}
274
+ // Keyboard-removable chips are focusable and announce the removal
275
+ // hint. A composing parent (InputChip) overrides all three via
276
+ // props — the spread below wins.
277
+ aria-label={
278
+ removable
279
+ ? (removableAriaLabel ?? "{name}, press Delete to remove").replace(
280
+ "{name}",
281
+ chipName
282
+ )
283
+ : undefined
284
+ }
210
285
  className={cn(chipVariants({ size }), className)}
211
286
  data-hook={dataHook}
212
287
  data-slot="chip"
213
288
  data-tracking-el={trackingEl}
214
289
  data-tracking-label={trackingLabel}
290
+ role={removable ? "group" : undefined}
291
+ tabIndex={removable ? 0 : undefined}
292
+ onKeyDown={handleKeyDown}
215
293
  {...props}
216
294
  >
217
295
  {isTruncated ? (
@@ -239,11 +317,8 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
239
317
  <button
240
318
  aria-label={
241
319
  removeAriaLabel
242
- ? removeAriaLabel.replace(
243
- "{name}",
244
- typeof children === "string" ? children : "chip"
245
- )
246
- : `Remove ${typeof children === "string" ? children : "chip"}`
320
+ ? removeAriaLabel.replace("{name}", chipName)
321
+ : `Remove ${chipName}`
247
322
  }
248
323
  className={cn(chipDeleteButtonVariants({ size }))}
249
324
  data-slot="chip-delete"
@@ -264,4 +339,4 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
264
339
  Chip.displayName = "Chip";
265
340
 
266
341
  export { Chip, chipVariants };
267
- export type { ChipProps, ChipSize };
342
+ export type { ChipProps, ChipRemoveEvent, ChipRemoveHandler, ChipSize };
@@ -384,7 +384,7 @@ const comboboxTriggerVariants = cva([
384
384
  "dark:bg-white/5 dark:border-white/15",
385
385
 
386
386
  // Typography
387
- "text-base font-normal font-sans text-foreground",
387
+ "text-body text-foreground",
388
388
 
389
389
  // Placeholder state
390
390
  "data-[placeholder=true]:text-muted-foreground",
@@ -620,7 +620,7 @@ function ComboboxValue<T>({
620
620
  return (
621
621
  <span
622
622
  className={cn(
623
- "overflow-hidden text-base leading-normal font-medium text-ellipsis whitespace-nowrap",
623
+ "text-body overflow-hidden text-ellipsis whitespace-nowrap",
624
624
  className
625
625
  )}
626
626
  data-slot="combobox-value"
@@ -1473,7 +1473,7 @@ const ComboboxItem = React.forwardRef<
1473
1473
  return highlightText(
1474
1474
  children,
1475
1475
  highlight,
1476
- highlightClassName || "text-sm leading-normal font-semibold"
1476
+ highlightClassName || "text-label font-semibold"
1477
1477
  );
1478
1478
  }
1479
1479
  return children;
@@ -1492,7 +1492,7 @@ const ComboboxItem = React.forwardRef<
1492
1492
  aria-selected={isSelected}
1493
1493
  aria-setsize={virtualCtx.filteredCount}
1494
1494
  className={cn(
1495
- "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground relative flex cursor-default items-center justify-between gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none",
1495
+ "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-default items-center justify-between gap-2 rounded-sm px-2 py-3 outline-hidden select-none",
1496
1496
  "[&_svg]:pointer-events-none [&_svg]:shrink-0",
1497
1497
  isDisabled && "pointer-events-none opacity-50",
1498
1498
  className
@@ -1597,12 +1597,14 @@ function ComboboxLoading({
1597
1597
  <div
1598
1598
  aria-live="polite"
1599
1599
  className={cn(
1600
- // The entrance fade doubles as a ~150ms appearance delay (`both`
1601
- // holds the hidden start): a fetch that resolves faster than the
1602
- // delay never flashes a spinner, which would read slower than no
1603
- // indicator at all.
1604
- "text-muted-foreground relative flex items-center justify-center gap-2 py-6 text-sm",
1605
- "animate-entrance-fade entrance-delay-1",
1600
+ // The entrance fade doubles as the flash-threshold appearance delay
1601
+ // (`both` holds the hidden start): a fetch that resolves inside the
1602
+ // flash zone never flashes a spinner, which would read slower than
1603
+ // no indicator at all. flash-delay draws the delay from
1604
+ // --ds-motion-flash-threshold — the same threshold useDelayedPending
1605
+ // mirrors in JS.
1606
+ "text-body-sm text-muted-foreground relative flex items-center justify-center gap-2 py-6",
1607
+ "animate-entrance-fade flash-delay",
1606
1608
  className
1607
1609
  )}
1608
1610
  data-slot="combobox-loading"
@@ -10,6 +10,8 @@ import { Button } from "@brightlocal/ui-components/button";
10
10
  import { cn } from "@brightlocal/ui-components/lib/utils";
11
11
  import { useDevWarning } from "@brightlocal/ui-components/lib/use-dev-warning";
12
12
 
13
+ import { emptyChipStyles } from "../lib/empty-chip";
14
+
13
15
  /* -------------------------------------------------------------------------------------------------
14
16
  * Command Context — shared state between CommandInput and CommandVirtualList
15
17
  * -----------------------------------------------------------------------------------------------*/
@@ -249,7 +251,7 @@ const CommandInput = React.forwardRef<
249
251
  <CommandPrimitive.Input
250
252
  ref={inputRef}
251
253
  className={cn(
252
- "placeholder:text-muted-foreground flex w-full bg-transparent text-base outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
254
+ "placeholder:text-muted-foreground text-body flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
253
255
  className
254
256
  )}
255
257
  data-slot="command-input"
@@ -262,7 +264,9 @@ const CommandInput = React.forwardRef<
262
264
  {showClearButton && (
263
265
  <Button
264
266
  aria-label={clearSearchAriaLabel ?? "Clear search"}
265
- className="text-muted-foreground hover:text-foreground"
267
+ /* Same square hit area as the DataTableSearch clear — a default
268
+ h-9 px-4 button hovers as a wide pill inside the field. */
269
+ className="text-muted-foreground hover:text-foreground size-6 p-0"
266
270
  dataHook="command-input-clear"
267
271
  variant="ghost"
268
272
  onClick={handleClear}
@@ -326,15 +330,37 @@ export interface CommandEmptyProps extends React.ComponentProps<
326
330
  * Data hook for automated testing
327
331
  */
328
332
  dataHook?: string;
333
+ /**
334
+ * Icon shown in the muted chip above the message — the same chip as
335
+ * EmptyState, so the popover form matches the card and page forms
336
+ * (Patterns/Empty States). Decorative; the message carries the state.
337
+ */
338
+ icon?: React.ReactNode;
339
+ /**
340
+ * One quiet muted line under the message, e.g. "Try a different search."
341
+ */
342
+ description?: React.ReactNode;
329
343
  }
330
344
 
331
345
  /**
332
- * Empty state displayed when no results are found.
346
+ * Empty state displayed when no results are found. Plain `children` render
347
+ * the one-line form; pass `icon` and/or `description` for the compact form
348
+ * the Empty States pattern uses at popover scope — never hand-roll it.
349
+ *
350
+ * @example
351
+ * ```tsx
352
+ * <CommandEmpty
353
+ * description="Try a different search."
354
+ * icon={<SearchX />}
355
+ * >
356
+ * No locations match “{search}”
357
+ * </CommandEmpty>
358
+ * ```
333
359
  */
334
360
  const CommandEmpty = React.forwardRef<
335
361
  React.ComponentRef<typeof CommandPrimitive.Empty>,
336
362
  CommandEmptyProps
337
- >(({ dataHook, ...props }, ref) => {
363
+ >(({ children, dataHook, description, icon, ...props }, ref) => {
338
364
  // cmdk hardcodes role="presentation" after spreading props, so we
339
365
  // override it via a callback ref to satisfy the listbox a11y contract
340
366
  // (role="listbox" requires option or group children).
@@ -352,11 +378,39 @@ const CommandEmpty = React.forwardRef<
352
378
  ref={setRef}
353
379
  aria-disabled="true"
354
380
  aria-selected="false"
355
- className="py-6 text-center text-sm"
381
+ className="text-body-sm py-6 text-center"
356
382
  data-hook={dataHook}
357
383
  data-slot="command-empty"
358
384
  {...props}
359
- />
385
+ >
386
+ {icon || description ? (
387
+ /* The compact form. Inside role="option" the content is
388
+ presentational, so the message stays a plain line — never a
389
+ heading — and the chip is aria-hidden. */
390
+ <div className="flex flex-col items-center gap-1 px-4">
391
+ {icon ? (
392
+ <span
393
+ aria-hidden="true"
394
+ className={cn(emptyChipStyles(), "mb-1")}
395
+ data-slot="command-empty-icon"
396
+ >
397
+ {icon}
398
+ </span>
399
+ ) : null}
400
+ <p data-slot="command-empty-message">{children}</p>
401
+ {description ? (
402
+ <p
403
+ className="text-muted-foreground"
404
+ data-slot="command-empty-description"
405
+ >
406
+ {description}
407
+ </p>
408
+ ) : null}
409
+ </div>
410
+ ) : (
411
+ children
412
+ )}
413
+ </CommandPrimitive.Empty>
360
414
  );
361
415
  });
362
416
  CommandEmpty.displayName = "CommandEmpty";
@@ -387,7 +441,7 @@ const CommandGroup = React.forwardRef<
387
441
  <CommandPrimitive.Group
388
442
  ref={ref}
389
443
  className={cn(
390
- "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
444
+ "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-label-sm overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5",
391
445
  className
392
446
  )}
393
447
  data-hook={dataHook}
@@ -480,7 +534,7 @@ const CommandItem = React.forwardRef<
480
534
  <CommandPrimitive.Item
481
535
  ref={ref}
482
536
  className={cn(
483
- "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
537
+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground text-label relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
484
538
  className
485
539
  )}
486
540
  data-hook={dataHook}
@@ -526,10 +580,7 @@ const CommandShortcut = React.forwardRef<HTMLSpanElement, CommandShortcutProps>(
526
580
  ({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
527
581
  <span
528
582
  ref={ref}
529
- className={cn(
530
- "text-muted-foreground ml-auto text-xs tracking-widest",
531
- className
532
- )}
583
+ className={cn("text-muted-foreground text-body-xs ml-auto", className)}
533
584
  data-hook={dataHook}
534
585
  data-slot="command-shortcut"
535
586
  data-tracking-el={trackingEl}
@@ -976,7 +1027,7 @@ const CommandVirtualItem = React.forwardRef<
976
1027
  aria-selected={selected || undefined}
977
1028
  aria-setsize={virtualCtx?.filteredCount}
978
1029
  className={cn(
979
- "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none",
1030
+ "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none",
980
1031
  "[&_svg]:pointer-events-none [&_svg]:shrink-0",
981
1032
  disabled && "pointer-events-none opacity-50",
982
1033
  className