@brightlocal/ui-components 2.26.0 → 3.0.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 (284) hide show
  1. package/README.md +9 -2
  2. package/component-meta.json +4010 -255
  3. package/deprecations.json +189 -2
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.js +2 -2
  6. package/dist/alert-dialog.cjs +1 -1
  7. package/dist/alert-dialog.js +18 -18
  8. package/dist/alert.cjs +1 -1
  9. package/dist/alert.d.ts +11 -1
  10. package/dist/alert.d.ts.map +1 -1
  11. package/dist/alert.js +31 -28
  12. package/dist/avatar.cjs +1 -1
  13. package/dist/avatar.js +4 -4
  14. package/dist/badge.cjs +1 -1
  15. package/dist/badge.d.ts.map +1 -1
  16. package/dist/badge.js +15 -11
  17. package/dist/blocks/empty-state.cjs +1 -0
  18. package/dist/blocks/empty-state.d.ts +172 -0
  19. package/dist/blocks/empty-state.d.ts.map +1 -0
  20. package/dist/blocks/empty-state.js +155 -0
  21. package/dist/blocks/input-list.cjs +2 -2
  22. package/dist/blocks/input-list.d.ts.map +1 -1
  23. package/dist/blocks/input-list.js +124 -108
  24. package/dist/blocks/progress-state.cjs +1 -0
  25. package/dist/blocks/progress-state.d.ts +121 -0
  26. package/dist/blocks/progress-state.d.ts.map +1 -0
  27. package/dist/blocks/progress-state.js +368 -0
  28. package/dist/blocks/sidebar.cjs +1 -1
  29. package/dist/blocks/sidebar.d.ts.map +1 -1
  30. package/dist/blocks/sidebar.js +297 -296
  31. package/dist/brand-illustration-motif.d.ts +1 -1
  32. package/dist/breadcrumb.cjs +1 -1
  33. package/dist/breadcrumb.d.ts.map +1 -1
  34. package/dist/breadcrumb.js +44 -40
  35. package/dist/button.cjs +1 -1
  36. package/dist/button.d.ts.map +1 -1
  37. package/dist/button.js +23 -23
  38. package/dist/calendar.cjs +1 -1
  39. package/dist/calendar.d.ts.map +1 -1
  40. package/dist/calendar.js +37 -38
  41. package/dist/callout.cjs +1 -1
  42. package/dist/callout.d.ts +24 -2
  43. package/dist/callout.d.ts.map +1 -1
  44. package/dist/callout.js +57 -55
  45. package/dist/card.cjs +1 -1
  46. package/dist/card.d.ts +23 -2
  47. package/dist/card.d.ts.map +1 -1
  48. package/dist/card.js +94 -91
  49. package/dist/chart-empty.cjs +1 -0
  50. package/dist/chart-empty.d.ts +59 -0
  51. package/dist/chart-empty.d.ts.map +1 -0
  52. package/dist/chart-empty.js +29 -0
  53. package/dist/chart.cjs +6 -6
  54. package/dist/chart.d.ts +6 -1
  55. package/dist/chart.d.ts.map +1 -1
  56. package/dist/chart.js +183 -183
  57. package/dist/chip.cjs +1 -1
  58. package/dist/chip.d.ts +1 -1
  59. package/dist/chip.d.ts.map +1 -1
  60. package/dist/chip.js +47 -44
  61. package/dist/combobox.cjs +3 -3
  62. package/dist/combobox.d.ts +4 -2
  63. package/dist/combobox.d.ts.map +1 -1
  64. package/dist/combobox.js +143 -141
  65. package/dist/command.cjs +1 -1
  66. package/dist/command.d.ts.map +1 -1
  67. package/dist/command.js +74 -77
  68. package/dist/context-menu.cjs +1 -1
  69. package/dist/context-menu.d.ts.map +1 -1
  70. package/dist/context-menu.js +26 -29
  71. package/dist/data-table.cjs +1 -1
  72. package/dist/data-table.d.ts +182 -13
  73. package/dist/data-table.d.ts.map +1 -1
  74. package/dist/data-table.js +462 -314
  75. package/dist/description.cjs +1 -1
  76. package/dist/description.js +5 -5
  77. package/dist/dialog.cjs +1 -1
  78. package/dist/dialog.js +20 -20
  79. package/dist/drawer.cjs +1 -1
  80. package/dist/drawer.d.ts.map +1 -1
  81. package/dist/drawer.js +8 -11
  82. package/dist/dropdown-menu.cjs +1 -1
  83. package/dist/dropdown-menu.d.ts.map +1 -1
  84. package/dist/dropdown-menu.js +17 -20
  85. package/dist/field.cjs +1 -1
  86. package/dist/field.d.ts.map +1 -1
  87. package/dist/field.js +29 -25
  88. package/dist/global-layout.cjs +1 -1
  89. package/dist/global-layout.d.ts +58 -6
  90. package/dist/global-layout.d.ts.map +1 -1
  91. package/dist/global-layout.js +278 -194
  92. package/dist/grid.cjs +1 -0
  93. package/dist/grid.d.ts +56 -0
  94. package/dist/grid.d.ts.map +1 -0
  95. package/dist/grid.js +32 -0
  96. package/dist/header.d.ts +13 -0
  97. package/dist/header.d.ts.map +1 -1
  98. package/dist/hooks/use-delayed-pending.cjs +1 -0
  99. package/dist/hooks/use-delayed-pending.d.ts +34 -0
  100. package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
  101. package/dist/hooks/use-delayed-pending.js +17 -0
  102. package/dist/hover-card.cjs +1 -1
  103. package/dist/hover-card.js +13 -13
  104. package/dist/index.cjs +1 -1
  105. package/dist/index.d.ts +10 -0
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +523 -494
  108. package/dist/input-chip.cjs +1 -1
  109. package/dist/input-chip.js +25 -25
  110. package/dist/input-group.cjs +1 -1
  111. package/dist/input-group.js +9 -9
  112. package/dist/input-otp.cjs +1 -1
  113. package/dist/input-otp.js +9 -9
  114. package/dist/input-password.cjs +1 -1
  115. package/dist/input-password.js +51 -51
  116. package/dist/input.cjs +1 -1
  117. package/dist/input.js +9 -9
  118. package/dist/label.cjs +1 -1
  119. package/dist/label.d.ts.map +1 -1
  120. package/dist/label.js +25 -28
  121. package/dist/lib/block-illustration.cjs +1 -0
  122. package/dist/lib/block-illustration.d.ts +28 -0
  123. package/dist/lib/block-illustration.d.ts.map +1 -0
  124. package/dist/lib/block-illustration.js +21 -0
  125. package/dist/lib/empty-canvas.cjs +1 -0
  126. package/dist/lib/empty-canvas.d.ts +27 -0
  127. package/dist/lib/empty-canvas.d.ts.map +1 -0
  128. package/dist/lib/empty-canvas.js +62 -0
  129. package/dist/lib/motion.cjs +1 -1
  130. package/dist/lib/motion.js +10 -8
  131. package/dist/lib/optical-center.cjs +1 -0
  132. package/dist/lib/optical-center.d.ts +12 -0
  133. package/dist/lib/optical-center.d.ts.map +1 -0
  134. package/dist/lib/optical-center.js +11 -0
  135. package/dist/lib/utils.cjs +1 -1
  136. package/dist/lib/utils.d.ts.map +1 -1
  137. package/dist/lib/utils.js +28 -5
  138. package/dist/link.cjs +1 -1
  139. package/dist/link.d.ts +8 -6
  140. package/dist/link.d.ts.map +1 -1
  141. package/dist/link.js +52 -20
  142. package/dist/list.cjs +1 -1
  143. package/dist/list.d.ts.map +1 -1
  144. package/dist/list.js +87 -81
  145. package/dist/map.cjs +1 -1
  146. package/dist/map.d.ts +60 -2
  147. package/dist/map.d.ts.map +1 -1
  148. package/dist/map.js +187 -164
  149. package/dist/media-empty.cjs +1 -0
  150. package/dist/media-empty.d.ts +72 -0
  151. package/dist/media-empty.d.ts.map +1 -0
  152. package/dist/media-empty.js +45 -0
  153. package/dist/menubar.cjs +1 -1
  154. package/dist/menubar.d.ts.map +1 -1
  155. package/dist/menubar.js +17 -20
  156. package/dist/navigation-menu.cjs +1 -1
  157. package/dist/navigation-menu.js +7 -7
  158. package/dist/pagination.cjs +1 -1
  159. package/dist/pagination.d.ts +127 -1
  160. package/dist/pagination.d.ts.map +1 -1
  161. package/dist/pagination.js +189 -98
  162. package/dist/progress.cjs +1 -1
  163. package/dist/progress.d.ts +37 -3
  164. package/dist/progress.d.ts.map +1 -1
  165. package/dist/progress.js +102 -64
  166. package/dist/route-progress.cjs +1 -0
  167. package/dist/route-progress.d.ts +103 -0
  168. package/dist/route-progress.d.ts.map +1 -0
  169. package/dist/route-progress.js +106 -0
  170. package/dist/select.cjs +2 -2
  171. package/dist/select.d.ts.map +1 -1
  172. package/dist/select.js +19 -18
  173. package/dist/separator.cjs +1 -1
  174. package/dist/separator.js +8 -8
  175. package/dist/sheet.cjs +1 -1
  176. package/dist/sheet.d.ts +35 -2
  177. package/dist/sheet.d.ts.map +1 -1
  178. package/dist/sheet.js +103 -66
  179. package/dist/skeleton.cjs +1 -1
  180. package/dist/skeleton.d.ts +38 -3
  181. package/dist/skeleton.d.ts.map +1 -1
  182. package/dist/skeleton.js +43 -20
  183. package/dist/sonner.cjs +1 -1
  184. package/dist/sonner.d.ts.map +1 -1
  185. package/dist/sonner.js +32 -36
  186. package/dist/spinner.cjs +1 -0
  187. package/dist/spinner.d.ts +57 -0
  188. package/dist/spinner.d.ts.map +1 -0
  189. package/dist/spinner.js +35 -0
  190. package/dist/stepper.cjs +1 -1
  191. package/dist/stepper.d.ts.map +1 -1
  192. package/dist/stepper.js +23 -22
  193. package/dist/table.cjs +1 -1
  194. package/dist/table.d.ts +1 -1
  195. package/dist/table.d.ts.map +1 -1
  196. package/dist/table.js +36 -29
  197. package/dist/tabs.cjs +1 -1
  198. package/dist/tabs.js +1 -1
  199. package/dist/text-reveal-motion.d.ts +10 -0
  200. package/dist/text-reveal-motion.d.ts.map +1 -1
  201. package/dist/textarea.cjs +1 -1
  202. package/dist/textarea.js +11 -11
  203. package/dist/toggle.cjs +1 -1
  204. package/dist/toggle.js +8 -8
  205. package/dist/tooltip.cjs +1 -1
  206. package/dist/tooltip.js +8 -8
  207. package/dist/typography-heading.cjs +1 -0
  208. package/dist/typography-heading.d.ts +116 -0
  209. package/dist/typography-heading.d.ts.map +1 -0
  210. package/dist/typography-heading.js +84 -0
  211. package/dist/typography-text.cjs +1 -0
  212. package/dist/typography-text.d.ts +113 -0
  213. package/dist/typography-text.d.ts.map +1 -0
  214. package/dist/typography-text.js +81 -0
  215. package/dist/typography.d.ts +13 -0
  216. package/dist/typography.d.ts.map +1 -1
  217. package/package.json +42 -2
  218. package/src/blocks/empty-state.tsx +424 -0
  219. package/src/blocks/input-list.tsx +66 -36
  220. package/src/blocks/progress-state.tsx +542 -0
  221. package/src/blocks/sidebar.tsx +46 -40
  222. package/src/components/accordion.tsx +2 -2
  223. package/src/components/alert-dialog.tsx +2 -2
  224. package/src/components/alert.tsx +27 -13
  225. package/src/components/avatar.tsx +1 -1
  226. package/src/components/badge.tsx +8 -4
  227. package/src/components/breadcrumb.tsx +9 -4
  228. package/src/components/button.tsx +5 -8
  229. package/src/components/calendar.tsx +5 -6
  230. package/src/components/callout.tsx +48 -15
  231. package/src/components/card.tsx +52 -17
  232. package/src/components/chart-empty.tsx +116 -0
  233. package/src/components/chart.tsx +43 -17
  234. package/src/components/chip.tsx +9 -6
  235. package/src/components/combobox.tsx +21 -12
  236. package/src/components/command.tsx +9 -10
  237. package/src/components/context-menu.tsx +6 -9
  238. package/src/components/data-table.tsx +405 -31
  239. package/src/components/description.tsx +1 -1
  240. package/src/components/dialog.tsx +2 -2
  241. package/src/components/drawer.tsx +2 -5
  242. package/src/components/dropdown-menu.tsx +8 -11
  243. package/src/components/field.tsx +8 -4
  244. package/src/components/global-layout.tsx +264 -65
  245. package/src/components/grid.tsx +130 -0
  246. package/src/components/header.tsx +13 -0
  247. package/src/components/hover-card.tsx +1 -1
  248. package/src/components/input-chip.tsx +1 -1
  249. package/src/components/input-group.tsx +1 -1
  250. package/src/components/input-otp.tsx +1 -1
  251. package/src/components/input-password.tsx +1 -1
  252. package/src/components/input.tsx +1 -1
  253. package/src/components/label.tsx +10 -13
  254. package/src/components/link.tsx +39 -5
  255. package/src/components/list.tsx +18 -14
  256. package/src/components/map.tsx +101 -5
  257. package/src/components/media-empty.tsx +156 -0
  258. package/src/components/menubar.tsx +7 -10
  259. package/src/components/navigation-menu.tsx +1 -1
  260. package/src/components/pagination.tsx +279 -1
  261. package/src/components/progress.tsx +120 -11
  262. package/src/components/route-progress.tsx +354 -0
  263. package/src/components/select.tsx +5 -4
  264. package/src/components/separator.tsx +1 -1
  265. package/src/components/sheet.tsx +89 -7
  266. package/src/components/skeleton.tsx +78 -7
  267. package/src/components/sonner.tsx +5 -14
  268. package/src/components/spinner.tsx +94 -0
  269. package/src/components/stepper.tsx +6 -7
  270. package/src/components/table.tsx +11 -4
  271. package/src/components/tabs.tsx +1 -1
  272. package/src/components/text-reveal-motion.tsx +10 -0
  273. package/src/components/textarea.tsx +1 -1
  274. package/src/components/toggle.tsx +1 -1
  275. package/src/components/tooltip.tsx +1 -1
  276. package/src/components/typography-heading.tsx +229 -0
  277. package/src/components/typography-text.tsx +225 -0
  278. package/src/components/typography.tsx +13 -0
  279. package/src/hooks/use-delayed-pending.ts +60 -0
  280. package/src/index.ts +12 -0
  281. package/src/lib/block-illustration.tsx +88 -0
  282. package/src/lib/empty-canvas.tsx +128 -0
  283. package/src/lib/optical-center.tsx +45 -0
  284. package/src/lib/utils.ts +26 -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-body-sm`), the default for metric rows in cards
23
+ * - `md` — 16px (`text-body`) 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-body-sm", bar: "h-2" },
34
+ md: { text: "text-body", 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,7 +169,7 @@ 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;
126
175
  /**
@@ -133,6 +182,12 @@ interface ProgressProps extends React.ComponentProps<
133
182
  /**
134
183
  * Progress component for displaying loading states and task completion.
135
184
  * Built on Radix UI Progress primitive with Framer Motion animation.
185
+ *
186
+ * With a `label` and/or `showValue` the bar renders as a three-column row:
187
+ * a fixed-width label column, the bar filling the remaining space, and a
188
+ * right-aligned value column sized to the widest value it can show — so rows
189
+ * stacked in a card share the same bar start position and width, even when
190
+ * a label wraps onto two lines.
136
191
  */
137
192
  const Progress = React.forwardRef<
138
193
  React.ComponentRef<typeof ProgressPrimitive.Root>,
@@ -148,7 +203,9 @@ const Progress = React.forwardRef<
148
203
  trackingLabel,
149
204
  ariaLabel = "Progress",
150
205
  label,
206
+ labelWidth = DEFAULT_LABEL_WIDTH,
151
207
  color = "green",
208
+ size = "sm",
152
209
  showValue = false,
153
210
  unit = "%",
154
211
  indicatorClassName,
@@ -162,6 +219,13 @@ const Progress = React.forwardRef<
162
219
  const prefersReducedMotion = usePrefersReducedMotion();
163
220
 
164
221
  const colorStyles = COLOR_STYLES[color] ?? COLOR_STYLES.green;
222
+ const sizeStyles = SIZE_STYLES[size] ?? SIZE_STYLES.sm;
223
+ const labelHugs = labelWidth === "auto";
224
+ /* The bar only gets flex sizing when the row wrapper actually wraps it.
225
+ Standalone — no label and no value — `flex-1` would grow it along a
226
+ column parent's main axis and override the size's height, rendering an
227
+ 8px bar at whatever the row is tall. */
228
+ const inRow = hasVisibleLabel || showValue;
165
229
  const percentage =
166
230
  max > 0 ? Math.min(100, Math.max(0, ((value ?? 0) / max) * 100)) : 0;
167
231
 
@@ -171,7 +235,11 @@ const Progress = React.forwardRef<
171
235
  aria-label={hasVisibleLabel ? undefined : ariaLabel}
172
236
  aria-labelledby={hasVisibleLabel ? labelId : undefined}
173
237
  className={cn(
174
- "relative h-2 w-full overflow-hidden rounded-full",
238
+ "relative w-full overflow-hidden rounded-full",
239
+ // Inside the row wrapper the bar fills whatever the fixed label and
240
+ // value columns leave over; standalone it must not flex at all.
241
+ inRow && "min-w-0 flex-1",
242
+ sizeStyles.bar,
175
243
  colorStyles.track,
176
244
  !hasVisibleLabel && !showValue && disabled && "opacity-50",
177
245
  className
@@ -181,7 +249,12 @@ const Progress = React.forwardRef<
181
249
  data-tracking-el={trackingEl}
182
250
  data-tracking-label={trackingLabel}
183
251
  max={max}
184
- value={value}
252
+ /* Always a number, never null: null is how Radix marks a bar
253
+ indeterminate and drops aria-valuenow, and this bar is always
254
+ measuring something. A value-less bar is a placeholder row — it
255
+ keeps the layout and shows "–" — so it stays determinate rather
256
+ than being announced as indeterminate over an empty track. */
257
+ value={value ?? 0}
185
258
  {...props}
186
259
  >
187
260
  <ProgressPrimitive.Indicator asChild>
@@ -206,7 +279,8 @@ const Progress = React.forwardRef<
206
279
  return progressBar;
207
280
  }
208
281
 
209
- return (
282
+ /* The bar's row: label on the left, bar in the middle, value on the right. */
283
+ const inlineRow = (
210
284
  <div
211
285
  className={cn(
212
286
  "flex w-full items-center gap-2",
@@ -216,9 +290,20 @@ const Progress = React.forwardRef<
216
290
  >
217
291
  {hasVisibleLabel && (
218
292
  <span
219
- className="text-foreground text-xs leading-none font-medium"
293
+ // Fixed column: `shrink-0` + explicit width. Long labels wrap
294
+ // (`break-words` also splits a single overlong word) instead of
295
+ // pushing the bar around.
296
+ className={cn(
297
+ "text-foreground shrink-0 break-words",
298
+ // `auto`: hug the text but never take more than 40% of the row,
299
+ // so an overlong label still wraps instead of squeezing the bar.
300
+ labelHugs && "max-w-2/5",
301
+ sizeStyles.text
302
+ )}
303
+ data-label-width={labelHugs ? "auto" : undefined}
220
304
  data-slot="progress-label"
221
305
  id={labelId}
306
+ style={labelHugs ? undefined : { width: labelWidth }}
222
307
  >
223
308
  {label}
224
309
  </span>
@@ -226,18 +311,42 @@ const Progress = React.forwardRef<
226
311
  {progressBar}
227
312
  {showValue && (
228
313
  <span
229
- className="text-muted-foreground shrink-0 text-xs leading-none tabular-nums"
314
+ className={cn(
315
+ "text-muted-foreground grid min-w-10 shrink-0 text-right tabular-nums",
316
+ sizeStyles.text
317
+ )}
230
318
  data-slot="progress-value"
231
319
  >
232
- {formatProgressValue(value, max, unit)}
320
+ {/*
321
+ Invisible sizer holding the widest value this row can show
322
+ (`100%`, `100 / 100 steps`), stacked under the real value in the
323
+ same grid cell. Every row with the same `max`/`unit` gets the same
324
+ value-column width — never below the 40px `min-w-10` floor that
325
+ the Figma component also uses — so bars end at the same x-position.
326
+ */}
327
+ <span
328
+ aria-hidden="true"
329
+ className="invisible col-start-1 row-start-1"
330
+ data-slot="progress-value-sizer"
331
+ >
332
+ {formatProgressValue(max, max, unit)}
333
+ </span>
334
+ <span
335
+ className="col-start-1 row-start-1"
336
+ data-slot="progress-value-text"
337
+ >
338
+ {formatProgressValue(value, max, unit)}
339
+ </span>
233
340
  </span>
234
341
  )}
235
342
  </div>
236
343
  );
344
+
345
+ return inlineRow;
237
346
  }
238
347
  );
239
348
 
240
349
  Progress.displayName = "Progress";
241
350
 
242
351
  export { Progress };
243
- export type { ProgressProps, ProgressColor };
352
+ export type { ProgressProps, ProgressColor, ProgressSize, ProgressLabelWidth };
@@ -0,0 +1,354 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+
5
+ import { usePrefersReducedMotion } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
6
+ import { cn } from "@brightlocal/ui-components/lib/utils";
7
+ import {
8
+ MOTION_DURATION_BASE_MS,
9
+ MOTION_DURATION_FAST_MS,
10
+ } from "../lib/motion";
11
+
12
+ /* -------------------------------------------------------------------------------------------------
13
+ * Trickle constants
14
+ * -------------------------------------------------------------------------------------------------*/
15
+
16
+ /**
17
+ * Fill the bar starts at, as a percentage of the viewport width.
18
+ *
19
+ * Never zero: the bar's first job is to acknowledge the click, and a
20
+ * zero-width bar acknowledges nothing. This is the one place the Loading
21
+ * pattern's Restraint principle does not apply — there is no minimum wait
22
+ * before the bar appears, because it reports the input rather than the wait.
23
+ */
24
+ const START_FILL = 12;
25
+
26
+ /**
27
+ * Ceiling the creep approaches while the navigation is still in flight.
28
+ *
29
+ * Below 100 by design: the bar must never claim to be finished while the
30
+ * destination is still resolving. The remaining 10% is spent by the
31
+ * completion sweep.
32
+ */
33
+ const CREEP_TARGET = 90;
34
+
35
+ /**
36
+ * How long the creep takes to travel from {@link START_FILL} to
37
+ * {@link CREEP_TARGET}.
38
+ *
39
+ * Deliberately off the motion duration scale: this is not a UI state change
40
+ * but a progress trickle, and the scale tops out at 300ms. Paired with
41
+ * {@link CREEP_EASE} it front-loads most of the travel into the first second
42
+ * — where the great majority of navigations finish — and then slows to a
43
+ * crawl, so a slow route still shows movement without ever arriving.
44
+ */
45
+ const CREEP_MS = 12000;
46
+
47
+ /**
48
+ * Strongly decelerating curve for the creep, taken from the motion token
49
+ * scale (`ease-emphasized`). A single long CSS transition on this curve gives
50
+ * the asymptotic trickle without a timer: because transitions interpolate
51
+ * from the *current computed value*, the completion sweep can interrupt it at
52
+ * any point and pick up exactly where it is.
53
+ */
54
+ const CREEP_EASE = "var(--ds-motion-ease-emphasized)";
55
+
56
+ /**
57
+ * Grace period on the *falling* edge only: `active` going false schedules the
58
+ * completion rather than firing it, and `active` returning true inside the
59
+ * window cancels it and keeps the creep running.
60
+ *
61
+ * This exists because a real "has it settled?" signal is usually two signals
62
+ * handed off in sequence — the router stops being pending, then the
63
+ * destination's route-critical queries start. Without the grace the bar would
64
+ * sweep to 100%, fade, and immediately restart from 12% in the gap between
65
+ * them. The rising edge is never debounced: the bar still starts on the click
66
+ * with no threshold.
67
+ */
68
+ const SETTLE_GRACE_MS = MOTION_DURATION_FAST_MS;
69
+
70
+ /**
71
+ * Static fill used when `prefers-reduced-motion` is set — the bar is present
72
+ * for the whole navigation but never moves. Mid-track so it reads as
73
+ * in-progress rather than as almost-done.
74
+ */
75
+ const STATIC_FILL = 50;
76
+
77
+ /* -------------------------------------------------------------------------------------------------
78
+ * RouteProgress
79
+ * -------------------------------------------------------------------------------------------------*/
80
+
81
+ /**
82
+ * Lifecycle phase of the bar.
83
+ * - `idle` — no navigation in flight; the track is mounted but invisible.
84
+ * - `start` — navigation just began; the bar is painted at {@link START_FILL}.
85
+ * - `creep` — travelling toward {@link CREEP_TARGET} while the route resolves.
86
+ * - `complete` — sweeping to 100%, then fading out.
87
+ */
88
+ type RouteProgressPhase = "idle" | "start" | "creep" | "complete";
89
+
90
+ /**
91
+ * Props for the RouteProgress component.
92
+ */
93
+ interface RouteProgressProps extends Omit<
94
+ React.ComponentPropsWithoutRef<"div">,
95
+ "children"
96
+ > {
97
+ /**
98
+ * Required data-hook attribute for testing and component identification
99
+ */
100
+ dataHook: string;
101
+ /**
102
+ * Whether a full route navigation is in flight.
103
+ *
104
+ * Derive it from the router rather than from a click handler — that is what
105
+ * gives the remaining pattern guarantees for free: browser back and forward
106
+ * run the bar too, and in-page changes (tabs, filter changes, pagination
107
+ * refetches, modals) never touch it, because none of them are route
108
+ * navigations.
109
+ *
110
+ * ```tsx
111
+ * const navigating = useRouterState({
112
+ * select: (state) => state.status === "pending",
113
+ * });
114
+ * <RouteProgress active={navigating} dataHook="route-progress" />
115
+ * ```
116
+ *
117
+ * Prefer `status === "pending"` over `isLoading`: `isLoading` clears as soon
118
+ * as the route's loaders resolve, whereas `status` returns to `"idle"` only
119
+ * once `isLoading`, `isTransitioning` and `hasPendingMatches` are all false
120
+ * — so it also covers the React transition that commits the new route. And
121
+ * always pass `select`; `useRouterState()` with no selector re-renders the
122
+ * whole subtree on any router state change.
123
+ *
124
+ * **Router pending alone only means "the page is here", not "the page is
125
+ * ready."** It is the whole answer when the route declares its
126
+ * route-critical data in a loader — with TanStack Router,
127
+ * `loader: () => queryClient.ensureQueryData(...)` keeps `status` pending
128
+ * until that data has landed, which is exactly the signal this bar wants.
129
+ *
130
+ * Where components instead fetch on mount, the router goes idle as soon as
131
+ * the route commits and the bar finishes while skeletons are still
132
+ * rendering. Add the destination's own queries — **scoped to the route**,
133
+ * never a global `useIsFetching()`, which a polling or failing section would
134
+ * hold open forever:
135
+ *
136
+ * ```tsx
137
+ * const navigating = useRouterState({ select: (s) => s.status === "pending" });
138
+ * const loadingPage = useIsFetching({ queryKey: ["location", locationId] }) > 0;
139
+ * <RouteProgress active={navigating || loadingPage} dataHook="route-progress" />
140
+ * ```
141
+ *
142
+ * Handing off between two such signals is safe: the bar debounces the
143
+ * falling edge, so it stays continuous through the gap instead of sweeping
144
+ * and restarting. The rising edge is never debounced.
145
+ *
146
+ * Aim at *route-critical* content, not every query on the page. A
147
+ * below-the-fold widget that is slow, failing, or polling must keep its own
148
+ * skeleton and let the bar finish — a bar still running on a usable page
149
+ * reads as a hang.
150
+ */
151
+ active: boolean;
152
+ /**
153
+ * Optional tracking element identifier for analytics
154
+ */
155
+ trackingEl?: string;
156
+ /**
157
+ * Optional tracking label for analytics
158
+ */
159
+ trackingLabel?: string;
160
+ /**
161
+ * Announced politely to screen readers while `active` is true. The bar
162
+ * itself is decorative — its fill is a trickle, not measured progress, so
163
+ * it exposes no `progressbar` role or `aria-valuenow`.
164
+ * @default "Loading page"
165
+ */
166
+ navigatingLabel?: string;
167
+ }
168
+
169
+ /**
170
+ * A slim bar pinned to the top edge of the viewport that reports a full route
171
+ * navigation: it starts the moment the navigation begins and completes when
172
+ * the destination's route-critical content has settled.
173
+ *
174
+ * Its appearance answers *did my click work?*; its completion answers *is the
175
+ * page here yet?* It runs alongside the destination's own skeletons rather
176
+ * than instead of them — the two work at different scopes, and
177
+ * `RouteProgress (the navigation) over destination skeletons (each section) →
178
+ * content` is the normal lifecycle.
179
+ *
180
+ * Position is `fixed` at the viewport's top edge, so the bar blocks nothing
181
+ * and shifts nothing. Per the className policy the outer box is the
182
+ * consumer's: pass `className` to re-anchor it (for example `absolute` inside
183
+ * a positioned container), and the bar's own identity stays ours.
184
+ *
185
+ * Keeping the current page mounted until the destination commits is the
186
+ * router's job, not the bar's — tearing down a working screen costs people
187
+ * their context.
188
+ *
189
+ * See `Patterns/Loading → Page loading → Route transitions` in Storybook for
190
+ * the full guidance and the end-to-end demo.
191
+ */
192
+ const RouteProgress = React.forwardRef<HTMLDivElement, RouteProgressProps>(
193
+ (
194
+ {
195
+ className,
196
+ active,
197
+ dataHook,
198
+ trackingEl,
199
+ trackingLabel,
200
+ navigatingLabel = "Loading page",
201
+ style,
202
+ ...props
203
+ },
204
+ ref
205
+ ) => {
206
+ const prefersReducedMotion = usePrefersReducedMotion();
207
+ const [phase, setPhase] = React.useState<RouteProgressPhase>("idle");
208
+
209
+ // Navigation started: rise immediately, with no threshold. A navigation
210
+ // that begins while the previous one is still fading restarts the bar.
211
+ //
212
+ // Navigation ended: schedule the completion rather than firing it, so a
213
+ // hand-off between two signals (router pending → destination queries)
214
+ // keeps one continuous bar instead of a sweep-and-restart. Completing from
215
+ // `idle` would flash a bar for a navigation that was never announced, so
216
+ // idle stays idle.
217
+ React.useEffect(() => {
218
+ if (active) {
219
+ setPhase((current) =>
220
+ current === "start" || current === "creep" ? current : "start"
221
+ );
222
+ return;
223
+ }
224
+ const timer = setTimeout(
225
+ () => setPhase((current) => (current === "idle" ? "idle" : "complete")),
226
+ SETTLE_GRACE_MS
227
+ );
228
+ return () => clearTimeout(timer);
229
+ }, [active]);
230
+
231
+ // Hand off from the start fill to the creep. Two frames: the first lets
232
+ // the browser paint the bar at START_FILL, the second changes the target
233
+ // so the transition actually runs instead of being collapsed into the
234
+ // same commit.
235
+ React.useEffect(() => {
236
+ if (phase !== "start" || prefersReducedMotion) {
237
+ return;
238
+ }
239
+ let inner = 0;
240
+ const outer = requestAnimationFrame(() => {
241
+ inner = requestAnimationFrame(() =>
242
+ setPhase((current) => (current === "start" ? "creep" : current))
243
+ );
244
+ });
245
+ return () => {
246
+ cancelAnimationFrame(outer);
247
+ cancelAnimationFrame(inner);
248
+ };
249
+ }, [phase, prefersReducedMotion]);
250
+
251
+ // Reset once the sweep and the fade have played out, so the next
252
+ // navigation starts from a clean track.
253
+ React.useEffect(() => {
254
+ if (phase !== "complete") {
255
+ return;
256
+ }
257
+ const timer = setTimeout(
258
+ () =>
259
+ setPhase((current) => (current === "complete" ? "idle" : current)),
260
+ prefersReducedMotion
261
+ ? 0
262
+ : MOTION_DURATION_BASE_MS + MOTION_DURATION_FAST_MS
263
+ );
264
+ return () => clearTimeout(timer);
265
+ }, [phase, prefersReducedMotion]);
266
+
267
+ const navigating = phase === "start" || phase === "creep";
268
+
269
+ // Idle rests at START_FILL rather than 0 so the next navigation's first
270
+ // painted frame is already the start fill — nothing to animate in.
271
+ const fill =
272
+ phase === "complete"
273
+ ? 100
274
+ : phase === "creep"
275
+ ? CREEP_TARGET
276
+ : phase === "start" && prefersReducedMotion
277
+ ? STATIC_FILL
278
+ : START_FILL;
279
+
280
+ let transition = "none";
281
+ if (!prefersReducedMotion) {
282
+ if (phase === "creep") {
283
+ transition = `clip-path ${CREEP_MS}ms ${CREEP_EASE}`;
284
+ } else if (phase === "complete") {
285
+ // The delayed opacity keeps the bar visible for the whole sweep, then
286
+ // fades it — completion has to be seen to mean anything. Durations
287
+ // come from the token scale; MOTION_DURATION_*_MS below is the JS
288
+ // mirror of the same values, used only to time the reset.
289
+ transition =
290
+ "clip-path var(--ds-motion-duration-base) ease-out, opacity var(--ds-motion-duration-fast) ease-out var(--ds-motion-duration-base)";
291
+ }
292
+ }
293
+
294
+ return (
295
+ <>
296
+ <div
297
+ ref={ref}
298
+ aria-hidden="true"
299
+ className={cn(
300
+ // z-60, not z-50: every DS overlay (Dialog, Sheet, Drawer,
301
+ // AlertDialog) is `fixed inset-0 z-50` and portals to <body>, so at
302
+ // an equal z-index it would paint over the bar by DOM order. A
303
+ // navigation started from inside a modal must still be reported.
304
+ "pointer-events-none fixed inset-x-0 top-0 z-60 h-0.5 overflow-hidden",
305
+ className
306
+ )}
307
+ data-hook={dataHook}
308
+ data-slot="route-progress"
309
+ data-state={phase}
310
+ data-tracking-el={trackingEl}
311
+ data-tracking-label={trackingLabel}
312
+ style={style}
313
+ {...props}
314
+ >
315
+ <span
316
+ /* Solid brand green, the same colour as the primary button.
317
+ `--primary` flips to green-900 in dark because it is a button
318
+ *fill* sitting under light text, and as a 2px hairline that
319
+ reads at ~2.15:1 — so dark keeps the light-mode primary value
320
+ instead. Same override the Button itself uses for its label
321
+ (`dark:text-[var(--ds-colors-primary-foreground-light)]`), and
322
+ the same thing the Figma component does in its dark showcase. */
323
+ className="bg-primary absolute inset-0 dark:bg-[var(--ds-colors-primary-light)]"
324
+ data-slot="route-progress-bar"
325
+ style={{
326
+ /* Painted across the full track and revealed by clip-path, so
327
+ the fill's colour is identical at every width. */
328
+ clipPath: `inset(0 ${100 - fill}% 0 0)`,
329
+ opacity: navigating ? 1 : 0,
330
+ transition,
331
+ }}
332
+ />
333
+ </div>
334
+ {/* `sr-only` is position:absolute, which resolves against whatever
335
+ positioned ancestor the consumer happens to have and can inflate a
336
+ scroll container's scrollHeight. `fixed` resolves against the
337
+ viewport instead, so this 1px node can never affect layout. */}
338
+ <span
339
+ aria-atomic="true"
340
+ aria-live="polite"
341
+ className="sr-only fixed"
342
+ data-slot="route-progress-status"
343
+ >
344
+ {navigating ? navigatingLabel : ""}
345
+ </span>
346
+ </>
347
+ );
348
+ }
349
+ );
350
+
351
+ RouteProgress.displayName = "RouteProgress";
352
+
353
+ export { RouteProgress };
354
+ export type { RouteProgressProps };
@@ -184,8 +184,9 @@ const selectTriggerVariants = cva([
184
184
  "bg-neutral-50 border-neutral-300",
185
185
  "dark:bg-white/5 dark:border-white/15",
186
186
 
187
- // Typography
188
- "text-sm font-normal font-sans text-foreground",
187
+ // Typography — text-body (16px) per the Figma form-field example: the select
188
+ // sits beside inputs and both are values, so both are body (DS-921).
189
+ "text-body text-foreground",
189
190
 
190
191
  // Text truncation for long content (shadcn default behavior)
191
192
  "[&>span]:block [&>span]:truncate",
@@ -378,7 +379,7 @@ function SelectLabel({
378
379
  return (
379
380
  <SelectPrimitive.Label
380
381
  className={cn(
381
- "text-muted-foreground px-2 py-1.5 text-xs font-medium",
382
+ "text-muted-foreground text-label-sm px-2 py-1.5",
382
383
  className
383
384
  )}
384
385
  data-slot="select-label"
@@ -413,7 +414,7 @@ function SelectItem({
413
414
  "rounded py-1.5 pl-2 pr-8",
414
415
 
415
416
  // Typography
416
- "text-sm font-normal leading-5 text-popover-foreground",
417
+ "text-label text-popover-foreground",
417
418
 
418
419
  // Interactive states
419
420
  "focus:bg-accent focus:text-accent-foreground",
@@ -197,7 +197,7 @@ const SeparatorWithText = React.forwardRef<
197
197
  data-tracking-label={trackingLabel}
198
198
  >
199
199
  <Separator className="flex-1" />
200
- <span className="text-muted-foreground shrink-0 text-sm leading-none font-medium whitespace-nowrap">
200
+ <span className="text-body-sm text-muted-foreground shrink-0 leading-none whitespace-nowrap">
201
201
  {children}
202
202
  </span>
203
203
  <Separator className="flex-1" />