@brightlocal/ui-components 3.2.0 → 3.3.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/AI_USAGE.md +10 -0
- package/README.md +3 -1
- package/component-meta.json +1271 -428
- package/deprecations.json +44 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +73 -102
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +6 -4
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +85 -133
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +4 -4
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +106 -168
- package/dist/aspect-ratio.cjs +1 -1
- package/dist/aspect-ratio.js +13 -16
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +30 -45
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +23 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +90 -91
- package/dist/banner.cjs +1 -1
- package/dist/banner.js +102 -148
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +20 -3
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +73 -140
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +136 -176
- package/dist/blocks/progress-state.cjs +1 -1
- package/dist/blocks/progress-state.js +223 -347
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +11 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +763 -1092
- package/dist/brand-illustration-motif.cjs +1 -1
- package/dist/brand-illustration-motif.js +40 -61
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +62 -102
- package/dist/button-group.cjs +1 -1
- package/dist/button-group.js +23 -31
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +4 -2
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +149 -189
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +87 -3
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +116 -173
- package/dist/callout.cjs +1 -1
- package/dist/callout.js +73 -96
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +10 -4
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +233 -316
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +3 -3
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +174 -268
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.js +27 -48
- package/dist/chart-empty.cjs +1 -1
- package/dist/chart-empty.js +18 -27
- package/dist/chart.cjs +7 -7
- package/dist/chart.d.ts +23 -13
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +445 -651
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +36 -69
- package/dist/chip.cjs +1 -1
- package/dist/chip.js +116 -173
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/collapsible.js +35 -41
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +14 -4
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +439 -638
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +273 -420
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts +5 -5
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +121 -191
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +280 -129
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +687 -948
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +15 -4
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +156 -231
- package/dist/delta.cjs +1 -0
- package/dist/delta.d.ts +79 -0
- package/dist/delta.d.ts.map +1 -0
- package/dist/delta.js +62 -0
- package/dist/description.cjs +1 -1
- package/dist/description.js +11 -20
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +76 -116
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +11 -11
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +76 -134
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +6 -6
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +179 -300
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +9 -9
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +166 -286
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.js +203 -342
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +16 -29
- package/dist/header.cjs +1 -1
- package/dist/header.js +21 -38
- package/dist/height-transition.cjs +1 -1
- package/dist/height-transition.js +38 -55
- package/dist/hooks/use-breakpoint.cjs +1 -1
- package/dist/hooks/use-breakpoint.js +9 -9
- package/dist/hooks/use-debounce.cjs +1 -1
- package/dist/hooks/use-debounce.js +12 -11
- package/dist/hooks/use-delayed-pending.cjs +1 -1
- package/dist/hooks/use-delayed-pending.js +8 -9
- package/dist/hooks/use-filter-search-params.cjs +1 -0
- package/dist/hooks/use-filter-search-params.d.ts +93 -0
- package/dist/hooks/use-filter-search-params.d.ts.map +1 -0
- package/dist/hooks/use-filter-search-params.js +122 -0
- package/dist/hooks/use-mobile.cjs +1 -1
- package/dist/hooks/use-mobile.js +6 -6
- package/dist/hooks/use-overlay-pointer-lock.cjs +1 -1
- package/dist/hooks/use-overlay-pointer-lock.js +8 -9
- package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
- package/dist/hooks/use-prefers-reduced-motion.js +5 -8
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +1 -1
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +30 -62
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +630 -608
- package/dist/info-tooltip.cjs +1 -1
- package/dist/info-tooltip.js +22 -36
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +32 -3
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +181 -230
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +174 -221
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +3 -3
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +102 -146
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +12 -16
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +139 -171
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +51 -73
- package/dist/label.cjs +1 -1
- package/dist/label.js +20 -38
- package/dist/lib/block-illustration.cjs +1 -1
- package/dist/lib/block-illustration.d.ts +1 -1
- package/dist/lib/block-illustration.d.ts.map +1 -1
- package/dist/lib/block-illustration.js +16 -18
- package/dist/lib/compose-event-handlers.cjs +1 -0
- package/dist/lib/compose-event-handlers.d.ts +9 -0
- package/dist/lib/compose-event-handlers.d.ts.map +1 -0
- package/dist/lib/compose-event-handlers.js +8 -0
- package/dist/lib/download-file.cjs +1 -0
- package/dist/lib/download-file.d.ts +14 -0
- package/dist/lib/download-file.d.ts.map +1 -0
- package/dist/lib/download-file.js +40 -0
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.js +28 -56
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +14 -3
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +15 -11
- package/dist/lib/field-aria.cjs +1 -0
- package/dist/lib/field-aria.d.ts +34 -0
- package/dist/lib/field-aria.d.ts.map +1 -0
- package/dist/lib/field-aria.js +52 -0
- package/dist/lib/image-file-info.cjs +1 -0
- package/dist/lib/image-file-info.d.ts +25 -0
- package/dist/lib/image-file-info.d.ts.map +1 -0
- package/dist/lib/image-file-info.js +67 -0
- package/dist/lib/media-viewer-content.cjs +1 -0
- package/dist/lib/media-viewer-content.d.ts +102 -0
- package/dist/lib/media-viewer-content.d.ts.map +1 -0
- package/dist/lib/media-viewer-content.js +650 -0
- package/dist/lib/media-viewer-internal.cjs +1 -0
- package/dist/lib/media-viewer-internal.d.ts +98 -0
- package/dist/lib/media-viewer-internal.d.ts.map +1 -0
- package/dist/lib/media-viewer-internal.js +61 -0
- package/dist/lib/media-viewer-motion.cjs +1 -0
- package/dist/lib/media-viewer-motion.d.ts +40 -0
- package/dist/lib/media-viewer-motion.d.ts.map +1 -0
- package/dist/lib/media-viewer-motion.js +37 -0
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.d.ts +8 -0
- package/dist/lib/motion.d.ts.map +1 -1
- package/dist/lib/motion.js +11 -10
- package/dist/lib/optical-center.cjs +1 -1
- package/dist/lib/optical-center.d.ts +1 -1
- package/dist/lib/optical-center.d.ts.map +1 -1
- package/dist/lib/optical-center.js +12 -5
- package/dist/lib/spring-settle.cjs +1 -1
- package/dist/lib/spring-settle.js +1 -1
- package/dist/lib/table-internal.cjs +1 -0
- package/dist/lib/table-internal.d.ts +62 -0
- package/dist/lib/table-internal.d.ts.map +1 -0
- package/dist/lib/table-internal.js +18 -0
- package/dist/lib/use-controllable.cjs +1 -0
- package/dist/lib/use-controllable.d.ts +12 -0
- package/dist/lib/use-controllable.d.ts.map +1 -0
- package/dist/lib/use-controllable.js +15 -0
- package/dist/lib/use-dev-warning.cjs +1 -1
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.js +26 -33
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.js +78 -124
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +8 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +94 -156
- package/dist/loading.cjs +1 -1
- package/dist/loading.js +124 -151
- package/dist/logo-mark.cjs +1 -0
- package/dist/logo-mark.d.ts +79 -0
- package/dist/logo-mark.d.ts.map +1 -0
- package/dist/logo-mark.js +219 -0
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +1 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +51 -87
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +390 -586
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.js +27 -42
- package/dist/media-viewer.cjs +1 -0
- package/dist/media-viewer.d.ts +224 -0
- package/dist/media-viewer.d.ts.map +1 -0
- package/dist/media-viewer.js +295 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +14 -14
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +130 -267
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts +9 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +357 -446
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +108 -172
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +36 -12
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +208 -281
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +34 -45
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +17 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +116 -162
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +90 -146
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +80 -13
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +70 -65
- package/dist/relative-date.cjs +1 -1
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/relative-date.js +73 -89
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +39 -23
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +42 -44
- package/dist/result-count.cjs +1 -0
- package/dist/result-count.d.ts +110 -0
- package/dist/result-count.d.ts.map +1 -0
- package/dist/result-count.js +49 -0
- package/dist/route-progress.cjs +1 -1
- package/dist/route-progress.js +58 -102
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +9 -1
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +44 -79
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +10 -10
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +118 -238
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +90 -78
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +8 -5
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +250 -317
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts +32 -0
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +201 -203
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.js +24 -38
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +51 -81
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +101 -125
- package/dist/spinner.cjs +1 -1
- package/dist/spinner.js +22 -31
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.js +52 -101
- package/dist/status.cjs +1 -0
- package/dist/status.d.ts +51 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +60 -0
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +184 -316
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +17 -32
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +103 -30
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +170 -209
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +102 -147
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.js +307 -363
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +22 -35
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.js +43 -62
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +34 -46
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts +2 -2
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +157 -249
- package/dist/typography-heading.cjs +1 -1
- package/dist/typography-heading.js +25 -61
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.js +27 -57
- package/dist/typography.cjs +1 -1
- package/dist/typography.js +132 -340
- package/package.json +46 -46
- package/src/blocks/empty-state.tsx +34 -18
- package/src/blocks/sidebar.tsx +86 -31
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert-dialog.tsx +4 -2
- package/src/components/badge.tsx +127 -15
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +8 -6
- package/src/components/calendar.tsx +155 -9
- package/src/components/card.tsx +63 -10
- package/src/components/carousel.tsx +4 -1
- package/src/components/chart.tsx +151 -17
- package/src/components/checkbox.tsx +1 -1
- package/src/components/collapsible.tsx +4 -1
- package/src/components/combobox.tsx +40 -7
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +4 -4
- package/src/components/data-table.tsx +619 -237
- package/src/components/date-picker.tsx +31 -4
- package/src/components/delta.tsx +217 -0
- package/src/components/drawer.tsx +5 -5
- package/src/components/dropdown-menu.tsx +4 -4
- package/src/components/field.tsx +36 -15
- package/src/components/global-layout.tsx +1 -1
- package/src/components/input-chip.tsx +51 -7
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-password.tsx +15 -19
- package/src/components/input.tsx +10 -1
- package/src/components/list.tsx +14 -2
- package/src/components/logo-mark.tsx +345 -0
- package/src/components/map.tsx +18 -20
- package/src/components/media-viewer.tsx +908 -0
- package/src/components/multi-select-filter.tsx +255 -121
- package/src/components/navigation-menu.tsx +2 -2
- package/src/components/pagination.tsx +86 -26
- package/src/components/progress.tsx +91 -23
- package/src/components/rating.tsx +200 -74
- package/src/components/relative-date.tsx +19 -11
- package/src/components/resizable.tsx +86 -33
- package/src/components/result-count.tsx +253 -0
- package/src/components/scroll-area.tsx +31 -5
- package/src/components/select.tsx +2 -2
- package/src/components/sheet.tsx +14 -4
- package/src/components/single-select-filter.tsx +136 -41
- package/src/components/slider.tsx +2 -2
- package/src/components/status.tsx +162 -0
- package/src/components/switch.tsx +1 -1
- package/src/components/table.tsx +278 -106
- package/src/components/tabs.tsx +1 -0
- package/src/components/textarea.tsx +20 -2
- package/src/components/toggle.tsx +2 -2
- package/src/components/tooltip.tsx +11 -20
- package/src/hooks/use-filter-search-params.ts +302 -0
- package/src/index.ts +6 -0
- package/src/lib/compose-event-handlers.ts +14 -0
- package/src/lib/download-file.ts +61 -0
- package/src/lib/empty-chip.tsx +52 -0
- package/src/lib/field-aria.tsx +97 -0
- package/src/lib/image-file-info.ts +102 -0
- package/src/lib/media-viewer-content.tsx +1587 -0
- package/src/lib/media-viewer-internal.tsx +191 -0
- package/src/lib/media-viewer-motion.ts +120 -0
- package/src/lib/motion.ts +9 -0
- package/src/lib/table-internal.ts +74 -0
- package/src/lib/use-controllable.ts +43 -0
- package/src/lib/empty-chip.ts +0 -24
|
@@ -3,6 +3,7 @@ import { ChevronLeft, ChevronRight, MoreHorizontal } from "@brightlocal/icons";
|
|
|
3
3
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
5
|
import { useIsBelowBreakpoint } from "@brightlocal/ui-components/hooks/use-breakpoint";
|
|
6
|
+
import { ResultCount } from "./result-count";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Pagination item variants
|
|
@@ -63,8 +64,8 @@ export function usePagination({
|
|
|
63
64
|
}
|
|
64
65
|
} else {
|
|
65
66
|
const siblings = Math.floor((slots - 5) / 2);
|
|
66
|
-
const startThreshold = slots - 3;
|
|
67
|
-
const endThreshold = totalPages - startThreshold;
|
|
67
|
+
const startThreshold = slots - 3;
|
|
68
|
+
const endThreshold = totalPages - startThreshold + 1;
|
|
68
69
|
|
|
69
70
|
if (page <= startThreshold) {
|
|
70
71
|
for (let i = 1; i <= slots - 2; i++) {
|
|
@@ -83,6 +84,19 @@ export function usePagination({
|
|
|
83
84
|
}
|
|
84
85
|
result.push("ellipsis", totalPages);
|
|
85
86
|
}
|
|
87
|
+
|
|
88
|
+
for (let i = 1; i < result.length - 1; i++) {
|
|
89
|
+
const prev = result[i - 1];
|
|
90
|
+
const next = result[i + 1];
|
|
91
|
+
if (
|
|
92
|
+
result[i] === "ellipsis" &&
|
|
93
|
+
typeof prev === "number" &&
|
|
94
|
+
typeof next === "number" &&
|
|
95
|
+
next - prev === 2
|
|
96
|
+
) {
|
|
97
|
+
result[i] = prev + 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
86
100
|
}
|
|
87
101
|
|
|
88
102
|
result.push("next");
|
|
@@ -100,6 +114,7 @@ const paginationItemVariants = cva(
|
|
|
100
114
|
"h-9 w-9",
|
|
101
115
|
"rounded-full",
|
|
102
116
|
"text-label",
|
|
117
|
+
"cursor-pointer",
|
|
103
118
|
"transition-colors duration-fast ease-out",
|
|
104
119
|
"focus-visible:outline-none focus-visible:shadow-default",
|
|
105
120
|
],
|
|
@@ -398,9 +413,33 @@ interface PaginationControlsProps extends Omit<
|
|
|
398
413
|
*/
|
|
399
414
|
pageSize?: number;
|
|
400
415
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
416
|
+
* Caption text. Supports the `{from}`, `{to}` and `{total}` placeholders —
|
|
417
|
+
* name the records in the product's words
|
|
418
|
+
* ("{from} to {to} of {total} locations"); i18next's `{{from}}`
|
|
419
|
+
* form is accepted too. Passed to `ResultCount` as its `rangeLabel`.
|
|
420
|
+
* @default "{from} to {to} of {total} results"
|
|
421
|
+
*/
|
|
422
|
+
captionLabel?: string;
|
|
423
|
+
/**
|
|
424
|
+
* `captionLabel` for a total of exactly 1 ("1 to 1 of 1 location"). Falls
|
|
425
|
+
* back to `captionLabel`; pair with i18next's `_one` key. Passed to
|
|
426
|
+
* `ResultCount` as its `rangeLabelOne`.
|
|
427
|
+
* @default "{from} to {to} of {total} result"
|
|
428
|
+
*/
|
|
429
|
+
captionLabelOne?: string;
|
|
430
|
+
/**
|
|
431
|
+
* Screen-reader-only caption while `totalItems` is 0. The visible caption
|
|
432
|
+
* hides at zero (the empty state says it) but the live region stays and
|
|
433
|
+
* announces the result; nothing is visible and the bar keeps no height.
|
|
434
|
+
* Passed to `ResultCount` as its `emptyLabel`.
|
|
435
|
+
* @default "No results"
|
|
436
|
+
*/
|
|
437
|
+
captionEmptyLabel?: string;
|
|
438
|
+
/**
|
|
439
|
+
* Render the results caption yourself. Receives the derived numbers; you
|
|
440
|
+
* own wording, order and pluralization. Return `null` to hide it. The node
|
|
441
|
+
* renders as plain text — prefer `captionLabel` so the caption stays the
|
|
442
|
+
* `ResultCount` live region.
|
|
404
443
|
*/
|
|
405
444
|
renderCaption?: ((info: PaginationCaptionInfo) => React.ReactNode) | null;
|
|
406
445
|
/**
|
|
@@ -440,8 +479,10 @@ interface PaginationControlsProps extends Omit<
|
|
|
440
479
|
* the composed counterpart to the primitives below.
|
|
441
480
|
*
|
|
442
481
|
* Controlled: the consumer holds `page` and updates it from `onPageChange`.
|
|
443
|
-
* Pass `totalItems` + `pageSize` to get the results caption
|
|
444
|
-
*
|
|
482
|
+
* Pass `totalItems` + `pageSize` to get the results caption — a `ResultCount`
|
|
483
|
+
* in its range form, so it is the same count a filtered list shows; the
|
|
484
|
+
* caption sits on the left with the nav pushed right, and without one the
|
|
485
|
+
* nav centres.
|
|
445
486
|
* Below the `sm` viewport breakpoint the caption is removed and the nav
|
|
446
487
|
* centres, and from `sm` up the bar wraps inside narrow containers instead of
|
|
447
488
|
* overflowing — the same responsive rules as `DataTablePagination` (DS-998).
|
|
@@ -476,9 +517,7 @@ interface PaginationControlsProps extends Omit<
|
|
|
476
517
|
* page={page}
|
|
477
518
|
* pageSize={10}
|
|
478
519
|
* prevAriaLabel={t("pagination.prev")}
|
|
479
|
-
*
|
|
480
|
-
* t("pagination.caption", { from, to, total })
|
|
481
|
-
* }
|
|
520
|
+
* captionLabel={t("pagination.caption")} // "{from} to {to} of {total} locations"
|
|
482
521
|
* totalItems={30}
|
|
483
522
|
* totalPages={3}
|
|
484
523
|
* onPageChange={setPage}
|
|
@@ -497,6 +536,9 @@ const PaginationControls = React.forwardRef<
|
|
|
497
536
|
dataHook,
|
|
498
537
|
totalItems,
|
|
499
538
|
pageSize,
|
|
539
|
+
captionLabel,
|
|
540
|
+
captionLabelOne,
|
|
541
|
+
captionEmptyLabel,
|
|
500
542
|
renderCaption,
|
|
501
543
|
ariaLabel,
|
|
502
544
|
prevAriaLabel,
|
|
@@ -519,7 +561,7 @@ const PaginationControls = React.forwardRef<
|
|
|
519
561
|
if (renderCaption === null) return null;
|
|
520
562
|
if (totalItems === undefined || pageSize === undefined) return null;
|
|
521
563
|
// A page size that isn't a positive number, or a negative total, can only
|
|
522
|
-
// produce a nonsense range ("
|
|
564
|
+
// produce a nonsense range ("1 to 0 …", or NaN from a failed
|
|
523
565
|
// parse), so the caption is dropped rather than rendered wrong.
|
|
524
566
|
if (!Number.isFinite(pageSize) || pageSize <= 0) return null;
|
|
525
567
|
if (!Number.isFinite(totalItems) || totalItems < 0) return null;
|
|
@@ -527,7 +569,7 @@ const PaginationControls = React.forwardRef<
|
|
|
527
569
|
// `page` is the consumer's controlled value, so it can sit out of range
|
|
528
570
|
// for a render while an async total shrinks underneath it (a filter
|
|
529
571
|
// applied while on page 4 of 10). Clamp to what the totals allow, or the
|
|
530
|
-
// caption reads "
|
|
572
|
+
// caption reads "31 to 5 of 5 results".
|
|
531
573
|
const lastPage = Math.max(1, Math.ceil(totalItems / pageSize));
|
|
532
574
|
const safePage = Math.min(Math.max(1, Math.floor(page) || 1), lastPage);
|
|
533
575
|
|
|
@@ -535,19 +577,43 @@ const PaginationControls = React.forwardRef<
|
|
|
535
577
|
const to = Math.min(safePage * pageSize, totalItems);
|
|
536
578
|
|
|
537
579
|
if (renderCaption) {
|
|
538
|
-
|
|
580
|
+
const content = renderCaption({
|
|
539
581
|
page: safePage,
|
|
540
582
|
totalPages,
|
|
541
583
|
from,
|
|
542
584
|
to,
|
|
543
585
|
total: totalItems,
|
|
544
586
|
});
|
|
587
|
+
if (content == null) return null;
|
|
588
|
+
return (
|
|
589
|
+
<span
|
|
590
|
+
className="text-body-sm text-muted-foreground whitespace-nowrap"
|
|
591
|
+
data-hook={`${dataHook}-caption`}
|
|
592
|
+
data-slot="pagination-caption"
|
|
593
|
+
>
|
|
594
|
+
{content}
|
|
595
|
+
</span>
|
|
596
|
+
);
|
|
545
597
|
}
|
|
546
|
-
|
|
547
|
-
|
|
598
|
+
return (
|
|
599
|
+
<ResultCount
|
|
600
|
+
className="whitespace-nowrap"
|
|
601
|
+
dataHook={`${dataHook}-caption`}
|
|
602
|
+
emptyLabel={captionEmptyLabel}
|
|
603
|
+
from={from}
|
|
604
|
+
rangeLabel={captionLabel}
|
|
605
|
+
rangeLabelOne={captionLabelOne}
|
|
606
|
+
to={to}
|
|
607
|
+
total={totalItems}
|
|
608
|
+
/>
|
|
609
|
+
);
|
|
548
610
|
})();
|
|
549
611
|
|
|
550
612
|
const showNav = totalPages > 1;
|
|
613
|
+
// At zero items the default caption is only its screen-reader empty
|
|
614
|
+
// label, so the bar keeps no height for it and the nav centres.
|
|
615
|
+
const captionVisible =
|
|
616
|
+
caption != null && (Boolean(renderCaption) || totalItems !== 0);
|
|
551
617
|
|
|
552
618
|
if (caption == null && !showNav) {
|
|
553
619
|
return null;
|
|
@@ -557,8 +623,9 @@ const PaginationControls = React.forwardRef<
|
|
|
557
623
|
<div
|
|
558
624
|
ref={ref}
|
|
559
625
|
className={cn(
|
|
560
|
-
"flex
|
|
561
|
-
|
|
626
|
+
"flex w-full flex-wrap items-center gap-x-4 gap-y-2",
|
|
627
|
+
(captionVisible || showNav) && "min-h-9",
|
|
628
|
+
captionVisible ? "justify-between" : "justify-center",
|
|
562
629
|
className
|
|
563
630
|
)}
|
|
564
631
|
data-hook={dataHook}
|
|
@@ -567,18 +634,11 @@ const PaginationControls = React.forwardRef<
|
|
|
567
634
|
data-tracking-label={trackingLabel}
|
|
568
635
|
{...props}
|
|
569
636
|
>
|
|
570
|
-
{caption
|
|
571
|
-
<span
|
|
572
|
-
className="text-body-sm text-muted-foreground whitespace-nowrap"
|
|
573
|
-
data-slot="pagination-caption"
|
|
574
|
-
>
|
|
575
|
-
{caption}
|
|
576
|
-
</span>
|
|
577
|
-
)}
|
|
637
|
+
{caption}
|
|
578
638
|
{showNav && (
|
|
579
639
|
<Pagination
|
|
580
640
|
ariaLabel={ariaLabel}
|
|
581
|
-
className={cn(
|
|
641
|
+
className={cn(captionVisible && "mx-0 w-auto grow justify-end")}
|
|
582
642
|
dataHook={`${dataHook}-nav`}
|
|
583
643
|
>
|
|
584
644
|
<PaginationContent>
|
|
@@ -9,7 +9,7 @@ import { usePrefersReducedMotion } from "@brightlocal/ui-components/hooks/use-pr
|
|
|
9
9
|
import { SPRING_GENTLE } from "../lib/motion";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Color for the progress indicator, drawn from the score scale (`score-*`).
|
|
13
13
|
* - `green` — strong / healthy / complete
|
|
14
14
|
* - `yellow` — moderate / acceptable
|
|
15
15
|
* - `orange` — weak / needs attention
|
|
@@ -24,6 +24,13 @@ type ProgressColor = "green" | "red" | "orange" | "yellow";
|
|
|
24
24
|
*/
|
|
25
25
|
type ProgressSize = "sm" | "md";
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Controls where the label and value sit relative to the bar.
|
|
29
|
+
* - `inline` — label | bar | value in a single row (the default)
|
|
30
|
+
* - `above` — label and value on one line, bar full width beneath
|
|
31
|
+
*/
|
|
32
|
+
type ProgressLabelPlacement = "inline" | "above";
|
|
33
|
+
|
|
27
34
|
/**
|
|
28
35
|
* Per-size classes: text for the label and value, height for the bar — the row
|
|
29
36
|
* scales as one unit (`sm` 14px text / 8px bar, `md` 16px text / 12px bar).
|
|
@@ -35,35 +42,34 @@ const SIZE_STYLES: Record<ProgressSize, { text: string; bar: string }> = {
|
|
|
35
42
|
};
|
|
36
43
|
|
|
37
44
|
/**
|
|
38
|
-
* Track and indicator color classes for each
|
|
45
|
+
* Track and indicator color classes for each color.
|
|
39
46
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* `
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* do not "fix" it back to `chart-*` without a design decision.
|
|
47
|
+
* The bar answers "how good is this value", so it paints with the score scale
|
|
48
|
+
* (DS-774): green → `score-strong`, yellow → `score-moderate`, orange →
|
|
49
|
+
* `score-weak`, red → `score-poor`. The track is the same colour at 20% over
|
|
50
|
+
* the surface. This replaces the off-palette `brand-*` hexes and the separate
|
|
51
|
+
* `green-400` fill (DS-773) — one scale for Progress, Map pins and Delta. The
|
|
52
|
+
* Figma component binds the same `base/score-*` variables.
|
|
47
53
|
*/
|
|
48
54
|
const COLOR_STYLES: Record<
|
|
49
55
|
ProgressColor,
|
|
50
56
|
{ track: string; indicator: string }
|
|
51
57
|
> = {
|
|
52
58
|
green: {
|
|
53
|
-
track: "bg-
|
|
54
|
-
indicator: "bg-
|
|
59
|
+
track: "bg-score-strong/20",
|
|
60
|
+
indicator: "bg-score-strong",
|
|
55
61
|
},
|
|
56
62
|
red: {
|
|
57
|
-
track: "bg-
|
|
58
|
-
indicator: "bg-
|
|
63
|
+
track: "bg-score-poor/20",
|
|
64
|
+
indicator: "bg-score-poor",
|
|
59
65
|
},
|
|
60
66
|
orange: {
|
|
61
|
-
track: "bg-
|
|
62
|
-
indicator: "bg-
|
|
67
|
+
track: "bg-score-weak/20",
|
|
68
|
+
indicator: "bg-score-weak",
|
|
63
69
|
},
|
|
64
70
|
yellow: {
|
|
65
|
-
track: "bg-
|
|
66
|
-
indicator: "bg-
|
|
71
|
+
track: "bg-score-moderate/20",
|
|
72
|
+
indicator: "bg-score-moderate",
|
|
67
73
|
},
|
|
68
74
|
};
|
|
69
75
|
|
|
@@ -179,6 +185,15 @@ interface ProgressBaseProps extends React.ComponentProps<
|
|
|
179
185
|
* @default "sm"
|
|
180
186
|
*/
|
|
181
187
|
size?: ProgressSize;
|
|
188
|
+
/**
|
|
189
|
+
* Controls where the label and value sit relative to the bar.
|
|
190
|
+
* `"inline"` places label | bar | value in a single row (the default).
|
|
191
|
+
* `"above"` stacks the label and value on one line above a full-width bar —
|
|
192
|
+
* use this in narrow columns where the inline row would squeeze the bar.
|
|
193
|
+
* `labelWidth` is ignored when `"above"`.
|
|
194
|
+
* @default "inline"
|
|
195
|
+
*/
|
|
196
|
+
labelPlacement?: ProgressLabelPlacement;
|
|
182
197
|
/**
|
|
183
198
|
* Whether to render the numeric value to the right of the progress bar.
|
|
184
199
|
* Falls back to `–` when no value is provided so the layout stays consistent.
|
|
@@ -323,6 +338,7 @@ const Progress = React.forwardRef<
|
|
|
323
338
|
labelWidth = DEFAULT_LABEL_WIDTH,
|
|
324
339
|
color = "green",
|
|
325
340
|
size = "sm",
|
|
341
|
+
labelPlacement = "inline",
|
|
326
342
|
showValue = false,
|
|
327
343
|
unit = "%",
|
|
328
344
|
valueFormatter,
|
|
@@ -352,11 +368,12 @@ const Progress = React.forwardRef<
|
|
|
352
368
|
const colorStyles = COLOR_STYLES[color] ?? COLOR_STYLES.green;
|
|
353
369
|
const sizeStyles = SIZE_STYLES[size] ?? SIZE_STYLES.sm;
|
|
354
370
|
const labelHugs = labelWidth === "auto";
|
|
355
|
-
/* The bar only gets flex sizing when
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const
|
|
371
|
+
/* The bar only gets flex sizing when it sits inside the inline (horizontal)
|
|
372
|
+
row wrapper. In the stacked ("above") layout the bar is in a column and
|
|
373
|
+
must keep its fixed height, so `flex-1` must not apply. Standalone — no
|
|
374
|
+
label and no value — it must not apply either. */
|
|
375
|
+
const inHorizontalRow =
|
|
376
|
+
(hasVisibleLabel || showValue) && labelPlacement === "inline";
|
|
360
377
|
/* Radix rejects a value outside 0–max outright — it logs an error, nulls
|
|
361
378
|
the value and announces the bar as indeterminate — so the bar gets the
|
|
362
379
|
same clamped measurement its fill is drawn from. The value column still
|
|
@@ -373,7 +390,7 @@ const Progress = React.forwardRef<
|
|
|
373
390
|
"relative w-full overflow-hidden rounded-full",
|
|
374
391
|
// Inside the row wrapper the bar fills whatever the fixed label and
|
|
375
392
|
// value columns leave over; standalone it must not flex at all.
|
|
376
|
-
|
|
393
|
+
inHorizontalRow && "min-w-0 flex-1",
|
|
377
394
|
sizeStyles.bar,
|
|
378
395
|
colorStyles.track,
|
|
379
396
|
!hasVisibleLabel && !showValue && disabled && "opacity-50",
|
|
@@ -417,6 +434,56 @@ const Progress = React.forwardRef<
|
|
|
417
434
|
return progressBar;
|
|
418
435
|
}
|
|
419
436
|
|
|
437
|
+
/* Stacked layout: label + value on one line, bar full width beneath.
|
|
438
|
+
Used in narrow columns where the inline row squeezes the bar. */
|
|
439
|
+
if (labelPlacement === "above") {
|
|
440
|
+
return (
|
|
441
|
+
<div
|
|
442
|
+
className={cn(
|
|
443
|
+
"flex w-full flex-col gap-1.5",
|
|
444
|
+
disabled && "opacity-50"
|
|
445
|
+
)}
|
|
446
|
+
data-label-placement="above"
|
|
447
|
+
data-slot="progress-wrapper"
|
|
448
|
+
>
|
|
449
|
+
<div
|
|
450
|
+
className={cn(
|
|
451
|
+
"flex justify-between gap-3",
|
|
452
|
+
hasVisibleLabel && !labelIsText
|
|
453
|
+
? "items-center"
|
|
454
|
+
: "items-baseline"
|
|
455
|
+
)}
|
|
456
|
+
>
|
|
457
|
+
{hasVisibleLabel && (
|
|
458
|
+
<span
|
|
459
|
+
className={cn(
|
|
460
|
+
"text-foreground min-w-0",
|
|
461
|
+
!labelIsText && "flex items-center",
|
|
462
|
+
sizeStyles.text
|
|
463
|
+
)}
|
|
464
|
+
data-slot="progress-label"
|
|
465
|
+
id={labelId}
|
|
466
|
+
>
|
|
467
|
+
{label}
|
|
468
|
+
</span>
|
|
469
|
+
)}
|
|
470
|
+
{showValue && (
|
|
471
|
+
<span
|
|
472
|
+
className={cn(
|
|
473
|
+
"text-muted-foreground ml-auto shrink-0 tabular-nums",
|
|
474
|
+
sizeStyles.text
|
|
475
|
+
)}
|
|
476
|
+
data-slot="progress-value"
|
|
477
|
+
>
|
|
478
|
+
<span data-slot="progress-value-text">{valueText}</span>
|
|
479
|
+
</span>
|
|
480
|
+
)}
|
|
481
|
+
</div>
|
|
482
|
+
{progressBar}
|
|
483
|
+
</div>
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
420
487
|
/* The bar's row: label on the left, bar in the middle, value on the right. */
|
|
421
488
|
const inlineRow = (
|
|
422
489
|
<div
|
|
@@ -505,6 +572,7 @@ export type {
|
|
|
505
572
|
ProgressBaseProps,
|
|
506
573
|
ProgressColor,
|
|
507
574
|
ProgressSize,
|
|
575
|
+
ProgressLabelPlacement,
|
|
508
576
|
ProgressLabelWidth,
|
|
509
577
|
ProgressValueFormatter,
|
|
510
578
|
ProgressNodeLabel,
|