@brightlocal/ui-components 2.26.0 → 2.27.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 (89) hide show
  1. package/README.md +4 -2
  2. package/component-meta.json +3761 -360
  3. package/dist/blocks/progress-screen.cjs +1 -0
  4. package/dist/blocks/progress-screen.d.ts +109 -0
  5. package/dist/blocks/progress-screen.d.ts.map +1 -0
  6. package/dist/blocks/progress-screen.js +339 -0
  7. package/dist/blocks/sidebar.cjs +1 -1
  8. package/dist/blocks/sidebar.d.ts.map +1 -1
  9. package/dist/blocks/sidebar.js +155 -153
  10. package/dist/brand-illustration-motif.d.ts +1 -1
  11. package/dist/breadcrumb.cjs +1 -1
  12. package/dist/breadcrumb.d.ts.map +1 -1
  13. package/dist/breadcrumb.js +44 -40
  14. package/dist/button.cjs +1 -1
  15. package/dist/button.d.ts.map +1 -1
  16. package/dist/button.js +28 -28
  17. package/dist/chip.cjs +1 -1
  18. package/dist/chip.d.ts +1 -1
  19. package/dist/chip.d.ts.map +1 -1
  20. package/dist/chip.js +42 -41
  21. package/dist/combobox.cjs +3 -3
  22. package/dist/combobox.d.ts +4 -2
  23. package/dist/combobox.d.ts.map +1 -1
  24. package/dist/combobox.js +161 -161
  25. package/dist/data-table.cjs +1 -1
  26. package/dist/data-table.d.ts +138 -3
  27. package/dist/data-table.d.ts.map +1 -1
  28. package/dist/data-table.js +455 -309
  29. package/dist/global-layout.cjs +1 -1
  30. package/dist/global-layout.d.ts +31 -5
  31. package/dist/global-layout.d.ts.map +1 -1
  32. package/dist/global-layout.js +276 -194
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +462 -451
  37. package/dist/lib/motion.cjs +1 -1
  38. package/dist/lib/motion.js +10 -8
  39. package/dist/link.cjs +1 -1
  40. package/dist/link.d.ts +8 -6
  41. package/dist/link.d.ts.map +1 -1
  42. package/dist/link.js +52 -20
  43. package/dist/list.cjs +1 -1
  44. package/dist/list.js +65 -63
  45. package/dist/progress.cjs +1 -1
  46. package/dist/progress.d.ts +61 -3
  47. package/dist/progress.d.ts.map +1 -1
  48. package/dist/progress.js +142 -65
  49. package/dist/route-progress.cjs +1 -0
  50. package/dist/route-progress.d.ts +103 -0
  51. package/dist/route-progress.d.ts.map +1 -0
  52. package/dist/route-progress.js +106 -0
  53. package/dist/sheet.cjs +1 -1
  54. package/dist/sheet.d.ts +35 -2
  55. package/dist/sheet.d.ts.map +1 -1
  56. package/dist/sheet.js +102 -65
  57. package/dist/sonner.cjs +1 -1
  58. package/dist/sonner.d.ts.map +1 -1
  59. package/dist/sonner.js +11 -15
  60. package/dist/spinner.cjs +1 -0
  61. package/dist/spinner.d.ts +57 -0
  62. package/dist/spinner.d.ts.map +1 -0
  63. package/dist/spinner.js +35 -0
  64. package/dist/stepper.cjs +1 -1
  65. package/dist/stepper.d.ts.map +1 -1
  66. package/dist/stepper.js +26 -25
  67. package/dist/table.cjs +1 -1
  68. package/dist/table.d.ts +1 -1
  69. package/dist/table.d.ts.map +1 -1
  70. package/dist/table.js +6 -2
  71. package/package.json +14 -2
  72. package/src/blocks/progress-screen.tsx +481 -0
  73. package/src/blocks/sidebar.tsx +22 -15
  74. package/src/components/breadcrumb.tsx +9 -4
  75. package/src/components/button.tsx +2 -5
  76. package/src/components/chip.tsx +4 -3
  77. package/src/components/combobox.tsx +15 -8
  78. package/src/components/data-table.tsx +333 -14
  79. package/src/components/global-layout.tsx +228 -62
  80. package/src/components/link.tsx +39 -5
  81. package/src/components/list.tsx +5 -5
  82. package/src/components/progress.tsx +217 -30
  83. package/src/components/route-progress.tsx +354 -0
  84. package/src/components/sheet.tsx +87 -5
  85. package/src/components/sonner.tsx +3 -12
  86. package/src/components/spinner.tsx +94 -0
  87. package/src/components/stepper.tsx +3 -4
  88. package/src/components/table.tsx +6 -2
  89. package/src/index.ts +3 -0
@@ -17,10 +17,33 @@ import { SPRING_GENTLE } from "../lib/motion";
17
17
  */
18
18
  type ProgressColor = "green" | "red" | "orange" | "yellow";
19
19
 
20
+ /**
21
+ * Text size of the label and value.
22
+ * - `sm` — 14px (`text-sm`), the default for metric rows in cards
23
+ * - `md` — 16px (`text-base`) for roomier layouts
24
+ */
25
+ type ProgressSize = "sm" | "md";
26
+
27
+ /**
28
+ * Per-size classes: text for the label and value, height for the bar — the row
29
+ * scales as one unit (`sm` 14px text / 8px bar, `md` 16px text / 12px bar).
30
+ * Bar heights are the `h-2` / `h-3` tokens the Figma component binds too.
31
+ */
32
+ const SIZE_STYLES: Record<ProgressSize, { text: string; bar: string }> = {
33
+ sm: { text: "text-sm", bar: "h-2" },
34
+ md: { text: "text-base", bar: "h-3" },
35
+ };
36
+
20
37
  /**
21
38
  * Track and indicator color classes for each brand color.
22
- * Single source of truth — the `/20` track tint blends with the surface so it
23
- * adapts automatically to light and dark modes.
39
+ *
40
+ * DESIGN DECISION (DS-773, 28 Aug 2026): the bar deliberately uses the brand
41
+ * palette — `green-400` (#2ae855) and `brand-red` / `brand-orange` /
42
+ * `brand-yellow` — NOT the softer `chart-*` score-band tokens. The track is the
43
+ * same colour at 20% over the surface. The Figma component binds the identical
44
+ * variables (`tailwind colors/green/400`, `base/brand-primary-foreground` +
45
+ * `alpha/20`, and the brand red/orange/yellow), so this is parity by choice;
46
+ * do not "fix" it back to `chart-*` without a design decision.
24
47
  */
25
48
  const COLOR_STYLES: Record<
26
49
  ProgressColor,
@@ -44,6 +67,15 @@ const COLOR_STYLES: Record<
44
67
  },
45
68
  };
46
69
 
70
+ /**
71
+ * Width of the label column as a share of the row, or `auto` to hug the text.
72
+ * Mirrors the Figma `Progress / Label` Width options.
73
+ */
74
+ type ProgressLabelWidth = "auto" | "20%" | "30%" | "40%" | "50%";
75
+
76
+ /** Default label column: 40% of the row. */
77
+ const DEFAULT_LABEL_WIDTH: ProgressLabelWidth = "40%";
78
+
47
79
  /**
48
80
  * Formats the numeric value shown beside the progress bar.
49
81
  * - Percentage form (`unit === "%"`): the value as a percentage of `max`,
@@ -97,14 +129,31 @@ interface ProgressProps extends React.ComponentProps<
97
129
  */
98
130
  ariaLabel?: string;
99
131
  /**
100
- * Optional visible label text displayed to the left of the progress bar
132
+ * Optional visible label text displayed to the left of the progress bar.
133
+ * Rendered inside a fixed-width column (see `labelWidth`); longer labels
134
+ * wrap onto further lines while the bar and value stay in their columns.
101
135
  */
102
136
  label?: string;
137
+ /**
138
+ * Width of the label column: `"20%"` … `"50%"` of the row in 10% steps, or
139
+ * `"auto"`. Every row that uses the same percentage starts its bar at the
140
+ * same x-position, so stacked rows inside a card line up — pick the step that
141
+ * keeps the labels in that card to one or two lines. Use `"auto"` for a
142
+ * single row that isn't aligned with others: the label hugs its text (capped
143
+ * at 40% of the row) and the bar starts right after it.
144
+ * @default "40%"
145
+ */
146
+ labelWidth?: ProgressLabelWidth;
103
147
  /**
104
148
  * Brand color for the indicator.
105
149
  * @default "green"
106
150
  */
107
151
  color?: ProgressColor;
152
+ /**
153
+ * Row size: `sm` = 14px text with an 8px bar, `md` = 16px text with a 12px bar.
154
+ * @default "sm"
155
+ */
156
+ size?: ProgressSize;
108
157
  /**
109
158
  * Whether to render the numeric value to the right of the progress bar.
110
159
  * Falls back to `–` when no value is provided so the layout stays consistent.
@@ -120,9 +169,33 @@ interface ProgressProps extends React.ComponentProps<
120
169
  unit?: string;
121
170
  /**
122
171
  * Custom class name for the indicator (progress fill)
123
- * Use this to customize the color, e.g., "bg-red-500"
172
+ * Use this to customize the color, e.g., "bg-chart-red"
124
173
  */
125
174
  indicatorClassName?: string;
175
+ /**
176
+ * A line describing what the run is doing right now — the step, not the
177
+ * number. Renders on its own line above the bar's row, so `label` stays on
178
+ * the left and the value on the right. It takes the row's `size`, so it reads
179
+ * as a peer of the value rather than a second scale.
180
+ *
181
+ * It is a polite live region, and it never becomes the bar's accessible name
182
+ * (`ariaLabel` still owns that) — which is what makes it the right slot for a
183
+ * status that moves, where `label` is not.
184
+ * @example "Scanning search results across your area"
185
+ */
186
+ statusDescription?: React.ReactNode;
187
+ /**
188
+ * Runs the bar as an indeterminate sweep: a short pill travelling the track
189
+ * for "running, and we cannot say how far". Use when work is genuinely
190
+ * underway but the backend reports no percentage — never as a stand-in for a
191
+ * number you could have fetched.
192
+ *
193
+ * `value` is ignored while this is set, the numeric readout is suppressed
194
+ * (there is nothing to report), and the bar drops `aria-valuenow` so assistive
195
+ * technology announces it as indeterminate rather than as 0%.
196
+ * @default false
197
+ */
198
+ indeterminate?: boolean;
126
199
  /**
127
200
  * Whether the progress is in a disabled state
128
201
  * When disabled, the component renders with 50% opacity
@@ -133,6 +206,12 @@ interface ProgressProps extends React.ComponentProps<
133
206
  /**
134
207
  * Progress component for displaying loading states and task completion.
135
208
  * Built on Radix UI Progress primitive with Framer Motion animation.
209
+ *
210
+ * With a `label` and/or `showValue` the bar renders as a three-column row:
211
+ * a fixed-width label column, the bar filling the remaining space, and a
212
+ * right-aligned value column sized to the widest value it can show — so rows
213
+ * stacked in a card share the same bar start position and width, even when
214
+ * a label wraps onto two lines.
136
215
  */
137
216
  const Progress = React.forwardRef<
138
217
  React.ComponentRef<typeof ProgressPrimitive.Root>,
@@ -148,10 +227,14 @@ const Progress = React.forwardRef<
148
227
  trackingLabel,
149
228
  ariaLabel = "Progress",
150
229
  label,
230
+ labelWidth = DEFAULT_LABEL_WIDTH,
151
231
  color = "green",
232
+ size = "sm",
152
233
  showValue = false,
153
234
  unit = "%",
154
235
  indicatorClassName,
236
+ statusDescription,
237
+ indeterminate = false,
155
238
  disabled,
156
239
  ...props
157
240
  },
@@ -162,6 +245,20 @@ const Progress = React.forwardRef<
162
245
  const prefersReducedMotion = usePrefersReducedMotion();
163
246
 
164
247
  const colorStyles = COLOR_STYLES[color] ?? COLOR_STYLES.green;
248
+ const sizeStyles = SIZE_STYLES[size] ?? SIZE_STYLES.sm;
249
+ const labelHugs = labelWidth === "auto";
250
+ /* An indeterminate bar has no number to report, so the readout is dropped
251
+ rather than left showing the `–` fallback. */
252
+ const showsValue = showValue && !indeterminate;
253
+ const hasStatus =
254
+ statusDescription !== null &&
255
+ statusDescription !== undefined &&
256
+ statusDescription !== false;
257
+ /* The bar only gets flex sizing when the row wrapper actually wraps it.
258
+ Standalone — no label, no value, which `indeterminate` makes common —
259
+ `flex-1` would grow it along a column parent's main axis and override the
260
+ size's height, rendering an 8px bar at whatever the row is tall. */
261
+ const inRow = hasVisibleLabel || showsValue;
165
262
  const percentage =
166
263
  max > 0 ? Math.min(100, Math.max(0, ((value ?? 0) / max) * 100)) : 0;
167
264
 
@@ -171,9 +268,13 @@ const Progress = React.forwardRef<
171
268
  aria-label={hasVisibleLabel ? undefined : ariaLabel}
172
269
  aria-labelledby={hasVisibleLabel ? labelId : undefined}
173
270
  className={cn(
174
- "relative h-2 w-full overflow-hidden rounded-full",
271
+ "relative w-full overflow-hidden rounded-full",
272
+ // Inside the row wrapper the bar fills whatever the fixed label and
273
+ // value columns leave over; standalone it must not flex at all.
274
+ inRow && "min-w-0 flex-1",
275
+ sizeStyles.bar,
175
276
  colorStyles.track,
176
- !hasVisibleLabel && !showValue && disabled && "opacity-50",
277
+ !hasVisibleLabel && !showsValue && disabled && "opacity-50",
177
278
  className
178
279
  )}
179
280
  data-hook={dataHook}
@@ -181,63 +282,149 @@ const Progress = React.forwardRef<
181
282
  data-tracking-el={trackingEl}
182
283
  data-tracking-label={trackingLabel}
183
284
  max={max}
184
- value={value}
285
+ /* null makes Radix mark the bar indeterminate and omit aria-valuenow,
286
+ so `indeterminate` is the only route to it. A value-less bar is a
287
+ placeholder row — it keeps the layout and shows "–" — and must stay
288
+ determinate, or it would be announced as indeterminate while
289
+ rendering an empty track with no sweep. */
290
+ value={indeterminate ? null : (value ?? 0)}
185
291
  {...props}
186
292
  >
187
- <ProgressPrimitive.Indicator asChild>
188
- <motion.div
189
- animate={{
190
- transform: `translateX(-${100 - percentage}%)`,
191
- }}
192
- className={cn(
193
- "h-full w-full flex-1",
194
- colorStyles.indicator,
195
- indicatorClassName
196
- )}
197
- data-slot="progress-indicator"
198
- initial={false}
199
- transition={prefersReducedMotion ? { duration: 0 } : SPRING_GENTLE}
200
- />
201
- </ProgressPrimitive.Indicator>
293
+ {indeterminate ? (
294
+ /* A short pill travelling the track. Under reduced motion it rests
295
+ mid-track instead: the global CSS reset would freeze the sweep on
296
+ its last frame, which is off-screen, leaving an empty bar. */
297
+ <ProgressPrimitive.Indicator asChild>
298
+ <div
299
+ className={cn(
300
+ "h-full w-2/5 rounded-full",
301
+ colorStyles.indicator,
302
+ prefersReducedMotion
303
+ ? "translate-x-[75%]"
304
+ : "animate-ambient-sweep",
305
+ indicatorClassName
306
+ )}
307
+ data-slot="progress-indicator"
308
+ />
309
+ </ProgressPrimitive.Indicator>
310
+ ) : (
311
+ <ProgressPrimitive.Indicator asChild>
312
+ <motion.div
313
+ animate={{
314
+ transform: `translateX(-${100 - percentage}%)`,
315
+ }}
316
+ className={cn(
317
+ "h-full w-full flex-1",
318
+ colorStyles.indicator,
319
+ indicatorClassName
320
+ )}
321
+ data-slot="progress-indicator"
322
+ initial={false}
323
+ transition={
324
+ prefersReducedMotion ? { duration: 0 } : SPRING_GENTLE
325
+ }
326
+ />
327
+ </ProgressPrimitive.Indicator>
328
+ )}
202
329
  </ProgressPrimitive.Root>
203
330
  );
204
331
 
205
- if (!hasVisibleLabel && !showValue) {
332
+ if (!hasVisibleLabel && !showsValue && !hasStatus) {
206
333
  return progressBar;
207
334
  }
208
335
 
209
- return (
336
+ /* The bar's own row is unchanged whether or not there is a status: label on
337
+ the left, value on the right. The value stays put — it belongs to the bar,
338
+ and moving it would make one prop change where a number lives. */
339
+ const inlineRow = (
210
340
  <div
211
341
  className={cn(
212
342
  "flex w-full items-center gap-2",
213
- disabled && "opacity-50"
343
+ !hasStatus && disabled && "opacity-50"
214
344
  )}
215
345
  data-slot="progress-wrapper"
216
346
  >
217
347
  {hasVisibleLabel && (
218
348
  <span
219
- className="text-foreground text-xs leading-none font-medium"
349
+ // Fixed column: `shrink-0` + explicit width. Long labels wrap
350
+ // (`break-words` also splits a single overlong word) instead of
351
+ // pushing the bar around.
352
+ className={cn(
353
+ "text-foreground shrink-0 font-medium break-words",
354
+ // `auto`: hug the text but never take more than 40% of the row,
355
+ // so an overlong label still wraps instead of squeezing the bar.
356
+ labelHugs && "max-w-2/5",
357
+ sizeStyles.text
358
+ )}
359
+ data-label-width={labelHugs ? "auto" : undefined}
220
360
  data-slot="progress-label"
221
361
  id={labelId}
362
+ style={labelHugs ? undefined : { width: labelWidth }}
222
363
  >
223
364
  {label}
224
365
  </span>
225
366
  )}
226
367
  {progressBar}
227
- {showValue && (
368
+ {showsValue && (
228
369
  <span
229
- className="text-muted-foreground shrink-0 text-xs leading-none tabular-nums"
370
+ className={cn(
371
+ "text-muted-foreground grid min-w-10 shrink-0 text-right tabular-nums",
372
+ sizeStyles.text
373
+ )}
230
374
  data-slot="progress-value"
231
375
  >
232
- {formatProgressValue(value, max, unit)}
376
+ {/*
377
+ Invisible sizer holding the widest value this row can show
378
+ (`100%`, `100 / 100 steps`), stacked under the real value in the
379
+ same grid cell. Every row with the same `max`/`unit` gets the same
380
+ value-column width — never below the 40px `min-w-10` floor that
381
+ the Figma component also uses — so bars end at the same x-position.
382
+ */}
383
+ <span
384
+ aria-hidden="true"
385
+ className="invisible col-start-1 row-start-1"
386
+ data-slot="progress-value-sizer"
387
+ >
388
+ {formatProgressValue(max, max, unit)}
389
+ </span>
390
+ <span
391
+ className="col-start-1 row-start-1"
392
+ data-slot="progress-value-text"
393
+ >
394
+ {formatProgressValue(value, max, unit)}
395
+ </span>
233
396
  </span>
234
397
  )}
235
398
  </div>
236
399
  );
400
+
401
+ /* A status sits on its own line above that row. Keeping it out of the row is
402
+ the point — inline it would shrink the bar and take over the bar's
403
+ accessible name, which is what `label` does. It takes the row's size, so
404
+ the status and the value read as one band rather than two scales. */
405
+ if (hasStatus) {
406
+ return (
407
+ <div
408
+ className={cn("flex w-full flex-col gap-2", disabled && "opacity-50")}
409
+ data-slot="progress-status-wrapper"
410
+ >
411
+ <span
412
+ aria-live="polite"
413
+ className={cn("text-muted-foreground", sizeStyles.text)}
414
+ data-slot="progress-status"
415
+ >
416
+ {statusDescription}
417
+ </span>
418
+ {inlineRow}
419
+ </div>
420
+ );
421
+ }
422
+
423
+ return inlineRow;
237
424
  }
238
425
  );
239
426
 
240
427
  Progress.displayName = "Progress";
241
428
 
242
429
  export { Progress };
243
- export type { ProgressProps, ProgressColor };
430
+ export type { ProgressProps, ProgressColor, ProgressSize, ProgressLabelWidth };