@brightlocal/ui-components 2.27.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 +6 -1
- package/component-meta.json +480 -126
- 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-screen.d.ts → progress-state.d.ts} +30 -18
- package/dist/blocks/progress-state.d.ts.map +1 -0
- package/dist/blocks/{progress-screen.js → progress-state.js} +100 -71
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +160 -161
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +11 -11
- 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.map +1 -1
- package/dist/chip.js +5 -3
- package/dist/combobox.cjs +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +81 -79
- 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 +44 -10
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +13 -11
- 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 +27 -1
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +18 -16
- 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 +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +512 -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/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/list.cjs +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -58
- 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 +2 -26
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +79 -118
- 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.js +2 -2
- 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.js +26 -26
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +40 -40
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +31 -28
- 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 +35 -7
- package/src/blocks/empty-state.tsx +424 -0
- package/src/blocks/input-list.tsx +66 -36
- package/src/blocks/{progress-screen.tsx → progress-state.tsx} +154 -93
- package/src/blocks/sidebar.tsx +25 -26
- 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 +1 -1
- package/src/components/button.tsx +3 -3
- 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 +5 -3
- package/src/components/combobox.tsx +12 -10
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +6 -9
- package/src/components/data-table.tsx +72 -17
- 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 +36 -3
- 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/list.tsx +13 -9
- 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 +35 -113
- package/src/components/select.tsx +5 -4
- package/src/components/separator.tsx +1 -1
- package/src/components/sheet.tsx +2 -2
- package/src/components/skeleton.tsx +78 -7
- package/src/components/sonner.tsx +2 -2
- package/src/components/stepper.tsx +3 -3
- package/src/components/table.tsx +6 -3
- 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 +10 -1
- 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/dist/blocks/progress-screen.cjs +0 -1
- package/dist/blocks/progress-screen.d.ts.map +0 -1
|
@@ -139,7 +139,7 @@ const NavigationMenuTrigger = React.forwardRef<
|
|
|
139
139
|
[
|
|
140
140
|
"group inline-flex h-9 w-max items-center justify-center gap-1",
|
|
141
141
|
"rounded-md px-4 py-2",
|
|
142
|
-
"text-
|
|
142
|
+
"text-label",
|
|
143
143
|
"text-foreground",
|
|
144
144
|
"duration-fast transition-colors ease-out",
|
|
145
145
|
"hover:bg-accent hover:text-accent-foreground",
|
|
@@ -99,7 +99,7 @@ const paginationItemVariants = cva(
|
|
|
99
99
|
"inline-flex items-center justify-center",
|
|
100
100
|
"h-9 w-9",
|
|
101
101
|
"rounded-full",
|
|
102
|
-
"text-
|
|
102
|
+
"text-label",
|
|
103
103
|
"transition-colors duration-fast ease-out",
|
|
104
104
|
"focus-visible:outline-none focus-visible:shadow-default",
|
|
105
105
|
],
|
|
@@ -351,17 +351,295 @@ function PaginationEllipsis({
|
|
|
351
351
|
);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Numbers a `PaginationControls` caption is built from. Passed to
|
|
356
|
+
* `renderCaption` so the consumer owns wording, order and pluralization.
|
|
357
|
+
*/
|
|
358
|
+
interface PaginationCaptionInfo {
|
|
359
|
+
/**
|
|
360
|
+
* Current page (1-based), clamped to the last page the totals allow — so it
|
|
361
|
+
* can differ from the `page` prop for the render in which an async total
|
|
362
|
+
* shrinks under an out-of-range page.
|
|
363
|
+
*/
|
|
364
|
+
page: number;
|
|
365
|
+
/** Total number of pages, exactly as passed. */
|
|
366
|
+
totalPages: number;
|
|
367
|
+
/** First item shown on this page (1-based, 0 when there are no items). */
|
|
368
|
+
from: number;
|
|
369
|
+
/** Last item shown on this page. Never less than `from`. */
|
|
370
|
+
to: number;
|
|
371
|
+
/** Total items across all pages. */
|
|
372
|
+
total: number;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
interface PaginationControlsProps extends Omit<
|
|
376
|
+
React.ComponentProps<"div">,
|
|
377
|
+
"children" | "onChange"
|
|
378
|
+
> {
|
|
379
|
+
/** Current page (1-based). Controlled — the consumer owns the value. */
|
|
380
|
+
page: number;
|
|
381
|
+
/** Total number of pages. */
|
|
382
|
+
totalPages: number;
|
|
383
|
+
/**
|
|
384
|
+
* Called with the requested page (1-based) when the user picks a page or
|
|
385
|
+
* steps with previous/next. Never called outside `1..totalPages`.
|
|
386
|
+
*/
|
|
387
|
+
onPageChange: (page: number) => void;
|
|
388
|
+
/** Data hook for automated testing (REQUIRED). The nav gets `{dataHook}-nav`. */
|
|
389
|
+
dataHook: string;
|
|
390
|
+
/**
|
|
391
|
+
* Total items across all pages. Provide together with `pageSize` to render
|
|
392
|
+
* the results caption; without both, no caption renders.
|
|
393
|
+
*/
|
|
394
|
+
totalItems?: number;
|
|
395
|
+
/**
|
|
396
|
+
* Items per page. Only used to derive the caption's `from`/`to`; must be a
|
|
397
|
+
* positive number, or no caption renders.
|
|
398
|
+
*/
|
|
399
|
+
pageSize?: number;
|
|
400
|
+
/**
|
|
401
|
+
* Render the results caption. Receives the derived numbers; you own wording,
|
|
402
|
+
* order and pluralization. Return `null` to hide it.
|
|
403
|
+
* @default Renders "Showing {from} to {to} of {total} results", or nothing when `total` is 0.
|
|
404
|
+
*/
|
|
405
|
+
renderCaption?: ((info: PaginationCaptionInfo) => React.ReactNode) | null;
|
|
406
|
+
/**
|
|
407
|
+
* Accessible label for the pagination navigation.
|
|
408
|
+
* @default "Pagination"
|
|
409
|
+
*/
|
|
410
|
+
ariaLabel?: string;
|
|
411
|
+
/**
|
|
412
|
+
* Accessible label for the previous-page button.
|
|
413
|
+
* @default "Go to previous page"
|
|
414
|
+
*/
|
|
415
|
+
prevAriaLabel?: string;
|
|
416
|
+
/**
|
|
417
|
+
* Accessible label for the next-page button.
|
|
418
|
+
* @default "Go to next page"
|
|
419
|
+
*/
|
|
420
|
+
nextAriaLabel?: string;
|
|
421
|
+
/**
|
|
422
|
+
* Accessible label for a page button.
|
|
423
|
+
* Supports `{page}` placeholder for interpolation.
|
|
424
|
+
* @default "Go to page {page}"
|
|
425
|
+
*/
|
|
426
|
+
pageAriaLabel?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Screen-reader-only label for the ellipsis.
|
|
429
|
+
* @default "More pages"
|
|
430
|
+
*/
|
|
431
|
+
ellipsisSrLabel?: string;
|
|
432
|
+
/** Tracking element identifier for analytics. */
|
|
433
|
+
trackingEl?: string;
|
|
434
|
+
/** Tracking label for analytics context. */
|
|
435
|
+
trackingLabel?: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Pagination with the previous/next/ellipsis/page-link wiring done for you —
|
|
440
|
+
* the composed counterpart to the primitives below.
|
|
441
|
+
*
|
|
442
|
+
* Controlled: the consumer holds `page` and updates it from `onPageChange`.
|
|
443
|
+
* Pass `totalItems` + `pageSize` to get the results caption; the caption sits
|
|
444
|
+
* on the left with the nav pushed right, and without one the nav centres.
|
|
445
|
+
*
|
|
446
|
+
* There is nothing to navigate on a single page, so the nav hides itself at
|
|
447
|
+
* `totalPages <= 1` and the component renders nothing at all when the caption
|
|
448
|
+
* is empty too (same rule as `DataTablePagination`, DS-900).
|
|
449
|
+
*
|
|
450
|
+
* Reach for the primitives (`Pagination`, `PaginationContent`,
|
|
451
|
+
* `PaginationItem`, …) plus `usePagination` only when you need a layout or an
|
|
452
|
+
* item set this doesn't cover. Inside a `DataTable`, use `DataTablePagination`
|
|
453
|
+
* instead so pagination stays in sync with sorting and filtering.
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* const [page, setPage] = React.useState(1);
|
|
457
|
+
*
|
|
458
|
+
* <PaginationControls
|
|
459
|
+
* dataHook="results-pagination"
|
|
460
|
+
* page={page}
|
|
461
|
+
* pageSize={10}
|
|
462
|
+
* totalItems={30}
|
|
463
|
+
* totalPages={3}
|
|
464
|
+
* onPageChange={setPage}
|
|
465
|
+
* />
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* // Localised caption and labels
|
|
469
|
+
* <PaginationControls
|
|
470
|
+
* ariaLabel={t("pagination.nav")}
|
|
471
|
+
* dataHook="results-pagination"
|
|
472
|
+
* nextAriaLabel={t("pagination.next")}
|
|
473
|
+
* page={page}
|
|
474
|
+
* pageSize={10}
|
|
475
|
+
* prevAriaLabel={t("pagination.prev")}
|
|
476
|
+
* renderCaption={({ from, to, total }) =>
|
|
477
|
+
* t("pagination.caption", { from, to, total })
|
|
478
|
+
* }
|
|
479
|
+
* totalItems={30}
|
|
480
|
+
* totalPages={3}
|
|
481
|
+
* onPageChange={setPage}
|
|
482
|
+
* />
|
|
483
|
+
*/
|
|
484
|
+
const PaginationControls = React.forwardRef<
|
|
485
|
+
HTMLDivElement,
|
|
486
|
+
PaginationControlsProps
|
|
487
|
+
>(
|
|
488
|
+
(
|
|
489
|
+
{
|
|
490
|
+
className,
|
|
491
|
+
page,
|
|
492
|
+
totalPages,
|
|
493
|
+
onPageChange,
|
|
494
|
+
dataHook,
|
|
495
|
+
totalItems,
|
|
496
|
+
pageSize,
|
|
497
|
+
renderCaption,
|
|
498
|
+
ariaLabel,
|
|
499
|
+
prevAriaLabel,
|
|
500
|
+
nextAriaLabel,
|
|
501
|
+
pageAriaLabel,
|
|
502
|
+
ellipsisSrLabel,
|
|
503
|
+
trackingEl,
|
|
504
|
+
trackingLabel,
|
|
505
|
+
...props
|
|
506
|
+
},
|
|
507
|
+
ref
|
|
508
|
+
) => {
|
|
509
|
+
const items = usePagination({ page, totalPages });
|
|
510
|
+
|
|
511
|
+
const caption = (() => {
|
|
512
|
+
if (renderCaption === null) return null;
|
|
513
|
+
if (totalItems === undefined || pageSize === undefined) return null;
|
|
514
|
+
// A page size that isn't a positive number, or a negative total, can only
|
|
515
|
+
// produce a nonsense range ("Showing 1 to 0 …", or NaN from a failed
|
|
516
|
+
// parse), so the caption is dropped rather than rendered wrong.
|
|
517
|
+
if (!Number.isFinite(pageSize) || pageSize <= 0) return null;
|
|
518
|
+
if (!Number.isFinite(totalItems) || totalItems < 0) return null;
|
|
519
|
+
|
|
520
|
+
// `page` is the consumer's controlled value, so it can sit out of range
|
|
521
|
+
// for a render while an async total shrinks underneath it (a filter
|
|
522
|
+
// applied while on page 4 of 10). Clamp to what the totals allow, or the
|
|
523
|
+
// caption reads "Showing 31 to 5 of 5 results".
|
|
524
|
+
const lastPage = Math.max(1, Math.ceil(totalItems / pageSize));
|
|
525
|
+
const safePage = Math.min(Math.max(1, Math.floor(page) || 1), lastPage);
|
|
526
|
+
|
|
527
|
+
const from = totalItems === 0 ? 0 : (safePage - 1) * pageSize + 1;
|
|
528
|
+
const to = Math.min(safePage * pageSize, totalItems);
|
|
529
|
+
|
|
530
|
+
if (renderCaption) {
|
|
531
|
+
return renderCaption({
|
|
532
|
+
page: safePage,
|
|
533
|
+
totalPages,
|
|
534
|
+
from,
|
|
535
|
+
to,
|
|
536
|
+
total: totalItems,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
if (totalItems === 0) return null;
|
|
540
|
+
return `Showing ${from} to ${to} of ${totalItems} results`;
|
|
541
|
+
})();
|
|
542
|
+
|
|
543
|
+
const showNav = totalPages > 1;
|
|
544
|
+
|
|
545
|
+
if (caption == null && !showNav) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
return (
|
|
550
|
+
<div
|
|
551
|
+
ref={ref}
|
|
552
|
+
className={cn(
|
|
553
|
+
"flex min-h-9 w-full items-center gap-4",
|
|
554
|
+
caption == null ? "justify-center" : "justify-between",
|
|
555
|
+
className
|
|
556
|
+
)}
|
|
557
|
+
data-hook={dataHook}
|
|
558
|
+
data-slot="pagination-controls"
|
|
559
|
+
data-tracking-el={trackingEl || "pagination-controls"}
|
|
560
|
+
data-tracking-label={trackingLabel}
|
|
561
|
+
{...props}
|
|
562
|
+
>
|
|
563
|
+
{caption != null && (
|
|
564
|
+
<span
|
|
565
|
+
className="text-body-sm text-muted-foreground"
|
|
566
|
+
data-slot="pagination-caption"
|
|
567
|
+
>
|
|
568
|
+
{caption}
|
|
569
|
+
</span>
|
|
570
|
+
)}
|
|
571
|
+
{showNav && (
|
|
572
|
+
<Pagination
|
|
573
|
+
ariaLabel={ariaLabel}
|
|
574
|
+
className={cn(caption != null && "mx-0 w-auto justify-end")}
|
|
575
|
+
dataHook={`${dataHook}-nav`}
|
|
576
|
+
>
|
|
577
|
+
<PaginationContent>
|
|
578
|
+
{items.map((item, index) => {
|
|
579
|
+
if (item === "previous") {
|
|
580
|
+
return (
|
|
581
|
+
<PaginationItem key="previous">
|
|
582
|
+
<PaginationPrevious
|
|
583
|
+
ariaLabel={prevAriaLabel}
|
|
584
|
+
disabled={page <= 1}
|
|
585
|
+
onClick={() => onPageChange(page - 1)}
|
|
586
|
+
/>
|
|
587
|
+
</PaginationItem>
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
if (item === "next") {
|
|
591
|
+
return (
|
|
592
|
+
<PaginationItem key="next">
|
|
593
|
+
<PaginationNext
|
|
594
|
+
ariaLabel={nextAriaLabel}
|
|
595
|
+
disabled={page >= totalPages}
|
|
596
|
+
onClick={() => onPageChange(page + 1)}
|
|
597
|
+
/>
|
|
598
|
+
</PaginationItem>
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
if (item === "ellipsis") {
|
|
602
|
+
return (
|
|
603
|
+
<PaginationItem key={`ellipsis-${index}`}>
|
|
604
|
+
<PaginationEllipsis srLabel={ellipsisSrLabel} />
|
|
605
|
+
</PaginationItem>
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
return (
|
|
609
|
+
<PaginationItem key={item}>
|
|
610
|
+
<PaginationLink
|
|
611
|
+
ariaLabel={pageAriaLabel}
|
|
612
|
+
isActive={item === page}
|
|
613
|
+
page={item}
|
|
614
|
+
onClick={() => onPageChange(item)}
|
|
615
|
+
/>
|
|
616
|
+
</PaginationItem>
|
|
617
|
+
);
|
|
618
|
+
})}
|
|
619
|
+
</PaginationContent>
|
|
620
|
+
</Pagination>
|
|
621
|
+
)}
|
|
622
|
+
</div>
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
|
|
627
|
+
PaginationControls.displayName = "PaginationControls";
|
|
628
|
+
|
|
354
629
|
export type { PaginationItemType };
|
|
355
630
|
|
|
356
631
|
export {
|
|
357
632
|
Pagination,
|
|
358
633
|
PaginationContent,
|
|
634
|
+
PaginationControls,
|
|
359
635
|
PaginationItem,
|
|
360
636
|
PaginationButton,
|
|
361
637
|
PaginationLink,
|
|
362
638
|
PaginationPrevious,
|
|
363
639
|
PaginationNext,
|
|
364
640
|
PaginationEllipsis,
|
|
641
|
+
type PaginationCaptionInfo,
|
|
642
|
+
type PaginationControlsProps,
|
|
365
643
|
type PaginationProps,
|
|
366
644
|
type PaginationButtonProps,
|
|
367
645
|
type PaginationLinkProps,
|
|
@@ -19,8 +19,8 @@ type ProgressColor = "green" | "red" | "orange" | "yellow";
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Text size of the label and value.
|
|
22
|
-
* - `sm` — 14px (`text-sm`), the default for metric rows in cards
|
|
23
|
-
* - `md` — 16px (`text-
|
|
22
|
+
* - `sm` — 14px (`text-body-sm`), the default for metric rows in cards
|
|
23
|
+
* - `md` — 16px (`text-body`) for roomier layouts
|
|
24
24
|
*/
|
|
25
25
|
type ProgressSize = "sm" | "md";
|
|
26
26
|
|
|
@@ -30,8 +30,8 @@ type ProgressSize = "sm" | "md";
|
|
|
30
30
|
* Bar heights are the `h-2` / `h-3` tokens the Figma component binds too.
|
|
31
31
|
*/
|
|
32
32
|
const SIZE_STYLES: Record<ProgressSize, { text: string; bar: string }> = {
|
|
33
|
-
sm: { text: "text-sm", bar: "h-2" },
|
|
34
|
-
md: { text: "text-
|
|
33
|
+
sm: { text: "text-body-sm", bar: "h-2" },
|
|
34
|
+
md: { text: "text-body", bar: "h-3" },
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -172,30 +172,6 @@ interface ProgressProps extends React.ComponentProps<
|
|
|
172
172
|
* Use this to customize the color, e.g., "bg-chart-red"
|
|
173
173
|
*/
|
|
174
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;
|
|
199
175
|
/**
|
|
200
176
|
* Whether the progress is in a disabled state
|
|
201
177
|
* When disabled, the component renders with 50% opacity
|
|
@@ -233,8 +209,6 @@ const Progress = React.forwardRef<
|
|
|
233
209
|
showValue = false,
|
|
234
210
|
unit = "%",
|
|
235
211
|
indicatorClassName,
|
|
236
|
-
statusDescription,
|
|
237
|
-
indeterminate = false,
|
|
238
212
|
disabled,
|
|
239
213
|
...props
|
|
240
214
|
},
|
|
@@ -247,18 +221,11 @@ const Progress = React.forwardRef<
|
|
|
247
221
|
const colorStyles = COLOR_STYLES[color] ?? COLOR_STYLES.green;
|
|
248
222
|
const sizeStyles = SIZE_STYLES[size] ?? SIZE_STYLES.sm;
|
|
249
223
|
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
224
|
/* The bar only gets flex sizing when the row wrapper actually wraps it.
|
|
258
|
-
Standalone — no label
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const inRow = hasVisibleLabel ||
|
|
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;
|
|
262
229
|
const percentage =
|
|
263
230
|
max > 0 ? Math.min(100, Math.max(0, ((value ?? 0) / max) * 100)) : 0;
|
|
264
231
|
|
|
@@ -274,7 +241,7 @@ const Progress = React.forwardRef<
|
|
|
274
241
|
inRow && "min-w-0 flex-1",
|
|
275
242
|
sizeStyles.bar,
|
|
276
243
|
colorStyles.track,
|
|
277
|
-
!hasVisibleLabel && !
|
|
244
|
+
!hasVisibleLabel && !showValue && disabled && "opacity-50",
|
|
278
245
|
className
|
|
279
246
|
)}
|
|
280
247
|
data-hook={dataHook}
|
|
@@ -282,65 +249,42 @@ const Progress = React.forwardRef<
|
|
|
282
249
|
data-tracking-el={trackingEl}
|
|
283
250
|
data-tracking-label={trackingLabel}
|
|
284
251
|
max={max}
|
|
285
|
-
/*
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
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}
|
|
291
258
|
{...props}
|
|
292
259
|
>
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
)}
|
|
260
|
+
<ProgressPrimitive.Indicator asChild>
|
|
261
|
+
<motion.div
|
|
262
|
+
animate={{
|
|
263
|
+
transform: `translateX(-${100 - percentage}%)`,
|
|
264
|
+
}}
|
|
265
|
+
className={cn(
|
|
266
|
+
"h-full w-full flex-1",
|
|
267
|
+
colorStyles.indicator,
|
|
268
|
+
indicatorClassName
|
|
269
|
+
)}
|
|
270
|
+
data-slot="progress-indicator"
|
|
271
|
+
initial={false}
|
|
272
|
+
transition={prefersReducedMotion ? { duration: 0 } : SPRING_GENTLE}
|
|
273
|
+
/>
|
|
274
|
+
</ProgressPrimitive.Indicator>
|
|
329
275
|
</ProgressPrimitive.Root>
|
|
330
276
|
);
|
|
331
277
|
|
|
332
|
-
if (!hasVisibleLabel && !
|
|
278
|
+
if (!hasVisibleLabel && !showValue) {
|
|
333
279
|
return progressBar;
|
|
334
280
|
}
|
|
335
281
|
|
|
336
|
-
/* The bar's
|
|
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. */
|
|
282
|
+
/* The bar's row: label on the left, bar in the middle, value on the right. */
|
|
339
283
|
const inlineRow = (
|
|
340
284
|
<div
|
|
341
285
|
className={cn(
|
|
342
286
|
"flex w-full items-center gap-2",
|
|
343
|
-
|
|
287
|
+
disabled && "opacity-50"
|
|
344
288
|
)}
|
|
345
289
|
data-slot="progress-wrapper"
|
|
346
290
|
>
|
|
@@ -350,7 +294,7 @@ const Progress = React.forwardRef<
|
|
|
350
294
|
// (`break-words` also splits a single overlong word) instead of
|
|
351
295
|
// pushing the bar around.
|
|
352
296
|
className={cn(
|
|
353
|
-
"text-foreground shrink-0
|
|
297
|
+
"text-foreground shrink-0 break-words",
|
|
354
298
|
// `auto`: hug the text but never take more than 40% of the row,
|
|
355
299
|
// so an overlong label still wraps instead of squeezing the bar.
|
|
356
300
|
labelHugs && "max-w-2/5",
|
|
@@ -365,7 +309,7 @@ const Progress = React.forwardRef<
|
|
|
365
309
|
</span>
|
|
366
310
|
)}
|
|
367
311
|
{progressBar}
|
|
368
|
-
{
|
|
312
|
+
{showValue && (
|
|
369
313
|
<span
|
|
370
314
|
className={cn(
|
|
371
315
|
"text-muted-foreground grid min-w-10 shrink-0 text-right tabular-nums",
|
|
@@ -398,28 +342,6 @@ const Progress = React.forwardRef<
|
|
|
398
342
|
</div>
|
|
399
343
|
);
|
|
400
344
|
|
|
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
345
|
return inlineRow;
|
|
424
346
|
}
|
|
425
347
|
);
|
|
@@ -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
|
-
|
|
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
|
|
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-
|
|
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
|
|
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" />
|
package/src/components/sheet.tsx
CHANGED
|
@@ -392,7 +392,7 @@ const SheetTitle = React.forwardRef<
|
|
|
392
392
|
<SheetPrimitive.Title
|
|
393
393
|
ref={ref}
|
|
394
394
|
className={cn(
|
|
395
|
-
"text-foreground text-
|
|
395
|
+
"text-foreground text-heading-section",
|
|
396
396
|
icon && "flex items-center gap-2",
|
|
397
397
|
className
|
|
398
398
|
)}
|
|
@@ -433,7 +433,7 @@ const SheetDescription = React.forwardRef<
|
|
|
433
433
|
>(({ className, dataHook, ...props }, ref) => (
|
|
434
434
|
<SheetPrimitive.Description
|
|
435
435
|
ref={ref}
|
|
436
|
-
className={cn("text-
|
|
436
|
+
className={cn("text-body-sm text-muted-foreground", className)}
|
|
437
437
|
data-hook={dataHook}
|
|
438
438
|
data-slot="sheet-description"
|
|
439
439
|
{...props}
|