@brightlocal/ui-components 2.26.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +9 -2
  2. package/component-meta.json +4010 -255
  3. package/deprecations.json +189 -2
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.js +2 -2
  6. package/dist/alert-dialog.cjs +1 -1
  7. package/dist/alert-dialog.js +18 -18
  8. package/dist/alert.cjs +1 -1
  9. package/dist/alert.d.ts +11 -1
  10. package/dist/alert.d.ts.map +1 -1
  11. package/dist/alert.js +31 -28
  12. package/dist/avatar.cjs +1 -1
  13. package/dist/avatar.js +4 -4
  14. package/dist/badge.cjs +1 -1
  15. package/dist/badge.d.ts.map +1 -1
  16. package/dist/badge.js +15 -11
  17. package/dist/blocks/empty-state.cjs +1 -0
  18. package/dist/blocks/empty-state.d.ts +172 -0
  19. package/dist/blocks/empty-state.d.ts.map +1 -0
  20. package/dist/blocks/empty-state.js +155 -0
  21. package/dist/blocks/input-list.cjs +2 -2
  22. package/dist/blocks/input-list.d.ts.map +1 -1
  23. package/dist/blocks/input-list.js +124 -108
  24. package/dist/blocks/progress-state.cjs +1 -0
  25. package/dist/blocks/progress-state.d.ts +121 -0
  26. package/dist/blocks/progress-state.d.ts.map +1 -0
  27. package/dist/blocks/progress-state.js +368 -0
  28. package/dist/blocks/sidebar.cjs +1 -1
  29. package/dist/blocks/sidebar.d.ts.map +1 -1
  30. package/dist/blocks/sidebar.js +297 -296
  31. package/dist/brand-illustration-motif.d.ts +1 -1
  32. package/dist/breadcrumb.cjs +1 -1
  33. package/dist/breadcrumb.d.ts.map +1 -1
  34. package/dist/breadcrumb.js +44 -40
  35. package/dist/button.cjs +1 -1
  36. package/dist/button.d.ts.map +1 -1
  37. package/dist/button.js +23 -23
  38. package/dist/calendar.cjs +1 -1
  39. package/dist/calendar.d.ts.map +1 -1
  40. package/dist/calendar.js +37 -38
  41. package/dist/callout.cjs +1 -1
  42. package/dist/callout.d.ts +24 -2
  43. package/dist/callout.d.ts.map +1 -1
  44. package/dist/callout.js +57 -55
  45. package/dist/card.cjs +1 -1
  46. package/dist/card.d.ts +23 -2
  47. package/dist/card.d.ts.map +1 -1
  48. package/dist/card.js +94 -91
  49. package/dist/chart-empty.cjs +1 -0
  50. package/dist/chart-empty.d.ts +59 -0
  51. package/dist/chart-empty.d.ts.map +1 -0
  52. package/dist/chart-empty.js +29 -0
  53. package/dist/chart.cjs +6 -6
  54. package/dist/chart.d.ts +6 -1
  55. package/dist/chart.d.ts.map +1 -1
  56. package/dist/chart.js +183 -183
  57. package/dist/chip.cjs +1 -1
  58. package/dist/chip.d.ts +1 -1
  59. package/dist/chip.d.ts.map +1 -1
  60. package/dist/chip.js +47 -44
  61. package/dist/combobox.cjs +3 -3
  62. package/dist/combobox.d.ts +4 -2
  63. package/dist/combobox.d.ts.map +1 -1
  64. package/dist/combobox.js +143 -141
  65. package/dist/command.cjs +1 -1
  66. package/dist/command.d.ts.map +1 -1
  67. package/dist/command.js +74 -77
  68. package/dist/context-menu.cjs +1 -1
  69. package/dist/context-menu.d.ts.map +1 -1
  70. package/dist/context-menu.js +26 -29
  71. package/dist/data-table.cjs +1 -1
  72. package/dist/data-table.d.ts +182 -13
  73. package/dist/data-table.d.ts.map +1 -1
  74. package/dist/data-table.js +462 -314
  75. package/dist/description.cjs +1 -1
  76. package/dist/description.js +5 -5
  77. package/dist/dialog.cjs +1 -1
  78. package/dist/dialog.js +20 -20
  79. package/dist/drawer.cjs +1 -1
  80. package/dist/drawer.d.ts.map +1 -1
  81. package/dist/drawer.js +8 -11
  82. package/dist/dropdown-menu.cjs +1 -1
  83. package/dist/dropdown-menu.d.ts.map +1 -1
  84. package/dist/dropdown-menu.js +17 -20
  85. package/dist/field.cjs +1 -1
  86. package/dist/field.d.ts.map +1 -1
  87. package/dist/field.js +29 -25
  88. package/dist/global-layout.cjs +1 -1
  89. package/dist/global-layout.d.ts +58 -6
  90. package/dist/global-layout.d.ts.map +1 -1
  91. package/dist/global-layout.js +278 -194
  92. package/dist/grid.cjs +1 -0
  93. package/dist/grid.d.ts +56 -0
  94. package/dist/grid.d.ts.map +1 -0
  95. package/dist/grid.js +32 -0
  96. package/dist/header.d.ts +13 -0
  97. package/dist/header.d.ts.map +1 -1
  98. package/dist/hooks/use-delayed-pending.cjs +1 -0
  99. package/dist/hooks/use-delayed-pending.d.ts +34 -0
  100. package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
  101. package/dist/hooks/use-delayed-pending.js +17 -0
  102. package/dist/hover-card.cjs +1 -1
  103. package/dist/hover-card.js +13 -13
  104. package/dist/index.cjs +1 -1
  105. package/dist/index.d.ts +10 -0
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +523 -494
  108. package/dist/input-chip.cjs +1 -1
  109. package/dist/input-chip.js +25 -25
  110. package/dist/input-group.cjs +1 -1
  111. package/dist/input-group.js +9 -9
  112. package/dist/input-otp.cjs +1 -1
  113. package/dist/input-otp.js +9 -9
  114. package/dist/input-password.cjs +1 -1
  115. package/dist/input-password.js +51 -51
  116. package/dist/input.cjs +1 -1
  117. package/dist/input.js +9 -9
  118. package/dist/label.cjs +1 -1
  119. package/dist/label.d.ts.map +1 -1
  120. package/dist/label.js +25 -28
  121. package/dist/lib/block-illustration.cjs +1 -0
  122. package/dist/lib/block-illustration.d.ts +28 -0
  123. package/dist/lib/block-illustration.d.ts.map +1 -0
  124. package/dist/lib/block-illustration.js +21 -0
  125. package/dist/lib/empty-canvas.cjs +1 -0
  126. package/dist/lib/empty-canvas.d.ts +27 -0
  127. package/dist/lib/empty-canvas.d.ts.map +1 -0
  128. package/dist/lib/empty-canvas.js +62 -0
  129. package/dist/lib/motion.cjs +1 -1
  130. package/dist/lib/motion.js +10 -8
  131. package/dist/lib/optical-center.cjs +1 -0
  132. package/dist/lib/optical-center.d.ts +12 -0
  133. package/dist/lib/optical-center.d.ts.map +1 -0
  134. package/dist/lib/optical-center.js +11 -0
  135. package/dist/lib/utils.cjs +1 -1
  136. package/dist/lib/utils.d.ts.map +1 -1
  137. package/dist/lib/utils.js +28 -5
  138. package/dist/link.cjs +1 -1
  139. package/dist/link.d.ts +8 -6
  140. package/dist/link.d.ts.map +1 -1
  141. package/dist/link.js +52 -20
  142. package/dist/list.cjs +1 -1
  143. package/dist/list.d.ts.map +1 -1
  144. package/dist/list.js +87 -81
  145. package/dist/map.cjs +1 -1
  146. package/dist/map.d.ts +60 -2
  147. package/dist/map.d.ts.map +1 -1
  148. package/dist/map.js +187 -164
  149. package/dist/media-empty.cjs +1 -0
  150. package/dist/media-empty.d.ts +72 -0
  151. package/dist/media-empty.d.ts.map +1 -0
  152. package/dist/media-empty.js +45 -0
  153. package/dist/menubar.cjs +1 -1
  154. package/dist/menubar.d.ts.map +1 -1
  155. package/dist/menubar.js +17 -20
  156. package/dist/navigation-menu.cjs +1 -1
  157. package/dist/navigation-menu.js +7 -7
  158. package/dist/pagination.cjs +1 -1
  159. package/dist/pagination.d.ts +127 -1
  160. package/dist/pagination.d.ts.map +1 -1
  161. package/dist/pagination.js +189 -98
  162. package/dist/progress.cjs +1 -1
  163. package/dist/progress.d.ts +37 -3
  164. package/dist/progress.d.ts.map +1 -1
  165. package/dist/progress.js +102 -64
  166. package/dist/route-progress.cjs +1 -0
  167. package/dist/route-progress.d.ts +103 -0
  168. package/dist/route-progress.d.ts.map +1 -0
  169. package/dist/route-progress.js +106 -0
  170. package/dist/select.cjs +2 -2
  171. package/dist/select.d.ts.map +1 -1
  172. package/dist/select.js +19 -18
  173. package/dist/separator.cjs +1 -1
  174. package/dist/separator.js +8 -8
  175. package/dist/sheet.cjs +1 -1
  176. package/dist/sheet.d.ts +35 -2
  177. package/dist/sheet.d.ts.map +1 -1
  178. package/dist/sheet.js +103 -66
  179. package/dist/skeleton.cjs +1 -1
  180. package/dist/skeleton.d.ts +38 -3
  181. package/dist/skeleton.d.ts.map +1 -1
  182. package/dist/skeleton.js +43 -20
  183. package/dist/sonner.cjs +1 -1
  184. package/dist/sonner.d.ts.map +1 -1
  185. package/dist/sonner.js +32 -36
  186. package/dist/spinner.cjs +1 -0
  187. package/dist/spinner.d.ts +57 -0
  188. package/dist/spinner.d.ts.map +1 -0
  189. package/dist/spinner.js +35 -0
  190. package/dist/stepper.cjs +1 -1
  191. package/dist/stepper.d.ts.map +1 -1
  192. package/dist/stepper.js +23 -22
  193. package/dist/table.cjs +1 -1
  194. package/dist/table.d.ts +1 -1
  195. package/dist/table.d.ts.map +1 -1
  196. package/dist/table.js +36 -29
  197. package/dist/tabs.cjs +1 -1
  198. package/dist/tabs.js +1 -1
  199. package/dist/text-reveal-motion.d.ts +10 -0
  200. package/dist/text-reveal-motion.d.ts.map +1 -1
  201. package/dist/textarea.cjs +1 -1
  202. package/dist/textarea.js +11 -11
  203. package/dist/toggle.cjs +1 -1
  204. package/dist/toggle.js +8 -8
  205. package/dist/tooltip.cjs +1 -1
  206. package/dist/tooltip.js +8 -8
  207. package/dist/typography-heading.cjs +1 -0
  208. package/dist/typography-heading.d.ts +116 -0
  209. package/dist/typography-heading.d.ts.map +1 -0
  210. package/dist/typography-heading.js +84 -0
  211. package/dist/typography-text.cjs +1 -0
  212. package/dist/typography-text.d.ts +113 -0
  213. package/dist/typography-text.d.ts.map +1 -0
  214. package/dist/typography-text.js +81 -0
  215. package/dist/typography.d.ts +13 -0
  216. package/dist/typography.d.ts.map +1 -1
  217. package/package.json +42 -2
  218. package/src/blocks/empty-state.tsx +424 -0
  219. package/src/blocks/input-list.tsx +66 -36
  220. package/src/blocks/progress-state.tsx +542 -0
  221. package/src/blocks/sidebar.tsx +46 -40
  222. package/src/components/accordion.tsx +2 -2
  223. package/src/components/alert-dialog.tsx +2 -2
  224. package/src/components/alert.tsx +27 -13
  225. package/src/components/avatar.tsx +1 -1
  226. package/src/components/badge.tsx +8 -4
  227. package/src/components/breadcrumb.tsx +9 -4
  228. package/src/components/button.tsx +5 -8
  229. package/src/components/calendar.tsx +5 -6
  230. package/src/components/callout.tsx +48 -15
  231. package/src/components/card.tsx +52 -17
  232. package/src/components/chart-empty.tsx +116 -0
  233. package/src/components/chart.tsx +43 -17
  234. package/src/components/chip.tsx +9 -6
  235. package/src/components/combobox.tsx +21 -12
  236. package/src/components/command.tsx +9 -10
  237. package/src/components/context-menu.tsx +6 -9
  238. package/src/components/data-table.tsx +405 -31
  239. package/src/components/description.tsx +1 -1
  240. package/src/components/dialog.tsx +2 -2
  241. package/src/components/drawer.tsx +2 -5
  242. package/src/components/dropdown-menu.tsx +8 -11
  243. package/src/components/field.tsx +8 -4
  244. package/src/components/global-layout.tsx +264 -65
  245. package/src/components/grid.tsx +130 -0
  246. package/src/components/header.tsx +13 -0
  247. package/src/components/hover-card.tsx +1 -1
  248. package/src/components/input-chip.tsx +1 -1
  249. package/src/components/input-group.tsx +1 -1
  250. package/src/components/input-otp.tsx +1 -1
  251. package/src/components/input-password.tsx +1 -1
  252. package/src/components/input.tsx +1 -1
  253. package/src/components/label.tsx +10 -13
  254. package/src/components/link.tsx +39 -5
  255. package/src/components/list.tsx +18 -14
  256. package/src/components/map.tsx +101 -5
  257. package/src/components/media-empty.tsx +156 -0
  258. package/src/components/menubar.tsx +7 -10
  259. package/src/components/navigation-menu.tsx +1 -1
  260. package/src/components/pagination.tsx +279 -1
  261. package/src/components/progress.tsx +120 -11
  262. package/src/components/route-progress.tsx +354 -0
  263. package/src/components/select.tsx +5 -4
  264. package/src/components/separator.tsx +1 -1
  265. package/src/components/sheet.tsx +89 -7
  266. package/src/components/skeleton.tsx +78 -7
  267. package/src/components/sonner.tsx +5 -14
  268. package/src/components/spinner.tsx +94 -0
  269. package/src/components/stepper.tsx +6 -7
  270. package/src/components/table.tsx +11 -4
  271. package/src/components/tabs.tsx +1 -1
  272. package/src/components/text-reveal-motion.tsx +10 -0
  273. package/src/components/textarea.tsx +1 -1
  274. package/src/components/toggle.tsx +1 -1
  275. package/src/components/tooltip.tsx +1 -1
  276. package/src/components/typography-heading.tsx +229 -0
  277. package/src/components/typography-text.tsx +225 -0
  278. package/src/components/typography.tsx +13 -0
  279. package/src/hooks/use-delayed-pending.ts +60 -0
  280. package/src/index.ts +12 -0
  281. package/src/lib/block-illustration.tsx +88 -0
  282. package/src/lib/empty-canvas.tsx +128 -0
  283. package/src/lib/optical-center.tsx +45 -0
  284. package/src/lib/utils.ts +26 -0
@@ -0,0 +1,88 @@
1
+ import * as React from "react";
2
+
3
+ /* -------------------------------------------------------------------------------------------------
4
+ * BlockIllustration (internal)
5
+ *
6
+ * The illustration slot shared by the blocks that draw one — ProgressState,
7
+ * and EmptyState at page scope. Both had the same problem and the same fix, so
8
+ * it lives once.
9
+ *
10
+ * The block owns the size, not the caller. Left to the consumer it was a number
11
+ * to get wrong on every call site, and forgetting it was as bad as mistyping
12
+ * it: the illustrations default to 250, so an unsized one arrives nearly twice
13
+ * the intended height and buries the title under it.
14
+ *
15
+ * The size is applied twice on purpose. As the element's own `size` prop,
16
+ * because clamping it only in the stylesheet means the artwork paints at 250
17
+ * and snaps down the moment the CSS lands — one visible jump on every mount.
18
+ * And as the wrapper's inline width/height, which is the whole mechanism for
19
+ * children that cannot take the prop.
20
+ *
21
+ * The box is square but the artwork is NOT stretched into it. The child keeps
22
+ * its own width — capped by the box — and takes its height from that, which is
23
+ * why `h-auto` is set and `w-auto` deliberately is not: an `<img>`'s `width`
24
+ * attribute is only a presentational hint, so a `w-auto` class beats it and
25
+ * collapses the element to nothing until the source has loaded. Most of the
26
+ * library's illustrations are square SVGs with a `size` prop, but a couple are
27
+ * `<img>`s with their own width and height (`GlobeyFixingFault` is 164×137),
28
+ * and forcing `size-full` on one of those squashed it. The child is capped by
29
+ * the box and keeps its own ratio instead, centred in whatever room is left, so
30
+ * the column's rhythm stays predictable whichever kind of artwork arrives.
31
+ * -----------------------------------------------------------------------------------------------*/
32
+
33
+ /**
34
+ * The size the design specifies for a page-scope illustration, shared by every
35
+ * block that draws one — `ProgressState` and `EmptyState` at page scope — so the
36
+ * artwork never resizes as one of those screens becomes the other.
37
+ *
38
+ * The artwork is the title's companion, not the subject of the screen: much
39
+ * larger and it outweighs the 24px heading under it, and the eye lands on the
40
+ * drawing instead of the words that say what to do next.
41
+ */
42
+ const BLOCK_ILLUSTRATION_SIZE = 130;
43
+
44
+ /**
45
+ * Props for the internal BlockIllustration wrapper.
46
+ */
47
+ interface BlockIllustrationProps {
48
+ /** The illustration element, exactly as the consumer passed it. */
49
+ children: React.ReactNode;
50
+ /** Rendered width and height in pixels. */
51
+ size: number;
52
+ /** The owning block's slot name, e.g. `"empty-screen-illustration"`. */
53
+ slot: string;
54
+ }
55
+
56
+ /**
57
+ * Renders a consumer-supplied illustration at the block's own size.
58
+ */
59
+ function BlockIllustration({ children, size, slot }: BlockIllustrationProps) {
60
+ /* Override whatever the caller set — including nothing, which is the
61
+ illustration's own 250. Merging leaves their other props (aria-hidden,
62
+ className) intact.
63
+
64
+ Only a plain function component gets the prop, and that is deliberately
65
+ narrow: those are the 109 SVG illustrations that declare `size`. A
66
+ `forwardRef` illustration (the two `<img>` ones) has an object type and so
67
+ falls through, which is what we want — `size` is not in its API and would
68
+ land on the `<img>` as an invalid attribute. A host element or a fragment
69
+ falls through for the same reason. Those are handled by the box below. */
70
+ const sized =
71
+ React.isValidElement(children) && typeof children.type === "function"
72
+ ? React.cloneElement(children as React.ReactElement<{ size?: number }>, {
73
+ size,
74
+ })
75
+ : children;
76
+
77
+ return (
78
+ <div
79
+ className="flex shrink-0 items-center justify-center [&>*]:h-auto [&>*]:max-h-full [&>*]:max-w-full"
80
+ data-slot={slot}
81
+ style={{ width: size, height: size }}
82
+ >
83
+ {sized}
84
+ </div>
85
+ );
86
+ }
87
+
88
+ export { BlockIllustration, BLOCK_ILLUSTRATION_SIZE };
@@ -0,0 +1,128 @@
1
+ import * as React from "react";
2
+
3
+ import { cn } from "@brightlocal/ui-components/lib/utils";
4
+ import { TypographyText } from "../components/typography-text";
5
+
6
+ /* -------------------------------------------------------------------------------------------------
7
+ * EmptyCanvas (internal)
8
+ *
9
+ * The shared body of the canvas-empty family — `ChartEmpty`, `MapEmpty` and
10
+ * `MediaEmpty`. A muted surface filling the box the consumer reserved, one bare
11
+ * glyph, one quiet line. No title, no CTA, and no circle chip, because a circle
12
+ * on a flat surface reads as a button.
13
+ *
14
+ * It is deliberately NOT `EmptyState` with most of its parts switched off. A
15
+ * canvas shares only the muted vocabulary with the standard block, not its
16
+ * anatomy — and `EmptyState` is a block that composes typography and actions,
17
+ * while these three are primitives. Borrowing the block here would point a
18
+ * primitive at a block and invert the layering.
19
+ *
20
+ * Internal, so it lives in `lib/` rather than `components/`: the package's
21
+ * `"./*"` export maps every file in `components/` to a public entry point, and
22
+ * this is not one.
23
+ * -----------------------------------------------------------------------------------------------*/
24
+
25
+ /**
26
+ * The glyph is one size, everywhere: 32.
27
+ *
28
+ * It does not scale with the box, and there is no size step either. A canvas
29
+ * empty is one treatment, so it reads the same on a metric card's plot, a map
30
+ * well and a photo slot — and every box these land in is a real content box,
31
+ * where 32 is right. A step existed briefly for a 1200px mockup-filler frame
32
+ * that no longer exists; three variants of one treatment were noise.
33
+ */
34
+ const CANVAS_ICON_SIZE = 32;
35
+
36
+ /**
37
+ * Props for the internal EmptyCanvas body.
38
+ */
39
+ interface EmptyCanvasProps extends Omit<
40
+ React.ComponentPropsWithoutRef<"div">,
41
+ "children" | "title"
42
+ > {
43
+ /** Required data-hook; the parts derive `-icon` and `-message` from it. */
44
+ dataHook: string;
45
+ /**
46
+ * The decorative glyph. This component owns its size — whatever the element
47
+ * carries is overridden — so no call site has a number to get wrong.
48
+ */
49
+ icon: React.ReactNode;
50
+ /** The one line under the glyph. */
51
+ message: string;
52
+ /** The calling component's slot name, e.g. `"chart-empty"`. */
53
+ slot: string;
54
+ /** Tracking element identifier for analytics. */
55
+ trackingEl?: string;
56
+ /** Tracking label for analytics context. */
57
+ trackingLabel?: string;
58
+ }
59
+
60
+ /**
61
+ * Renders the muted canvas surface with its glyph and line.
62
+ */
63
+ const EmptyCanvas = React.forwardRef<HTMLDivElement, EmptyCanvasProps>(
64
+ (
65
+ {
66
+ className,
67
+ dataHook,
68
+ icon,
69
+ message,
70
+ slot,
71
+ trackingEl,
72
+ trackingLabel,
73
+ ...props
74
+ },
75
+ ref
76
+ ) => {
77
+ /* Override whatever size the element carries, including none. Only
78
+ component elements get the prop — DS icons (forwardRef) and any icon
79
+ component take `size` — while a host element (`<svg>`, `<img>`) or a
80
+ fragment would receive it as an invalid attribute, so those fall
81
+ through; the span's CSS below sizes a raw svg instead. */
82
+ const sized =
83
+ React.isValidElement(icon) &&
84
+ typeof icon.type !== "string" &&
85
+ icon.type !== React.Fragment
86
+ ? React.cloneElement(icon as React.ReactElement<{ size?: number }>, {
87
+ size: CANVAS_ICON_SIZE,
88
+ })
89
+ : icon;
90
+
91
+ return (
92
+ <div
93
+ ref={ref}
94
+ className={cn(
95
+ "bg-muted flex flex-col items-center justify-center gap-2 text-center",
96
+ className
97
+ )}
98
+ data-hook={dataHook}
99
+ data-slot={slot}
100
+ data-tracking-el={trackingEl ?? slot}
101
+ data-tracking-label={trackingLabel}
102
+ {...props}
103
+ >
104
+ <span
105
+ aria-hidden="true"
106
+ className="text-muted-foreground flex items-center justify-center [&_svg:not([class*='size-'])]:size-8"
107
+ data-hook={`${dataHook}-icon`}
108
+ data-slot={`${slot}-icon`}
109
+ >
110
+ {sized}
111
+ </span>
112
+ <TypographyText
113
+ align="center"
114
+ color="muted"
115
+ data-slot={`${slot}-message`}
116
+ dataHook={`${dataHook}-message`}
117
+ variant="body-sm"
118
+ >
119
+ {message}
120
+ </TypographyText>
121
+ </div>
122
+ );
123
+ }
124
+ );
125
+
126
+ EmptyCanvas.displayName = "EmptyCanvas";
127
+
128
+ export { EmptyCanvas };
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+
3
+ /* -------------------------------------------------------------------------------------------------
4
+ * OpticalCenter (internal)
5
+ *
6
+ * The one agreement every single-message screen shares: where "centred in the
7
+ * page body" actually is. Rendered as a fragment of two flexible spacers, so
8
+ * the OWNER of the element supplies the box (`flex flex-1 flex-col`) and this
9
+ * helper supplies only the ratio.
10
+ *
11
+ * Centred on the viewport, not on the container — hence 38/62 rather than
12
+ * 50/50. A block fills the page BODY, but the reader centres the whole window,
13
+ * and the page header above the body biases that by about half its height:
14
+ * centred in the body, the block's centre lands 22–45px below the window's
15
+ * across every realistic viewport (720–1080). Sitting 38% down cancels most of
16
+ * it — the offset falls to single digits at the 800–900px heights most people
17
+ * are on. Both spacers are flexible, so in a container with no room to spare
18
+ * they collapse together and the content simply centres rather than
19
+ * overflowing.
20
+ *
21
+ * Internal on purpose: everyone — consumers and the DS's own blocks alike —
22
+ * reaches this through `Grid variant="centered"`. The number must never be
23
+ * re-typed at a call site — that is the whole reason this file exists.
24
+ * -----------------------------------------------------------------------------------------------*/
25
+
26
+ interface OpticalCenterProps {
27
+ /** The content to hold at the optical centre. */
28
+ children: React.ReactNode;
29
+ }
30
+
31
+ /**
32
+ * Two flexible spacers in a 38/62 ratio around the children. The parent must
33
+ * be a `flex flex-1 flex-col` box for the ratio to have room to work.
34
+ */
35
+ function OpticalCenter({ children }: OpticalCenterProps) {
36
+ return (
37
+ <>
38
+ <div aria-hidden="true" className="flex-1" />
39
+ {children}
40
+ <div aria-hidden="true" className="flex-[1.6]" />
41
+ </>
42
+ );
43
+ }
44
+
45
+ export { OpticalCenter };
package/src/lib/utils.ts CHANGED
@@ -4,11 +4,37 @@ import { extendTailwindMerge } from "tailwind-merge";
4
4
  // The motion scale adds named duration/ease utilities (tailwind-preset.css)
5
5
  // that stock twMerge does not recognize — without registering them, a
6
6
  // consumer's `duration-300` would not replace a baked-in `duration-fast`.
7
+ // The semantic type scale (DS-714) must register as font-size classes:
8
+ // unknown `text-*` values are otherwise treated as text colours, so
9
+ // `cn("text-body", "text-foreground")` would drop the scale utility.
7
10
  const twMerge = extendTailwindMerge({
8
11
  extend: {
9
12
  classGroups: {
10
13
  duration: [{ duration: ["fast", "base", "slow"] }],
11
14
  ease: [{ ease: ["emphasized", "overshoot"] }],
15
+ // text-emphasis sets font-weight only, so it belongs to the font-weight
16
+ // group (conflicts with font-bold etc.), NOT font-size — and unregistered
17
+ // it would be treated as a text colour and clobber color utilities.
18
+ "font-weight": [{ text: ["emphasis"] }],
19
+ "font-size": [
20
+ {
21
+ text: [
22
+ "display",
23
+ "heading-page",
24
+ "heading-section",
25
+ "heading-subsection",
26
+ "heading-compact",
27
+ "body",
28
+ "body-sm",
29
+ "body-xs",
30
+ "label",
31
+ "label-sm",
32
+ "metric",
33
+ "code",
34
+ "code-inline",
35
+ ],
36
+ },
37
+ ],
12
38
  },
13
39
  },
14
40
  });