@brightlocal/ui-components 2.27.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/README.md +7 -1
  2. package/component-meta.json +568 -143
  3. package/deprecations.json +298 -1
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.d.ts +36 -0
  6. package/dist/accordion.d.ts.map +1 -1
  7. package/dist/accordion.js +74 -61
  8. package/dist/alert-dialog.cjs +1 -1
  9. package/dist/alert-dialog.js +18 -18
  10. package/dist/alert.cjs +1 -1
  11. package/dist/alert.d.ts +11 -1
  12. package/dist/alert.d.ts.map +1 -1
  13. package/dist/alert.js +31 -28
  14. package/dist/avatar.cjs +1 -1
  15. package/dist/avatar.js +4 -4
  16. package/dist/badge.cjs +1 -1
  17. package/dist/badge.d.ts.map +1 -1
  18. package/dist/badge.js +15 -11
  19. package/dist/blocks/empty-state.cjs +1 -0
  20. package/dist/blocks/empty-state.d.ts +172 -0
  21. package/dist/blocks/empty-state.d.ts.map +1 -0
  22. package/dist/blocks/empty-state.js +147 -0
  23. package/dist/blocks/input-list.cjs +2 -2
  24. package/dist/blocks/input-list.d.ts.map +1 -1
  25. package/dist/blocks/input-list.js +124 -108
  26. package/dist/blocks/progress-state.cjs +1 -0
  27. package/dist/blocks/{progress-screen.d.ts → progress-state.d.ts} +30 -18
  28. package/dist/blocks/progress-state.d.ts.map +1 -0
  29. package/dist/blocks/{progress-screen.js → progress-state.js} +100 -71
  30. package/dist/blocks/sidebar.cjs +1 -1
  31. package/dist/blocks/sidebar.d.ts.map +1 -1
  32. package/dist/blocks/sidebar.js +160 -161
  33. package/dist/breadcrumb.cjs +1 -1
  34. package/dist/breadcrumb.js +1 -1
  35. package/dist/button-group.cjs +1 -0
  36. package/dist/button-group.d.ts +36 -0
  37. package/dist/button-group.d.ts.map +1 -0
  38. package/dist/button-group.js +47 -0
  39. package/dist/button.cjs +1 -1
  40. package/dist/button.js +12 -12
  41. package/dist/calendar.cjs +1 -1
  42. package/dist/calendar.d.ts.map +1 -1
  43. package/dist/calendar.js +37 -38
  44. package/dist/callout.cjs +1 -1
  45. package/dist/callout.d.ts +24 -2
  46. package/dist/callout.d.ts.map +1 -1
  47. package/dist/callout.js +57 -55
  48. package/dist/card.cjs +1 -1
  49. package/dist/card.d.ts +42 -3
  50. package/dist/card.d.ts.map +1 -1
  51. package/dist/card.js +102 -91
  52. package/dist/chart-empty.cjs +1 -0
  53. package/dist/chart-empty.d.ts +59 -0
  54. package/dist/chart-empty.d.ts.map +1 -0
  55. package/dist/chart-empty.js +29 -0
  56. package/dist/chart.cjs +6 -6
  57. package/dist/chart.d.ts +46 -13
  58. package/dist/chart.d.ts.map +1 -1
  59. package/dist/chart.js +172 -157
  60. package/dist/chip.cjs +1 -1
  61. package/dist/chip.d.ts +38 -4
  62. package/dist/chip.d.ts.map +1 -1
  63. package/dist/chip.js +100 -84
  64. package/dist/combobox.cjs +2 -2
  65. package/dist/combobox.d.ts.map +1 -1
  66. package/dist/combobox.js +81 -79
  67. package/dist/command.cjs +1 -1
  68. package/dist/command.d.ts +23 -1
  69. package/dist/command.d.ts.map +1 -1
  70. package/dist/command.js +248 -225
  71. package/dist/context-menu.cjs +1 -1
  72. package/dist/context-menu.d.ts.map +1 -1
  73. package/dist/context-menu.js +26 -29
  74. package/dist/data-table.cjs +1 -1
  75. package/dist/data-table.d.ts +75 -10
  76. package/dist/data-table.d.ts.map +1 -1
  77. package/dist/data-table.js +346 -334
  78. package/dist/date-picker.cjs +1 -1
  79. package/dist/date-picker.d.ts +13 -5
  80. package/dist/date-picker.d.ts.map +1 -1
  81. package/dist/date-picker.js +54 -53
  82. package/dist/description.cjs +1 -1
  83. package/dist/description.js +5 -5
  84. package/dist/dialog.cjs +1 -1
  85. package/dist/dialog.js +20 -20
  86. package/dist/drawer.cjs +1 -1
  87. package/dist/drawer.d.ts.map +1 -1
  88. package/dist/drawer.js +8 -11
  89. package/dist/dropdown-menu.cjs +1 -1
  90. package/dist/dropdown-menu.d.ts.map +1 -1
  91. package/dist/dropdown-menu.js +17 -20
  92. package/dist/field.cjs +1 -1
  93. package/dist/field.d.ts +8 -1
  94. package/dist/field.d.ts.map +1 -1
  95. package/dist/field.js +96 -65
  96. package/dist/global-layout.cjs +1 -1
  97. package/dist/global-layout.d.ts +130 -12
  98. package/dist/global-layout.d.ts.map +1 -1
  99. package/dist/global-layout.js +146 -127
  100. package/dist/grid.cjs +1 -0
  101. package/dist/grid.d.ts +56 -0
  102. package/dist/grid.d.ts.map +1 -0
  103. package/dist/grid.js +32 -0
  104. package/dist/header.d.ts +13 -0
  105. package/dist/header.d.ts.map +1 -1
  106. package/dist/hooks/use-delayed-pending.cjs +1 -0
  107. package/dist/hooks/use-delayed-pending.d.ts +34 -0
  108. package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
  109. package/dist/hooks/use-delayed-pending.js +17 -0
  110. package/dist/hooks/use-mobile.cjs +1 -0
  111. package/dist/hooks/use-mobile.js +8 -0
  112. package/dist/hover-card.cjs +1 -1
  113. package/dist/hover-card.js +13 -13
  114. package/dist/index.cjs +1 -1
  115. package/dist/index.d.ts +9 -1
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +554 -527
  118. package/dist/input-chip.cjs +1 -1
  119. package/dist/input-chip.js +25 -25
  120. package/dist/input-group.cjs +1 -1
  121. package/dist/input-group.js +9 -9
  122. package/dist/input-otp.cjs +1 -1
  123. package/dist/input-otp.js +9 -9
  124. package/dist/input-password.cjs +1 -1
  125. package/dist/input-password.d.ts +17 -9
  126. package/dist/input-password.d.ts.map +1 -1
  127. package/dist/input-password.js +73 -72
  128. package/dist/input.cjs +1 -1
  129. package/dist/input.js +9 -9
  130. package/dist/label.cjs +1 -1
  131. package/dist/label.d.ts.map +1 -1
  132. package/dist/label.js +25 -28
  133. package/dist/lib/block-illustration.cjs +1 -0
  134. package/dist/lib/block-illustration.d.ts +28 -0
  135. package/dist/lib/block-illustration.d.ts.map +1 -0
  136. package/dist/lib/block-illustration.js +21 -0
  137. package/dist/lib/empty-canvas.cjs +1 -0
  138. package/dist/lib/empty-canvas.d.ts +27 -0
  139. package/dist/lib/empty-canvas.d.ts.map +1 -0
  140. package/dist/lib/empty-canvas.js +62 -0
  141. package/dist/lib/empty-chip.cjs +1 -0
  142. package/dist/lib/empty-chip.d.ts +4 -0
  143. package/dist/lib/empty-chip.d.ts.map +1 -0
  144. package/dist/lib/empty-chip.js +13 -0
  145. package/dist/lib/optical-center.cjs +1 -0
  146. package/dist/lib/optical-center.d.ts +12 -0
  147. package/dist/lib/optical-center.d.ts.map +1 -0
  148. package/dist/lib/optical-center.js +11 -0
  149. package/dist/lib/utils.cjs +1 -1
  150. package/dist/lib/utils.d.ts.map +1 -1
  151. package/dist/lib/utils.js +28 -5
  152. package/dist/list.cjs +1 -1
  153. package/dist/list.d.ts.map +1 -1
  154. package/dist/list.js +62 -58
  155. package/dist/map.cjs +1 -1
  156. package/dist/map.d.ts +60 -2
  157. package/dist/map.d.ts.map +1 -1
  158. package/dist/map.js +187 -164
  159. package/dist/media-empty.cjs +1 -0
  160. package/dist/media-empty.d.ts +72 -0
  161. package/dist/media-empty.d.ts.map +1 -0
  162. package/dist/media-empty.js +45 -0
  163. package/dist/menubar.cjs +1 -1
  164. package/dist/menubar.d.ts.map +1 -1
  165. package/dist/menubar.js +17 -20
  166. package/dist/navigation-menu.cjs +1 -1
  167. package/dist/navigation-menu.js +7 -7
  168. package/dist/pagination.cjs +1 -1
  169. package/dist/pagination.d.ts +130 -1
  170. package/dist/pagination.d.ts.map +1 -1
  171. package/dist/pagination.js +193 -102
  172. package/dist/progress.cjs +1 -1
  173. package/dist/progress.d.ts +2 -26
  174. package/dist/progress.d.ts.map +1 -1
  175. package/dist/progress.js +79 -118
  176. package/dist/scroll-area.cjs +1 -1
  177. package/dist/scroll-area.d.ts +15 -6
  178. package/dist/scroll-area.d.ts.map +1 -1
  179. package/dist/scroll-area.js +38 -36
  180. package/dist/select.cjs +2 -2
  181. package/dist/select.d.ts +13 -2
  182. package/dist/select.d.ts.map +1 -1
  183. package/dist/select.js +92 -87
  184. package/dist/separator.cjs +1 -1
  185. package/dist/separator.js +8 -8
  186. package/dist/sheet.cjs +1 -1
  187. package/dist/sheet.js +2 -2
  188. package/dist/skeleton.cjs +1 -1
  189. package/dist/skeleton.d.ts +38 -3
  190. package/dist/skeleton.d.ts.map +1 -1
  191. package/dist/skeleton.js +43 -20
  192. package/dist/sonner.cjs +1 -1
  193. package/dist/sonner.js +26 -26
  194. package/dist/stepper.cjs +1 -1
  195. package/dist/stepper.js +40 -40
  196. package/dist/table.cjs +1 -1
  197. package/dist/table.d.ts.map +1 -1
  198. package/dist/table.js +31 -28
  199. package/dist/tabs.cjs +1 -1
  200. package/dist/tabs.js +1 -1
  201. package/dist/text-reveal-motion.d.ts +10 -0
  202. package/dist/text-reveal-motion.d.ts.map +1 -1
  203. package/dist/textarea.cjs +1 -1
  204. package/dist/textarea.js +11 -11
  205. package/dist/toggle.cjs +1 -1
  206. package/dist/toggle.js +8 -8
  207. package/dist/tooltip.cjs +1 -1
  208. package/dist/tooltip.js +8 -8
  209. package/dist/typography-heading.cjs +1 -0
  210. package/dist/typography-heading.d.ts +129 -0
  211. package/dist/typography-heading.d.ts.map +1 -0
  212. package/dist/typography-heading.js +95 -0
  213. package/dist/typography-text.cjs +1 -0
  214. package/dist/typography-text.d.ts +127 -0
  215. package/dist/typography-text.d.ts.map +1 -0
  216. package/dist/typography-text.js +92 -0
  217. package/dist/typography.d.ts +13 -0
  218. package/dist/typography.d.ts.map +1 -1
  219. package/package.json +35 -7
  220. package/src/blocks/empty-state.tsx +412 -0
  221. package/src/blocks/input-list.tsx +66 -36
  222. package/src/blocks/{progress-screen.tsx → progress-state.tsx} +154 -93
  223. package/src/blocks/sidebar.tsx +25 -26
  224. package/src/components/accordion.tsx +82 -27
  225. package/src/components/alert-dialog.tsx +2 -2
  226. package/src/components/alert.tsx +27 -13
  227. package/src/components/avatar.tsx +1 -1
  228. package/src/components/badge.tsx +8 -4
  229. package/src/components/breadcrumb.tsx +1 -1
  230. package/src/components/button-group.tsx +112 -0
  231. package/src/components/button.tsx +4 -4
  232. package/src/components/calendar.tsx +5 -6
  233. package/src/components/callout.tsx +48 -15
  234. package/src/components/card.tsx +89 -19
  235. package/src/components/chart-empty.tsx +116 -0
  236. package/src/components/chart.tsx +103 -32
  237. package/src/components/chip.tsx +88 -13
  238. package/src/components/combobox.tsx +12 -10
  239. package/src/components/command.tsx +64 -13
  240. package/src/components/context-menu.tsx +6 -9
  241. package/src/components/data-table.tsx +135 -20
  242. package/src/components/date-picker.tsx +18 -7
  243. package/src/components/description.tsx +1 -1
  244. package/src/components/dialog.tsx +2 -2
  245. package/src/components/drawer.tsx +2 -5
  246. package/src/components/dropdown-menu.tsx +8 -11
  247. package/src/components/field.tsx +89 -16
  248. package/src/components/global-layout.tsx +210 -39
  249. package/src/components/grid.tsx +130 -0
  250. package/src/components/header.tsx +13 -0
  251. package/src/components/hover-card.tsx +1 -1
  252. package/src/components/input-chip.tsx +1 -1
  253. package/src/components/input-group.tsx +1 -1
  254. package/src/components/input-otp.tsx +1 -1
  255. package/src/components/input-password.tsx +24 -12
  256. package/src/components/input.tsx +1 -1
  257. package/src/components/label.tsx +10 -13
  258. package/src/components/list.tsx +13 -9
  259. package/src/components/map.tsx +101 -5
  260. package/src/components/media-empty.tsx +156 -0
  261. package/src/components/menubar.tsx +7 -10
  262. package/src/components/navigation-menu.tsx +1 -1
  263. package/src/components/pagination.tsx +286 -1
  264. package/src/components/progress.tsx +35 -113
  265. package/src/components/scroll-area.tsx +23 -10
  266. package/src/components/select.tsx +35 -10
  267. package/src/components/separator.tsx +1 -1
  268. package/src/components/sheet.tsx +2 -2
  269. package/src/components/skeleton.tsx +78 -7
  270. package/src/components/sonner.tsx +2 -2
  271. package/src/components/stepper.tsx +3 -3
  272. package/src/components/table.tsx +6 -3
  273. package/src/components/tabs.tsx +1 -1
  274. package/src/components/text-reveal-motion.tsx +10 -0
  275. package/src/components/textarea.tsx +1 -1
  276. package/src/components/toggle.tsx +1 -1
  277. package/src/components/tooltip.tsx +1 -1
  278. package/src/components/typography-heading.tsx +253 -0
  279. package/src/components/typography-text.tsx +250 -0
  280. package/src/components/typography.tsx +13 -0
  281. package/src/hooks/use-delayed-pending.ts +60 -0
  282. package/src/index.ts +11 -1
  283. package/src/lib/block-illustration.tsx +88 -0
  284. package/src/lib/empty-canvas.tsx +128 -0
  285. package/src/lib/empty-chip.ts +24 -0
  286. package/src/lib/optical-center.tsx +45 -0
  287. package/src/lib/utils.ts +26 -0
  288. package/dist/blocks/progress-screen.cjs +0 -1
  289. package/dist/blocks/progress-screen.d.ts.map +0 -1
@@ -0,0 +1,156 @@
1
+ import * as React from "react";
2
+ import { Image, Video } from "@brightlocal/icons";
3
+
4
+ import { cn } from "@brightlocal/ui-components/lib/utils";
5
+ import { EmptyCanvas } from "../lib/empty-canvas";
6
+
7
+ /* -------------------------------------------------------------------------------------------------
8
+ * MediaEmpty
9
+ *
10
+ * The missing-media placeholder for a media slot (Patterns/Empty States →
11
+ * Charts, maps & images) — location photos, card media, video wells. Same
12
+ * canvas family as `ChartEmpty` and `MapEmpty`: a muted surface, a bare icon,
13
+ * one quiet line, no title and no CTA.
14
+ *
15
+ * One component, one `variant` axis — `image` and `video` are the same
16
+ * treatment with a different glyph and default line, so a second component
17
+ * would only be a second description of the same canvas. (It was born
18
+ * `ImageEmpty`; the name lied about half of its own variants.)
19
+ *
20
+ * Two decisions worth keeping:
21
+ *
22
+ * The icon is the plain `Image`/`Video` glyph, never `ImageOff`/`VideoOff`.
23
+ * This state is "media goes here", not "the media is broken" — the `…Off`
24
+ * glyphs tell the reader something failed, and nothing did.
25
+ *
26
+ * The component owns its own background. A media slot's frame — usually
27
+ * `AspectRatio` — is a layout primitive, and painting a surface on it from the
28
+ * outside means a `bg-muted` className override on a DS component, which the
29
+ * override policy rightly refuses. Absorbing the surface here settles that: the
30
+ * frame stays a frame, and the placeholder brings its own fill (DS-934).
31
+ *
32
+ * The frame is the consumer's and it stays put, so the layout never shifts when
33
+ * the media arrives — and anything overlaid on the frame (a status Badge in a
34
+ * corner) keeps working, because this fills the frame rather than replacing it.
35
+ * -----------------------------------------------------------------------------------------------*/
36
+
37
+ /**
38
+ * Which medium the slot holds. Picks the glyph and the default line — the
39
+ * treatment is identical.
40
+ */
41
+ type MediaEmptyVariant = "image" | "video";
42
+
43
+ /** The glyph and default line per variant. */
44
+ const VARIANT_DEFAULTS: Record<
45
+ MediaEmptyVariant,
46
+ { icon: React.ReactNode; message: string }
47
+ > = {
48
+ image: { icon: <Image strokeWidth={2} />, message: "No photo available" },
49
+ video: { icon: <Video strokeWidth={2} />, message: "No video available" },
50
+ };
51
+
52
+ /**
53
+ * Props for the MediaEmpty component.
54
+ */
55
+ export interface MediaEmptyProps extends Omit<
56
+ React.ComponentPropsWithoutRef<"div">,
57
+ "children" | "title"
58
+ > {
59
+ /**
60
+ * Required data-hook attribute for automated testing. The parts derive
61
+ * theirs from it: `-icon`, `-message`.
62
+ * @example "location-photo-empty"
63
+ */
64
+ dataHook: string;
65
+ /**
66
+ * Which medium the slot holds — picks the glyph and the default line.
67
+ * @default "image"
68
+ */
69
+ variant?: MediaEmptyVariant;
70
+ /**
71
+ * Overrides the variant's glyph, for a slot neither variant names.
72
+ * @default the variant's glyph
73
+ */
74
+ icon?: React.ReactNode;
75
+ /**
76
+ * The one line under the glyph. No trailing period.
77
+ * @default "No photo available" at variant image, "No video available" at variant video
78
+ */
79
+ message?: string;
80
+ /**
81
+ * Tracking element identifier for analytics.
82
+ */
83
+ trackingEl?: string;
84
+ /**
85
+ * Tracking label for analytics context.
86
+ */
87
+ trackingLabel?: string;
88
+ }
89
+
90
+ /**
91
+ * A media slot with nothing in it — the reserved frame, filled with a muted
92
+ * surface, a bare icon, and one quiet line.
93
+ *
94
+ * The frame is the consumer's: this fills it, and corners the consumer overlays
95
+ * on the frame keep rendering above it.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * <AspectRatio dataHook="location-photo" ratio={16 / 9}>
100
+ * {photoUrl ? (
101
+ * <img alt={t("location.photo.alt", { businessName })} className="size-full object-cover" src={photoUrl} />
102
+ * ) : (
103
+ * <MediaEmpty dataHook="location-photo-empty" message={t("location.photo.empty")} />
104
+ * )}
105
+ * {status ? (
106
+ * <div className="absolute top-3 right-3">
107
+ * <LocationStatusBadge status={status} />
108
+ * </div>
109
+ * ) : null}
110
+ * </AspectRatio>
111
+ *
112
+ * // A video well: same canvas, the video glyph and line.
113
+ * <AspectRatio dataHook="tour-video" ratio={16 / 9}>
114
+ * <MediaEmpty dataHook="tour-video-empty" variant="video" />
115
+ * </AspectRatio>
116
+ * ```
117
+ */
118
+ const MediaEmpty = React.forwardRef<HTMLDivElement, MediaEmptyProps>(
119
+ (
120
+ {
121
+ className,
122
+ dataHook,
123
+ variant = "image",
124
+ icon,
125
+ message,
126
+ trackingEl,
127
+ trackingLabel,
128
+ ...props
129
+ },
130
+ ref
131
+ ) => (
132
+ /* `size-full`, unlike the chart and map placeholders: a media slot's frame
133
+ already has both dimensions — that is what reserving an aspect ratio
134
+ means — so this one fills rather than asking for a height. No radius
135
+ either: the frame clips, and a radius here would draw a second, smaller
136
+ corner inside the card's own. */
137
+ <EmptyCanvas
138
+ ref={ref}
139
+ className={cn("size-full", className)}
140
+ data-variant={variant}
141
+ dataHook={dataHook}
142
+ icon={icon ?? VARIANT_DEFAULTS[variant].icon}
143
+ message={message ?? VARIANT_DEFAULTS[variant].message}
144
+ slot="media-empty"
145
+ trackingEl={trackingEl}
146
+ trackingLabel={trackingLabel}
147
+ {...props}
148
+ />
149
+ )
150
+ );
151
+
152
+ MediaEmpty.displayName = "MediaEmpty";
153
+
154
+ export { MediaEmpty };
155
+
156
+ export type { MediaEmptyVariant };
@@ -85,7 +85,7 @@ function MenubarTrigger({
85
85
  return (
86
86
  <MenubarPrimitive.Trigger
87
87
  className={cn(
88
- "text-foreground duration-fast flex cursor-pointer items-center justify-center gap-2 rounded-xs px-3 py-1 text-sm font-normal transition-colors ease-out",
88
+ "text-foreground duration-fast text-label flex cursor-pointer items-center justify-center gap-2 rounded-xs px-3 py-1 transition-colors ease-out",
89
89
  "hover:bg-accent hover:text-accent-foreground",
90
90
  "focus:bg-accent focus:text-accent-foreground focus:outline-none",
91
91
  "data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
@@ -147,7 +147,7 @@ function MenubarItem({
147
147
  return (
148
148
  <MenubarPrimitive.Item
149
149
  className={cn(
150
- "text-foreground duration-fast relative flex cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 text-sm font-normal transition-colors ease-out outline-none",
150
+ "text-foreground duration-fast text-label relative flex cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 transition-colors ease-out outline-none",
151
151
  "hover:bg-accent hover:text-foreground",
152
152
  "focus:bg-accent focus:text-foreground",
153
153
  "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
@@ -191,7 +191,7 @@ function MenubarCheckboxItem({
191
191
  <MenubarPrimitive.CheckboxItem
192
192
  checked={checked}
193
193
  className={cn(
194
- "text-foreground duration-fast relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors ease-out outline-none",
194
+ "text-foreground duration-fast text-label relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 transition-colors ease-out outline-none",
195
195
  "hover:bg-accent hover:text-foreground",
196
196
  "focus:bg-accent focus:text-foreground",
197
197
  "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
@@ -268,7 +268,7 @@ function MenubarRadioItem({
268
268
  return (
269
269
  <MenubarPrimitive.RadioItem
270
270
  className={cn(
271
- "text-foreground duration-fast relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors ease-out outline-none",
271
+ "text-foreground duration-fast text-label relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 transition-colors ease-out outline-none",
272
272
  "hover:bg-accent hover:text-foreground",
273
273
  "focus:bg-accent focus:text-foreground",
274
274
  "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
@@ -310,7 +310,7 @@ function MenubarLabel({
310
310
  return (
311
311
  <MenubarPrimitive.Label
312
312
  className={cn(
313
- "text-foreground px-2 py-1.5 text-sm font-semibold",
313
+ "text-foreground text-label-sm px-2 py-1.5",
314
314
  inset && "pl-8",
315
315
  className
316
316
  )}
@@ -345,10 +345,7 @@ function MenubarShortcut({
345
345
  }: React.HTMLAttributes<HTMLSpanElement>) {
346
346
  return (
347
347
  <span
348
- className={cn(
349
- "text-muted-foreground ml-auto text-xs tracking-widest",
350
- className
351
- )}
348
+ className={cn("text-muted-foreground text-body-xs ml-auto", className)}
352
349
  data-slot="menubar-shortcut"
353
350
  {...props}
354
351
  />
@@ -381,7 +378,7 @@ function MenubarSubTrigger({
381
378
  return (
382
379
  <MenubarPrimitive.SubTrigger
383
380
  className={cn(
384
- "text-foreground duration-fast flex cursor-pointer items-center justify-between rounded-xs px-2 py-1.5 text-sm font-normal transition-colors ease-out outline-none",
381
+ "text-foreground duration-fast text-label flex cursor-pointer items-center justify-between rounded-xs px-2 py-1.5 transition-colors ease-out outline-none",
385
382
  "hover:bg-accent hover:text-foreground",
386
383
  "focus:bg-accent focus:text-foreground",
387
384
  "data-[state=open]:bg-accent data-[state=open]:text-foreground",
@@ -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-sm font-medium",
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-sm font-medium",
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,302 @@ 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
+ * Below the `sm` viewport breakpoint the caption is removed and the nav
446
+ * centres, and from `sm` up the bar wraps inside narrow containers instead of
447
+ * overflowing — the same responsive rules as `DataTablePagination` (DS-998).
448
+ *
449
+ * There is nothing to navigate on a single page, so the nav hides itself at
450
+ * `totalPages <= 1` and the component renders nothing at all when the caption
451
+ * is empty too (same rule as `DataTablePagination`, DS-900).
452
+ *
453
+ * Reach for the primitives (`Pagination`, `PaginationContent`,
454
+ * `PaginationItem`, …) plus `usePagination` only when you need a layout or an
455
+ * item set this doesn't cover. Inside a `DataTable`, use `DataTablePagination`
456
+ * instead so pagination stays in sync with sorting and filtering.
457
+ *
458
+ * @example
459
+ * const [page, setPage] = React.useState(1);
460
+ *
461
+ * <PaginationControls
462
+ * dataHook="results-pagination"
463
+ * page={page}
464
+ * pageSize={10}
465
+ * totalItems={30}
466
+ * totalPages={3}
467
+ * onPageChange={setPage}
468
+ * />
469
+ *
470
+ * @example
471
+ * // Localised caption and labels
472
+ * <PaginationControls
473
+ * ariaLabel={t("pagination.nav")}
474
+ * dataHook="results-pagination"
475
+ * nextAriaLabel={t("pagination.next")}
476
+ * page={page}
477
+ * pageSize={10}
478
+ * prevAriaLabel={t("pagination.prev")}
479
+ * renderCaption={({ from, to, total }) =>
480
+ * t("pagination.caption", { from, to, total })
481
+ * }
482
+ * totalItems={30}
483
+ * totalPages={3}
484
+ * onPageChange={setPage}
485
+ * />
486
+ */
487
+ const PaginationControls = React.forwardRef<
488
+ HTMLDivElement,
489
+ PaginationControlsProps
490
+ >(
491
+ (
492
+ {
493
+ className,
494
+ page,
495
+ totalPages,
496
+ onPageChange,
497
+ dataHook,
498
+ totalItems,
499
+ pageSize,
500
+ renderCaption,
501
+ ariaLabel,
502
+ prevAriaLabel,
503
+ nextAriaLabel,
504
+ pageAriaLabel,
505
+ ellipsisSrLabel,
506
+ trackingEl,
507
+ trackingLabel,
508
+ ...props
509
+ },
510
+ ref
511
+ ) => {
512
+ const items = usePagination({ page, totalPages });
513
+ const isMobile = useIsBelowBreakpoint("sm");
514
+
515
+ const caption = (() => {
516
+ // Below `sm` the caption is removed so the page buttons get the full
517
+ // width and centre (DS-998) — same rule as `DataTablePagination`.
518
+ if (isMobile) return null;
519
+ if (renderCaption === null) return null;
520
+ if (totalItems === undefined || pageSize === undefined) return null;
521
+ // A page size that isn't a positive number, or a negative total, can only
522
+ // produce a nonsense range ("Showing 1 to 0 …", or NaN from a failed
523
+ // parse), so the caption is dropped rather than rendered wrong.
524
+ if (!Number.isFinite(pageSize) || pageSize <= 0) return null;
525
+ if (!Number.isFinite(totalItems) || totalItems < 0) return null;
526
+
527
+ // `page` is the consumer's controlled value, so it can sit out of range
528
+ // for a render while an async total shrinks underneath it (a filter
529
+ // applied while on page 4 of 10). Clamp to what the totals allow, or the
530
+ // caption reads "Showing 31 to 5 of 5 results".
531
+ const lastPage = Math.max(1, Math.ceil(totalItems / pageSize));
532
+ const safePage = Math.min(Math.max(1, Math.floor(page) || 1), lastPage);
533
+
534
+ const from = totalItems === 0 ? 0 : (safePage - 1) * pageSize + 1;
535
+ const to = Math.min(safePage * pageSize, totalItems);
536
+
537
+ if (renderCaption) {
538
+ return renderCaption({
539
+ page: safePage,
540
+ totalPages,
541
+ from,
542
+ to,
543
+ total: totalItems,
544
+ });
545
+ }
546
+ if (totalItems === 0) return null;
547
+ return `Showing ${from} to ${to} of ${totalItems} results`;
548
+ })();
549
+
550
+ const showNav = totalPages > 1;
551
+
552
+ if (caption == null && !showNav) {
553
+ return null;
554
+ }
555
+
556
+ return (
557
+ <div
558
+ ref={ref}
559
+ className={cn(
560
+ "flex min-h-9 w-full flex-wrap items-center gap-x-4 gap-y-2",
561
+ caption == null ? "justify-center" : "justify-between",
562
+ className
563
+ )}
564
+ data-hook={dataHook}
565
+ data-slot="pagination-controls"
566
+ data-tracking-el={trackingEl || "pagination-controls"}
567
+ data-tracking-label={trackingLabel}
568
+ {...props}
569
+ >
570
+ {caption != null && (
571
+ <span
572
+ className="text-body-sm text-muted-foreground whitespace-nowrap"
573
+ data-slot="pagination-caption"
574
+ >
575
+ {caption}
576
+ </span>
577
+ )}
578
+ {showNav && (
579
+ <Pagination
580
+ ariaLabel={ariaLabel}
581
+ className={cn(caption != null && "mx-0 w-auto grow justify-end")}
582
+ dataHook={`${dataHook}-nav`}
583
+ >
584
+ <PaginationContent>
585
+ {items.map((item, index) => {
586
+ if (item === "previous") {
587
+ return (
588
+ <PaginationItem key="previous">
589
+ <PaginationPrevious
590
+ ariaLabel={prevAriaLabel}
591
+ disabled={page <= 1}
592
+ onClick={() => onPageChange(page - 1)}
593
+ />
594
+ </PaginationItem>
595
+ );
596
+ }
597
+ if (item === "next") {
598
+ return (
599
+ <PaginationItem key="next">
600
+ <PaginationNext
601
+ ariaLabel={nextAriaLabel}
602
+ disabled={page >= totalPages}
603
+ onClick={() => onPageChange(page + 1)}
604
+ />
605
+ </PaginationItem>
606
+ );
607
+ }
608
+ if (item === "ellipsis") {
609
+ return (
610
+ <PaginationItem key={`ellipsis-${index}`}>
611
+ <PaginationEllipsis srLabel={ellipsisSrLabel} />
612
+ </PaginationItem>
613
+ );
614
+ }
615
+ return (
616
+ <PaginationItem key={item}>
617
+ <PaginationLink
618
+ ariaLabel={pageAriaLabel}
619
+ isActive={item === page}
620
+ page={item}
621
+ onClick={() => onPageChange(item)}
622
+ />
623
+ </PaginationItem>
624
+ );
625
+ })}
626
+ </PaginationContent>
627
+ </Pagination>
628
+ )}
629
+ </div>
630
+ );
631
+ }
632
+ );
633
+
634
+ PaginationControls.displayName = "PaginationControls";
635
+
354
636
  export type { PaginationItemType };
355
637
 
356
638
  export {
357
639
  Pagination,
358
640
  PaginationContent,
641
+ PaginationControls,
359
642
  PaginationItem,
360
643
  PaginationButton,
361
644
  PaginationLink,
362
645
  PaginationPrevious,
363
646
  PaginationNext,
364
647
  PaginationEllipsis,
648
+ type PaginationCaptionInfo,
649
+ type PaginationControlsProps,
365
650
  type PaginationProps,
366
651
  type PaginationButtonProps,
367
652
  type PaginationLinkProps,