@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.
- package/README.md +4 -2
- package/component-meta.json +3761 -360
- package/dist/blocks/progress-screen.cjs +1 -0
- package/dist/blocks/progress-screen.d.ts +109 -0
- package/dist/blocks/progress-screen.d.ts.map +1 -0
- package/dist/blocks/progress-screen.js +339 -0
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +155 -153
- package/dist/brand-illustration-motif.d.ts +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +44 -40
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +28 -28
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +1 -1
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +42 -41
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +4 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +161 -161
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +138 -3
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +455 -309
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +31 -5
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +276 -194
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +462 -451
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +10 -8
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +8 -6
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +52 -20
- package/dist/list.cjs +1 -1
- package/dist/list.js +65 -63
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +61 -3
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +142 -65
- package/dist/route-progress.cjs +1 -0
- package/dist/route-progress.d.ts +103 -0
- package/dist/route-progress.d.ts.map +1 -0
- package/dist/route-progress.js +106 -0
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +35 -2
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +102 -65
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +11 -15
- package/dist/spinner.cjs +1 -0
- package/dist/spinner.d.ts +57 -0
- package/dist/spinner.d.ts.map +1 -0
- package/dist/spinner.js +35 -0
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.d.ts.map +1 -1
- package/dist/stepper.js +26 -25
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +6 -2
- package/package.json +14 -2
- package/src/blocks/progress-screen.tsx +481 -0
- package/src/blocks/sidebar.tsx +22 -15
- package/src/components/breadcrumb.tsx +9 -4
- package/src/components/button.tsx +2 -5
- package/src/components/chip.tsx +4 -3
- package/src/components/combobox.tsx +15 -8
- package/src/components/data-table.tsx +333 -14
- package/src/components/global-layout.tsx +228 -62
- package/src/components/link.tsx +39 -5
- package/src/components/list.tsx +5 -5
- package/src/components/progress.tsx +217 -30
- package/src/components/route-progress.tsx +354 -0
- package/src/components/sheet.tsx +87 -5
- package/src/components/sonner.tsx +3 -12
- package/src/components/spinner.tsx +94 -0
- package/src/components/stepper.tsx +3 -4
- package/src/components/table.tsx +6 -2
- 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
|
-
*
|
|
23
|
-
*
|
|
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
|
|
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
|
|
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 && !
|
|
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
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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 && !
|
|
332
|
+
if (!hasVisibleLabel && !showsValue && !hasStatus) {
|
|
206
333
|
return progressBar;
|
|
207
334
|
}
|
|
208
335
|
|
|
209
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
368
|
+
{showsValue && (
|
|
228
369
|
<span
|
|
229
|
-
className=
|
|
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
|
-
{
|
|
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 };
|