@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.
- package/README.md +9 -2
- package/component-meta.json +4010 -255
- package/deprecations.json +189 -2
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +2 -2
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.js +18 -18
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +11 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +31 -28
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +4 -4
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +15 -11
- package/dist/blocks/empty-state.cjs +1 -0
- package/dist/blocks/empty-state.d.ts +172 -0
- package/dist/blocks/empty-state.d.ts.map +1 -0
- package/dist/blocks/empty-state.js +155 -0
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +124 -108
- package/dist/blocks/progress-state.cjs +1 -0
- package/dist/blocks/progress-state.d.ts +121 -0
- package/dist/blocks/progress-state.d.ts.map +1 -0
- package/dist/blocks/progress-state.js +368 -0
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +297 -296
- 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 +23 -23
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +37 -38
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +24 -2
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +57 -55
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +23 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +94 -91
- package/dist/chart-empty.cjs +1 -0
- package/dist/chart-empty.d.ts +59 -0
- package/dist/chart-empty.d.ts.map +1 -0
- package/dist/chart-empty.js +29 -0
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -1
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +183 -183
- 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 +47 -44
- 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 +143 -141
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +74 -77
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +26 -29
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +182 -13
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +462 -314
- package/dist/description.cjs +1 -1
- package/dist/description.js +5 -5
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +20 -20
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +8 -11
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +17 -20
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +29 -25
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +58 -6
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +278 -194
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +56 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +32 -0
- package/dist/header.d.ts +13 -0
- package/dist/header.d.ts.map +1 -1
- package/dist/hooks/use-delayed-pending.cjs +1 -0
- package/dist/hooks/use-delayed-pending.d.ts +34 -0
- package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
- package/dist/hooks/use-delayed-pending.js +17 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +13 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +523 -494
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +25 -25
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +9 -9
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +9 -9
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +51 -51
- package/dist/input.cjs +1 -1
- package/dist/input.js +9 -9
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +25 -28
- package/dist/lib/block-illustration.cjs +1 -0
- package/dist/lib/block-illustration.d.ts +28 -0
- package/dist/lib/block-illustration.d.ts.map +1 -0
- package/dist/lib/block-illustration.js +21 -0
- package/dist/lib/empty-canvas.cjs +1 -0
- package/dist/lib/empty-canvas.d.ts +27 -0
- package/dist/lib/empty-canvas.d.ts.map +1 -0
- package/dist/lib/empty-canvas.js +62 -0
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +10 -8
- package/dist/lib/optical-center.cjs +1 -0
- package/dist/lib/optical-center.d.ts +12 -0
- package/dist/lib/optical-center.d.ts.map +1 -0
- package/dist/lib/optical-center.js +11 -0
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +28 -5
- 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.d.ts.map +1 -1
- package/dist/list.js +87 -81
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +60 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +187 -164
- package/dist/media-empty.cjs +1 -0
- package/dist/media-empty.d.ts +72 -0
- package/dist/media-empty.d.ts.map +1 -0
- package/dist/media-empty.js +45 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +17 -20
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +7 -7
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +127 -1
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +189 -98
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +37 -3
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +102 -64
- 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/select.cjs +2 -2
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +19 -18
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +8 -8
- 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 +103 -66
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +38 -3
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +43 -20
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +32 -36
- 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 +23 -22
- 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 +36 -29
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-reveal-motion.d.ts +10 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +11 -11
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +8 -8
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +8 -8
- package/dist/typography-heading.cjs +1 -0
- package/dist/typography-heading.d.ts +116 -0
- package/dist/typography-heading.d.ts.map +1 -0
- package/dist/typography-heading.js +84 -0
- package/dist/typography-text.cjs +1 -0
- package/dist/typography-text.d.ts +113 -0
- package/dist/typography-text.d.ts.map +1 -0
- package/dist/typography-text.js +81 -0
- package/dist/typography.d.ts +13 -0
- package/dist/typography.d.ts.map +1 -1
- package/package.json +42 -2
- package/src/blocks/empty-state.tsx +424 -0
- package/src/blocks/input-list.tsx +66 -36
- package/src/blocks/progress-state.tsx +542 -0
- package/src/blocks/sidebar.tsx +46 -40
- package/src/components/accordion.tsx +2 -2
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/alert.tsx +27 -13
- package/src/components/avatar.tsx +1 -1
- package/src/components/badge.tsx +8 -4
- package/src/components/breadcrumb.tsx +9 -4
- package/src/components/button.tsx +5 -8
- package/src/components/calendar.tsx +5 -6
- package/src/components/callout.tsx +48 -15
- package/src/components/card.tsx +52 -17
- package/src/components/chart-empty.tsx +116 -0
- package/src/components/chart.tsx +43 -17
- package/src/components/chip.tsx +9 -6
- package/src/components/combobox.tsx +21 -12
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +6 -9
- package/src/components/data-table.tsx +405 -31
- package/src/components/description.tsx +1 -1
- package/src/components/dialog.tsx +2 -2
- package/src/components/drawer.tsx +2 -5
- package/src/components/dropdown-menu.tsx +8 -11
- package/src/components/field.tsx +8 -4
- package/src/components/global-layout.tsx +264 -65
- package/src/components/grid.tsx +130 -0
- package/src/components/header.tsx +13 -0
- package/src/components/hover-card.tsx +1 -1
- package/src/components/input-chip.tsx +1 -1
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +10 -13
- package/src/components/link.tsx +39 -5
- package/src/components/list.tsx +18 -14
- package/src/components/map.tsx +101 -5
- package/src/components/media-empty.tsx +156 -0
- package/src/components/menubar.tsx +7 -10
- package/src/components/navigation-menu.tsx +1 -1
- package/src/components/pagination.tsx +279 -1
- package/src/components/progress.tsx +120 -11
- package/src/components/route-progress.tsx +354 -0
- package/src/components/select.tsx +5 -4
- package/src/components/separator.tsx +1 -1
- package/src/components/sheet.tsx +89 -7
- package/src/components/skeleton.tsx +78 -7
- package/src/components/sonner.tsx +5 -14
- package/src/components/spinner.tsx +94 -0
- package/src/components/stepper.tsx +6 -7
- package/src/components/table.tsx +11 -4
- package/src/components/tabs.tsx +1 -1
- package/src/components/text-reveal-motion.tsx +10 -0
- package/src/components/textarea.tsx +1 -1
- package/src/components/toggle.tsx +1 -1
- package/src/components/tooltip.tsx +1 -1
- package/src/components/typography-heading.tsx +229 -0
- package/src/components/typography-text.tsx +225 -0
- package/src/components/typography.tsx +13 -0
- package/src/hooks/use-delayed-pending.ts +60 -0
- package/src/index.ts +12 -0
- package/src/lib/block-illustration.tsx +88 -0
- package/src/lib/empty-canvas.tsx +128 -0
- package/src/lib/optical-center.tsx +45 -0
- package/src/lib/utils.ts +26 -0
package/src/components/sheet.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
6
6
|
import { X } from "@brightlocal/icons";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
|
+
import { ScrollArea } from "@brightlocal/ui-components/scroll-area";
|
|
9
10
|
import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -17,6 +18,14 @@ import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-over
|
|
|
17
18
|
*/
|
|
18
19
|
export type SheetSide = "top" | "right" | "bottom" | "left";
|
|
19
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Available sheet size variants (side panels only — ignored for top/bottom)
|
|
23
|
+
* - default: Panel fills 75% of the viewport up to 384px
|
|
24
|
+
* - sm: Panel hugs its content between 288 and 320px, keeping the page
|
|
25
|
+
* partly visible behind it on phones (used by the Sidebar mobile nav)
|
|
26
|
+
*/
|
|
27
|
+
export type SheetSize = "default" | "sm";
|
|
28
|
+
|
|
20
29
|
const sheetContentVariants = cva(
|
|
21
30
|
[
|
|
22
31
|
"bg-background",
|
|
@@ -55,9 +64,7 @@ const sheetContentVariants = cva(
|
|
|
55
64
|
"inset-y-0",
|
|
56
65
|
"right-0",
|
|
57
66
|
"h-full",
|
|
58
|
-
"w-3/4",
|
|
59
67
|
"border-l",
|
|
60
|
-
"sm:max-w-sm",
|
|
61
68
|
],
|
|
62
69
|
bottom: [
|
|
63
70
|
"data-[state=closed]:slide-out-to-bottom",
|
|
@@ -73,14 +80,38 @@ const sheetContentVariants = cva(
|
|
|
73
80
|
"inset-y-0",
|
|
74
81
|
"left-0",
|
|
75
82
|
"h-full",
|
|
76
|
-
"w-3/4",
|
|
77
83
|
"border-r",
|
|
78
|
-
"sm:max-w-sm",
|
|
79
84
|
],
|
|
80
85
|
},
|
|
86
|
+
size: {
|
|
87
|
+
default: [],
|
|
88
|
+
sm: [],
|
|
89
|
+
},
|
|
81
90
|
},
|
|
91
|
+
compoundVariants: [
|
|
92
|
+
// Width only applies to side panels — top/bottom sheets span the
|
|
93
|
+
// viewport and size their height from content on every size.
|
|
94
|
+
{
|
|
95
|
+
side: ["left", "right"],
|
|
96
|
+
size: "default",
|
|
97
|
+
className: ["w-3/4", "sm:max-w-sm"],
|
|
98
|
+
},
|
|
99
|
+
// sm side panels hug their content between 288 and 320px (DS-860) so
|
|
100
|
+
// the page stays partly visible behind them on phones — used by the
|
|
101
|
+
// Sidebar mobile navigation sheet.
|
|
102
|
+
{
|
|
103
|
+
side: ["left", "right"],
|
|
104
|
+
size: "sm",
|
|
105
|
+
className: [
|
|
106
|
+
"w-fit",
|
|
107
|
+
"min-w-(--ds-container-2xs)",
|
|
108
|
+
"max-w-(--ds-container-xs)",
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
82
112
|
defaultVariants: {
|
|
83
113
|
side: "right",
|
|
114
|
+
size: "default",
|
|
84
115
|
},
|
|
85
116
|
}
|
|
86
117
|
);
|
|
@@ -178,6 +209,13 @@ interface SheetContentProps
|
|
|
178
209
|
* @default "right"
|
|
179
210
|
*/
|
|
180
211
|
side?: SheetSide;
|
|
212
|
+
/**
|
|
213
|
+
* Width preset for side panels. `sm` hugs the content between 288 and
|
|
214
|
+
* 320px; `default` keeps the classic 75%-up-to-384px drawer width.
|
|
215
|
+
* Ignored for top/bottom sheets.
|
|
216
|
+
* @default "default"
|
|
217
|
+
*/
|
|
218
|
+
size?: SheetSize;
|
|
181
219
|
/**
|
|
182
220
|
* Data hook for automated testing
|
|
183
221
|
*/
|
|
@@ -210,6 +248,7 @@ const SheetContent = React.forwardRef<
|
|
|
210
248
|
className,
|
|
211
249
|
children,
|
|
212
250
|
side,
|
|
251
|
+
size,
|
|
213
252
|
dataHook,
|
|
214
253
|
trackingEl,
|
|
215
254
|
trackingLabel,
|
|
@@ -226,7 +265,7 @@ const SheetContent = React.forwardRef<
|
|
|
226
265
|
<SheetOverlay />
|
|
227
266
|
<SheetPrimitive.Content
|
|
228
267
|
ref={ref}
|
|
229
|
-
className={cn(sheetContentVariants({ side }), className)}
|
|
268
|
+
className={cn(sheetContentVariants({ side, size }), className)}
|
|
230
269
|
data-hook={dataHook}
|
|
231
270
|
data-slot="sheet-content"
|
|
232
271
|
data-tracking-el={trackingEl}
|
|
@@ -262,6 +301,47 @@ const SheetHeader = React.forwardRef<
|
|
|
262
301
|
));
|
|
263
302
|
SheetHeader.displayName = "SheetHeader";
|
|
264
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Props for the SheetBody component
|
|
306
|
+
*/
|
|
307
|
+
interface SheetBodyProps extends Omit<
|
|
308
|
+
React.ComponentProps<typeof ScrollArea>,
|
|
309
|
+
"dataHook"
|
|
310
|
+
> {
|
|
311
|
+
/**
|
|
312
|
+
* Data hook for automated testing
|
|
313
|
+
* @default "sheet-body"
|
|
314
|
+
*/
|
|
315
|
+
dataHook?: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Sheet body — the scrollable region between a pinned SheetHeader and
|
|
320
|
+
* SheetFooter. Wraps ScrollArea so long content scrolls with DS-styled
|
|
321
|
+
* scrollbars inside a keyboard-focusable viewport, while the close button,
|
|
322
|
+
* header, and footer stay visible.
|
|
323
|
+
*/
|
|
324
|
+
const SheetBody = React.forwardRef<
|
|
325
|
+
React.ComponentRef<typeof ScrollArea>,
|
|
326
|
+
SheetBodyProps
|
|
327
|
+
>(({ className, children, dataHook, ...props }, ref) => (
|
|
328
|
+
<ScrollArea
|
|
329
|
+
ref={ref}
|
|
330
|
+
// -mx-6 escapes SheetContent's p-6 so the scrollbar sits at the panel
|
|
331
|
+
// edge; the inner px-5 plus the viewport's built-in p-1 restores the
|
|
332
|
+
// 24px content inset.
|
|
333
|
+
className={cn("-mx-6 min-h-0 flex-1", className)}
|
|
334
|
+
data-slot="sheet-body"
|
|
335
|
+
dataHook={dataHook ?? "sheet-body"}
|
|
336
|
+
{...props}
|
|
337
|
+
>
|
|
338
|
+
<div className="px-5" data-slot="sheet-body-content">
|
|
339
|
+
{children}
|
|
340
|
+
</div>
|
|
341
|
+
</ScrollArea>
|
|
342
|
+
));
|
|
343
|
+
SheetBody.displayName = "SheetBody";
|
|
344
|
+
|
|
265
345
|
/**
|
|
266
346
|
* Sheet footer section for actions and buttons.
|
|
267
347
|
* Stacks buttons on mobile, aligns to end on larger screens.
|
|
@@ -312,7 +392,7 @@ const SheetTitle = React.forwardRef<
|
|
|
312
392
|
<SheetPrimitive.Title
|
|
313
393
|
ref={ref}
|
|
314
394
|
className={cn(
|
|
315
|
-
"text-foreground text-
|
|
395
|
+
"text-foreground text-heading-section",
|
|
316
396
|
icon && "flex items-center gap-2",
|
|
317
397
|
className
|
|
318
398
|
)}
|
|
@@ -353,7 +433,7 @@ const SheetDescription = React.forwardRef<
|
|
|
353
433
|
>(({ className, dataHook, ...props }, ref) => (
|
|
354
434
|
<SheetPrimitive.Description
|
|
355
435
|
ref={ref}
|
|
356
|
-
className={cn("text-
|
|
436
|
+
className={cn("text-body-sm text-muted-foreground", className)}
|
|
357
437
|
data-hook={dataHook}
|
|
358
438
|
data-slot="sheet-description"
|
|
359
439
|
{...props}
|
|
@@ -363,6 +443,7 @@ SheetDescription.displayName = "SheetDescription";
|
|
|
363
443
|
|
|
364
444
|
export {
|
|
365
445
|
Sheet,
|
|
446
|
+
SheetBody,
|
|
366
447
|
SheetClose,
|
|
367
448
|
SheetContent,
|
|
368
449
|
SheetDescription,
|
|
@@ -375,6 +456,7 @@ export {
|
|
|
375
456
|
};
|
|
376
457
|
|
|
377
458
|
export type {
|
|
459
|
+
SheetBodyProps,
|
|
378
460
|
SheetContentProps,
|
|
379
461
|
SheetDescriptionProps,
|
|
380
462
|
SheetTitleProps,
|
|
@@ -5,7 +5,29 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
5
5
|
/**
|
|
6
6
|
* Props for the Skeleton component
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Entry delay for the skeleton's appearance. `false` (default) shows it
|
|
10
|
+
* immediately; "short" holds it back 300ms (the flash zone's upper edge —
|
|
11
|
+
* waits that resolve first never show it); "long" holds it 1000ms for
|
|
12
|
+
* below-the-fold or secondary surfaces; a number sets a measured per-surface
|
|
13
|
+
* value in milliseconds. The delayed skeleton still reserves its geometry —
|
|
14
|
+
* it is invisible, not unmounted.
|
|
15
|
+
*/
|
|
16
|
+
type SkeletonDelay = "short" | "long" | number | false;
|
|
17
|
+
|
|
18
|
+
const SKELETON_DELAY_MS: Record<"short" | "long", number> = {
|
|
19
|
+
short: 300,
|
|
20
|
+
long: 1000,
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
24
|
+
/**
|
|
25
|
+
* Delay before the skeleton becomes visible: `"short"` (300ms),
|
|
26
|
+
* `"long"` (1000ms), or a number of milliseconds. It keeps reserving its
|
|
27
|
+
* space while invisible.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
delay?: SkeletonDelay;
|
|
9
31
|
/**
|
|
10
32
|
* Data hook for automated testing (optional for Skeleton as it's purely presentational)
|
|
11
33
|
*/
|
|
@@ -20,33 +42,82 @@ interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
|
20
42
|
trackingLabel?: string;
|
|
21
43
|
/**
|
|
22
44
|
* Accessible label announced to screen readers during loading.
|
|
23
|
-
*
|
|
45
|
+
*
|
|
46
|
+
* Unset (the default) the skeleton is silent: `aria-hidden`, with no
|
|
47
|
+
* screen-reader text. A loading layout is many skeletons — a table page is
|
|
48
|
+
* a dozen rows of four — and one announcement per shape is the whole wait
|
|
49
|
+
* read out dozens of times. The region being loaded carries `aria-busy` and
|
|
50
|
+
* makes the single announcement instead.
|
|
51
|
+
*
|
|
52
|
+
* Pass it only for a skeleton that stands alone, where there is no owning
|
|
53
|
+
* region to do the announcing.
|
|
24
54
|
*/
|
|
25
55
|
loadingLabel?: string;
|
|
26
56
|
}
|
|
27
57
|
|
|
28
58
|
/**
|
|
29
59
|
* Skeleton component for loading placeholder states.
|
|
30
|
-
* Displays a
|
|
60
|
+
* Displays a travelling shimmer wave — one soft color wave (skeleton base to
|
|
61
|
+
* a lighter peak) moving left to right through every skeleton shape in the
|
|
62
|
+
* view, so composed layouts light up in position order with no per-shape
|
|
63
|
+
* setup. The skeleton appears instantly at full strength — deliberately no
|
|
64
|
+
* fade-in — and the wave animates color only, never the shape's opacity.
|
|
31
65
|
* Use to represent text, images, avatars, or any other content while data is being fetched.
|
|
66
|
+
*
|
|
67
|
+
* Appears instantly at full strength — deliberately no fade-in: a skeleton
|
|
68
|
+
* is the page assembling, not a transition worth softening. Flicker on fast
|
|
69
|
+
* responses is prevented by not showing the skeleton at all (the `delay`
|
|
70
|
+
* prop, or `useDelayedPending`), never by easing it in. The exit is equally
|
|
71
|
+
* instant: unmounting is immediate, and fading a skeleton out over readable
|
|
72
|
+
* content is banned (a minimum display time by another name).
|
|
32
73
|
*/
|
|
33
74
|
const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
|
|
34
75
|
(
|
|
35
|
-
{
|
|
76
|
+
{
|
|
77
|
+
className,
|
|
78
|
+
dataHook,
|
|
79
|
+
delay = false,
|
|
80
|
+
style,
|
|
81
|
+
trackingEl,
|
|
82
|
+
trackingLabel,
|
|
83
|
+
loadingLabel,
|
|
84
|
+
...props
|
|
85
|
+
},
|
|
36
86
|
ref
|
|
37
87
|
) => {
|
|
88
|
+
const delayMs =
|
|
89
|
+
delay === false
|
|
90
|
+
? 0
|
|
91
|
+
: typeof delay === "number"
|
|
92
|
+
? delay
|
|
93
|
+
: SKELETON_DELAY_MS[delay];
|
|
94
|
+
/* Announce only when the caller asked for it by name. Silence is the
|
|
95
|
+
default because a skeleton is scaffolding, not information. */
|
|
96
|
+
const announces = loadingLabel !== undefined;
|
|
38
97
|
return (
|
|
39
98
|
<div
|
|
40
99
|
ref={ref}
|
|
41
|
-
aria-busy="true"
|
|
42
|
-
|
|
100
|
+
aria-busy={announces ? "true" : undefined}
|
|
101
|
+
aria-hidden={announces ? undefined : "true"}
|
|
102
|
+
className={cn(
|
|
103
|
+
"bg-skeleton animate-status-shimmer relative rounded-md",
|
|
104
|
+
className
|
|
105
|
+
)}
|
|
43
106
|
data-hook={dataHook}
|
|
44
107
|
data-slot="skeleton"
|
|
45
108
|
data-tracking-el={trackingEl}
|
|
46
109
|
data-tracking-label={trackingLabel}
|
|
110
|
+
style={
|
|
111
|
+
delayMs
|
|
112
|
+
? ({
|
|
113
|
+
"--skeleton-delay": `${delayMs}ms`,
|
|
114
|
+
...style,
|
|
115
|
+
} as React.CSSProperties)
|
|
116
|
+
: style
|
|
117
|
+
}
|
|
47
118
|
{...props}
|
|
48
119
|
>
|
|
49
|
-
<span className="sr-only">{loadingLabel
|
|
120
|
+
{announces ? <span className="sr-only">{loadingLabel}</span> : null}
|
|
50
121
|
</div>
|
|
51
122
|
);
|
|
52
123
|
}
|
|
@@ -55,4 +126,4 @@ Skeleton.displayName = "Skeleton";
|
|
|
55
126
|
|
|
56
127
|
export { Skeleton };
|
|
57
128
|
|
|
58
|
-
export type { SkeletonProps };
|
|
129
|
+
export type { SkeletonDelay, SkeletonProps };
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
AlertTriangle,
|
|
5
|
-
CheckCircle2,
|
|
6
|
-
Info,
|
|
7
|
-
Loader2,
|
|
8
|
-
XCircle,
|
|
9
|
-
} from "@brightlocal/icons";
|
|
3
|
+
import { AlertTriangle, CheckCircle2, Info, XCircle } from "@brightlocal/icons";
|
|
10
4
|
import { cva } from "class-variance-authority";
|
|
11
5
|
import { toast as sonnerToast, Toaster as SonnerToaster } from "sonner";
|
|
12
6
|
|
|
13
7
|
import { Button, type ButtonVariant } from "@brightlocal/ui-components/button";
|
|
14
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
|
+
import { Spinner } from "@brightlocal/ui-components/spinner";
|
|
15
10
|
|
|
16
11
|
/**
|
|
17
12
|
* Supported button variant values for toast action buttons.
|
|
@@ -102,7 +97,7 @@ const CONTAINER_VARIANTS = cva(
|
|
|
102
97
|
}
|
|
103
98
|
);
|
|
104
99
|
|
|
105
|
-
const TITLE_VARIANTS = cva("text-
|
|
100
|
+
const TITLE_VARIANTS = cva("text-heading-compact", {
|
|
106
101
|
variants: {
|
|
107
102
|
colorSchema: {
|
|
108
103
|
default: "text-foreground",
|
|
@@ -114,7 +109,7 @@ const TITLE_VARIANTS = cva("text-sm leading-normal font-medium", {
|
|
|
114
109
|
},
|
|
115
110
|
});
|
|
116
111
|
|
|
117
|
-
const DESCRIPTION_VARIANTS = cva("text-sm
|
|
112
|
+
const DESCRIPTION_VARIANTS = cva("text-body-sm", {
|
|
118
113
|
variants: {
|
|
119
114
|
colorSchema: {
|
|
120
115
|
default: "text-muted-foreground",
|
|
@@ -161,11 +156,7 @@ function renderToastIcon(type: ToastIconType, schema: "default" | "success") {
|
|
|
161
156
|
case "error":
|
|
162
157
|
return <XCircle className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
163
158
|
case "loading":
|
|
164
|
-
return (
|
|
165
|
-
<Loader2
|
|
166
|
-
className={cn(ICON_VARIANTS({ colorSchema: schema }), "animate-spin")}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
159
|
+
return <Spinner className={cn(ICON_VARIANTS({ colorSchema: schema }))} />;
|
|
169
160
|
default:
|
|
170
161
|
return null;
|
|
171
162
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { LoaderCircle } from "@brightlocal/icons";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Spinner size scale — three sizes, one shared speed.
|
|
9
|
+
* sm 14 (chips, table cells, nav items) · md 16 (buttons, inputs — the
|
|
10
|
+
* default) · lg 20 (standing alone in a region).
|
|
11
|
+
*/
|
|
12
|
+
const SPINNER_SIZES = { sm: 14, md: 16, lg: 20 } as const;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Spinner size options
|
|
16
|
+
*/
|
|
17
|
+
type SpinnerSize = keyof typeof SPINNER_SIZES;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Props for the Spinner component
|
|
21
|
+
*/
|
|
22
|
+
interface SpinnerProps extends Omit<
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof LoaderCircle>,
|
|
24
|
+
"size"
|
|
25
|
+
> {
|
|
26
|
+
/**
|
|
27
|
+
* Data hook for automated testing (optional for Spinner as it's purely presentational)
|
|
28
|
+
*/
|
|
29
|
+
dataHook?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Tracking element identifier for analytics
|
|
32
|
+
*/
|
|
33
|
+
trackingEl?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Tracking label for analytics context
|
|
36
|
+
*/
|
|
37
|
+
trackingLabel?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Spinner size: sm 14 (chips, cells, nav items), md 16, lg 20 (standing alone).
|
|
40
|
+
* @default "md"
|
|
41
|
+
*/
|
|
42
|
+
size?: SpinnerSize;
|
|
43
|
+
/**
|
|
44
|
+
* Accessible label announced to screen readers (`role="status"`).
|
|
45
|
+
* When omitted the spinner is decorative (`aria-hidden`) — omit inside a
|
|
46
|
+
* control that already announces busy (e.g. a Button with `aria-busy`).
|
|
47
|
+
* @default undefined
|
|
48
|
+
* @example "Loading"
|
|
49
|
+
*/
|
|
50
|
+
loadingLabel?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Spinner — the one indeterminate loading indicator.
|
|
55
|
+
* Renders the LoaderCircle glyph rotating at the shared
|
|
56
|
+
* `--ds-motion-spinner-duration` speed, so every spinner in a view moves at
|
|
57
|
+
* the same rate. Size varies by context; speed never does.
|
|
58
|
+
* Color follows `currentColor` — set it from the surrounding text color.
|
|
59
|
+
*/
|
|
60
|
+
const Spinner = React.forwardRef<SVGSVGElement, SpinnerProps>(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
className,
|
|
64
|
+
size = "md",
|
|
65
|
+
loadingLabel,
|
|
66
|
+
dataHook,
|
|
67
|
+
trackingEl,
|
|
68
|
+
trackingLabel,
|
|
69
|
+
...props
|
|
70
|
+
},
|
|
71
|
+
ref
|
|
72
|
+
) => {
|
|
73
|
+
return (
|
|
74
|
+
<LoaderCircle
|
|
75
|
+
ref={ref}
|
|
76
|
+
aria-hidden={loadingLabel ? undefined : true}
|
|
77
|
+
aria-label={loadingLabel}
|
|
78
|
+
className={cn("animate-spinner", className)}
|
|
79
|
+
data-hook={dataHook}
|
|
80
|
+
data-slot="spinner"
|
|
81
|
+
data-tracking-el={trackingEl}
|
|
82
|
+
data-tracking-label={trackingLabel}
|
|
83
|
+
role={loadingLabel ? "status" : undefined}
|
|
84
|
+
size={SPINNER_SIZES[size]}
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
Spinner.displayName = "Spinner";
|
|
91
|
+
|
|
92
|
+
export { Spinner, SPINNER_SIZES };
|
|
93
|
+
|
|
94
|
+
export type { SpinnerProps, SpinnerSize };
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
5
|
import { cva } from "class-variance-authority";
|
|
6
|
-
import { Check,
|
|
6
|
+
import { Check, X } from "@brightlocal/icons";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
|
+
import { Spinner } from "@brightlocal/ui-components/spinner";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Orientation of the stepper layout.
|
|
@@ -445,7 +446,7 @@ StepperTrigger.displayName = "StepperTrigger";
|
|
|
445
446
|
|
|
446
447
|
const stepperIndicatorStyles = cva(
|
|
447
448
|
[
|
|
448
|
-
"relative flex size-8 shrink-0 items-center justify-center rounded-full text-
|
|
449
|
+
"relative flex size-8 shrink-0 items-center justify-center rounded-full text-label-sm",
|
|
449
450
|
"transition-colors duration-fast ease-out",
|
|
450
451
|
// Hover overlay (only visible when wrapped by an interactive trigger).
|
|
451
452
|
"after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:bg-white/10 after:opacity-0 after:transition-opacity after:duration-fast after:ease-out",
|
|
@@ -565,9 +566,7 @@ const StepperIndicator = React.forwardRef<
|
|
|
565
566
|
{state === "error" && !isLoading && (
|
|
566
567
|
<X className="absolute" size={16} />
|
|
567
568
|
)}
|
|
568
|
-
{isLoading &&
|
|
569
|
-
<LoaderCircle className="absolute animate-spin" size={16} />
|
|
570
|
-
)}
|
|
569
|
+
{isLoading && <Spinner className="absolute" size="md" />}
|
|
571
570
|
{stateLabel}
|
|
572
571
|
</>
|
|
573
572
|
)}
|
|
@@ -669,7 +668,7 @@ const StepperTitle = React.forwardRef<
|
|
|
669
668
|
<span
|
|
670
669
|
ref={ref}
|
|
671
670
|
className={cn(
|
|
672
|
-
"text-foreground text-
|
|
671
|
+
"text-foreground text-heading-compact",
|
|
673
672
|
"group-data-[state=inactive]/step:text-muted-foreground",
|
|
674
673
|
"group-data-[disabled=true]/step:text-muted-foreground",
|
|
675
674
|
className
|
|
@@ -689,7 +688,7 @@ const StepperDescription = React.forwardRef<
|
|
|
689
688
|
>(({ className, ...props }, ref) => (
|
|
690
689
|
<span
|
|
691
690
|
ref={ref}
|
|
692
|
-
className={cn("text-muted-foreground text-xs
|
|
691
|
+
className={cn("text-muted-foreground text-body-xs", className)}
|
|
693
692
|
data-slot="stepper-description"
|
|
694
693
|
{...props}
|
|
695
694
|
/>
|
package/src/components/table.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
10
10
|
* -----------------------------------------------------------------------------------------------*/
|
|
11
11
|
|
|
12
12
|
const tableCellVariants = cva(
|
|
13
|
-
"align-middle bg-transparent text-
|
|
13
|
+
"align-middle bg-transparent text-body-sm text-foreground break-words",
|
|
14
14
|
{
|
|
15
15
|
variants: {
|
|
16
16
|
size: {
|
|
@@ -32,7 +32,9 @@ const tableCellVariants = cva(
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const tableHeadVariants = cva(
|
|
35
|
-
|
|
35
|
+
// bg-muted only for column headers inside <thead> — a <TableHead
|
|
36
|
+
// scope="row"> in the body must not paint over its row's state tint.
|
|
37
|
+
"[thead_&]:bg-muted h-12 p-2 align-middle text-muted-foreground text-label font-semibold break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-fast ease-out",
|
|
36
38
|
{
|
|
37
39
|
variants: {
|
|
38
40
|
align: {
|
|
@@ -124,7 +126,10 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
|
124
126
|
<table
|
|
125
127
|
ref={ref}
|
|
126
128
|
className={cn(
|
|
127
|
-
|
|
129
|
+
// tabular-nums inherits into every cell (and into DataTable, which
|
|
130
|
+
// renders this root), so numeric columns align by default; a
|
|
131
|
+
// prose-heavy column can opt out with proportional-nums.
|
|
132
|
+
"text-body-sm w-full caption-bottom tabular-nums",
|
|
128
133
|
layout === "fixed" && "table-fixed",
|
|
129
134
|
className
|
|
130
135
|
)}
|
|
@@ -233,7 +238,9 @@ const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
|
233
238
|
<tr
|
|
234
239
|
ref={ref}
|
|
235
240
|
className={cn(
|
|
236
|
-
|
|
241
|
+
// Selected rows share the table head's surface (bg-muted).
|
|
242
|
+
"data-[state=selected]:bg-muted",
|
|
243
|
+
"duration-fast transition-colors ease-out",
|
|
237
244
|
className
|
|
238
245
|
)}
|
|
239
246
|
data-hook={dataHook}
|
package/src/components/tabs.tsx
CHANGED
|
@@ -199,7 +199,7 @@ function TabsTriggerInner<T extends string = string>(
|
|
|
199
199
|
// Layout
|
|
200
200
|
"inline-flex items-center justify-center gap-2 px-2 py-1",
|
|
201
201
|
// Typography
|
|
202
|
-
"text-
|
|
202
|
+
"text-label whitespace-nowrap",
|
|
203
203
|
// Border radius
|
|
204
204
|
"rounded-md",
|
|
205
205
|
// Border
|
|
@@ -139,6 +139,11 @@ function rafDelay(ms: number, signal: { cancelled: boolean }): Promise<void> {
|
|
|
139
139
|
* <TypographyP dataHook="w2">Processing</TypographyP>
|
|
140
140
|
* </TextRevealMotion>
|
|
141
141
|
* ```
|
|
142
|
+
*
|
|
143
|
+
* @deprecated Removal planned once product usage is gone (DS-907). Cycling
|
|
144
|
+
* phrases on a timer violates the Loading pattern's Honesty principle — the
|
|
145
|
+
* phrases are not stages the backend reported. Use a section skeleton, or a
|
|
146
|
+
* named-stages running screen driven by real stage data (Patterns / Loading).
|
|
142
147
|
*/
|
|
143
148
|
export interface TextRevealMotionProps extends Omit<
|
|
144
149
|
React.ComponentPropsWithoutRef<"div">,
|
|
@@ -205,6 +210,11 @@ export interface TextRevealMotionProps extends Omit<
|
|
|
205
210
|
* The ball rolls across each child, revealing it via clip-path, holds,
|
|
206
211
|
* then rolls back and cycles to the next child. Supports any Typography
|
|
207
212
|
* component as children.
|
|
213
|
+
*
|
|
214
|
+
* @deprecated Removal planned once product usage is gone (DS-907). Cycling
|
|
215
|
+
* phrases on a timer violates the Loading pattern's Honesty principle — the
|
|
216
|
+
* phrases are not stages the backend reported. Use a section skeleton, or a
|
|
217
|
+
* named-stages running screen driven by real stage data (Patterns / Loading).
|
|
208
218
|
*/
|
|
209
219
|
const TextRevealMotion = React.forwardRef<
|
|
210
220
|
HTMLDivElement,
|
|
@@ -10,7 +10,7 @@ const textareaVariants = cva([
|
|
|
10
10
|
"border border-input bg-background rounded-md",
|
|
11
11
|
"outline-none transition-[border-color,background-color,box-shadow] duration-fast ease-out",
|
|
12
12
|
// Typography
|
|
13
|
-
"text-
|
|
13
|
+
"text-body",
|
|
14
14
|
"text-foreground",
|
|
15
15
|
// Spacing
|
|
16
16
|
"px-3 py-2",
|
|
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-
|
|
10
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-label hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-fast ease-out whitespace-nowrap",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
@@ -153,7 +153,7 @@ const TooltipContent = React.forwardRef<
|
|
|
153
153
|
<TooltipPrimitive.Content
|
|
154
154
|
ref={ref}
|
|
155
155
|
className={cn(
|
|
156
|
-
"bg-secondary text-secondary-foreground z-50 w-max max-w-sm rounded-md px-3 py-1.5
|
|
156
|
+
"bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",
|
|
157
157
|
FLOATING_CONTENT_ANIMATION,
|
|
158
158
|
"**:data-[slot=tooltip-arrow]:-translate-y-px",
|
|
159
159
|
className
|