@mastra/playground-ui 69.0.0-alpha.5 → 69.0.0-alpha.7

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 (228) hide show
  1. package/README.md +12 -4
  2. package/components.css +2 -0
  3. package/dist/MarkdownRenderer.css +4 -2
  4. package/dist/{MetricsCard-pwQQISEa.cjs → MetricsCard-CrIFHYqU.cjs} +4 -4
  5. package/dist/MetricsCard-CrIFHYqU.cjs.map +1 -0
  6. package/dist/{MetricsCard-CjRMuW3D.js → MetricsCard-DCpENWoD.js} +4 -4
  7. package/dist/MetricsCard-DCpENWoD.js.map +1 -0
  8. package/dist/{MetricsCardGroup-C1UrcquB.js → MetricsCardGroup-CxvEpv7U.js} +2 -2
  9. package/dist/MetricsCardGroup-CxvEpv7U.js.map +1 -0
  10. package/dist/{MetricsCardGroup-JRNIwLDb.cjs → MetricsCardGroup-DRSzsF4g.cjs} +2 -2
  11. package/dist/MetricsCardGroup-DRSzsF4g.cjs.map +1 -0
  12. package/dist/{MetricsTable-DIjbD5Xk.js → MetricsTable-BseaftQ7.js} +2 -2
  13. package/dist/{MetricsTable-DIjbD5Xk.js.map → MetricsTable-BseaftQ7.js.map} +1 -1
  14. package/dist/{MetricsTable-CvMoo2vg.cjs → MetricsTable-Il_NGyyE.cjs} +2 -2
  15. package/dist/{MetricsTable-CvMoo2vg.cjs.map → MetricsTable-Il_NGyyE.cjs.map} +1 -1
  16. package/dist/{ShareBar-KrzzdcyI.js → ShareBar-BFrVOIxb.js} +2 -2
  17. package/dist/ShareBar-BFrVOIxb.js.map +1 -0
  18. package/dist/{ShareBar-DERy_egz.cjs → ShareBar-IXcm8TuK.cjs} +2 -2
  19. package/dist/ShareBar-IXcm8TuK.cjs.map +1 -0
  20. package/dist/{activity-BFk77HxX.js → activity-CKGv-H4N.js} +2 -2
  21. package/dist/{activity-BFk77HxX.js.map → activity-CKGv-H4N.js.map} +1 -1
  22. package/dist/{activity-CSzzlpz0.cjs → activity-D196tpZk.cjs} +2 -2
  23. package/dist/{activity-CSzzlpz0.cjs.map → activity-D196tpZk.cjs.map} +1 -1
  24. package/dist/components/DateTimePicker.cjs.js +1 -1
  25. package/dist/components/DateTimePicker.cjs.js.map +1 -1
  26. package/dist/components/DateTimePicker.es.js +1 -1
  27. package/dist/components/DateTimePicker.es.js.map +1 -1
  28. package/dist/components/Kbd.cjs.js.map +1 -1
  29. package/dist/components/Kbd.es.js.map +1 -1
  30. package/dist/components/MetricsCard.cjs.js +1 -1
  31. package/dist/components/MetricsCard.es.js +1 -1
  32. package/dist/components/MetricsCardGroup.cjs.js +1 -1
  33. package/dist/components/MetricsCardGroup.es.js +1 -1
  34. package/dist/components/MetricsTable.cjs.js +1 -1
  35. package/dist/components/MetricsTable.es.js +1 -1
  36. package/dist/components/ShareBar.cjs.js +1 -1
  37. package/dist/components/ShareBar.es.js +1 -1
  38. package/dist/components/Sidebar.cjs.js +60 -19
  39. package/dist/components/Sidebar.cjs.js.map +1 -1
  40. package/dist/components/Sidebar.es.js +61 -21
  41. package/dist/components/Sidebar.es.js.map +1 -1
  42. package/dist/components/Steps.cjs.js +2 -2
  43. package/dist/components/Steps.cjs.js.map +1 -1
  44. package/dist/components/Steps.es.js +2 -2
  45. package/dist/components/Steps.es.js.map +1 -1
  46. package/dist/components/ai/activity.cjs.js +1 -1
  47. package/dist/components/ai/activity.es.js +1 -1
  48. package/dist/components/ai/tool-approval.cjs.js +1 -1
  49. package/dist/components/ai/tool-approval.es.js +1 -1
  50. package/dist/components/ai/tool-call.cjs.js +1 -1
  51. package/dist/components/ai/tool-call.es.js +1 -1
  52. package/dist/domains/chat/activity/activity-stretch-line.cjs.js +1 -1
  53. package/dist/domains/chat/activity/activity-stretch-line.es.js +1 -1
  54. package/dist/domains/chat/activity/components/activity-fold.cjs.js +3 -3
  55. package/dist/domains/chat/activity/components/activity-fold.cjs.js.map +1 -1
  56. package/dist/domains/chat/activity/components/activity-fold.es.js +3 -3
  57. package/dist/domains/chat/activity/components/activity-fold.es.js.map +1 -1
  58. package/dist/domains/chat/activity/components/calls-panel.cjs.js +1 -1
  59. package/dist/domains/chat/activity/components/calls-panel.es.js +1 -1
  60. package/dist/domains/chat/activity/components/stretch-content.cjs.js +1 -1
  61. package/dist/domains/chat/activity/components/stretch-content.es.js +1 -1
  62. package/dist/domains/chat/activity/components/stretch-thought.cjs.js +1 -1
  63. package/dist/domains/chat/activity/components/stretch-thought.es.js +1 -1
  64. package/dist/domains/chat/activity/model/activity-segments.cjs.js +1 -1
  65. package/dist/domains/chat/activity/model/activity-segments.es.js +1 -1
  66. package/dist/domains/chat/activity/model/activity-words.cjs.js +1 -1
  67. package/dist/domains/chat/activity/model/activity-words.es.js +1 -1
  68. package/dist/domains/chat/components/badge-wrapper.cjs.js +1 -1
  69. package/dist/domains/chat/components/badge-wrapper.es.js +1 -1
  70. package/dist/domains/chat/knowledge/pinned-knowledge.cjs.js +1 -1
  71. package/dist/domains/chat/knowledge/pinned-knowledge.es.js +1 -1
  72. package/dist/domains/chat/messages/message-row.cjs.js +2 -2
  73. package/dist/domains/chat/messages/message-row.es.js +2 -2
  74. package/dist/domains/chat/messages/notification-signal-notice.cjs.js +1 -1
  75. package/dist/domains/chat/messages/notification-signal-notice.es.js +1 -1
  76. package/dist/domains/chat/messages/reasoning-content.cjs.js +1 -1
  77. package/dist/domains/chat/messages/reasoning-content.es.js +1 -1
  78. package/dist/domains/chat/messages/renderers/reasoning-part-renderer.cjs.js +1 -1
  79. package/dist/domains/chat/messages/renderers/reasoning-part-renderer.es.js +1 -1
  80. package/dist/domains/chat/messages/signal-badge.cjs.js +1 -1
  81. package/dist/domains/chat/messages/signal-badge.es.js +1 -1
  82. package/dist/domains/chat/messages/skill-activation.cjs.js +15 -15
  83. package/dist/domains/chat/messages/skill-activation.cjs.js.map +1 -1
  84. package/dist/domains/chat/messages/skill-activation.es.js +15 -15
  85. package/dist/domains/chat/messages/skill-activation.es.js.map +1 -1
  86. package/dist/domains/chat/messages/skill-message.cjs.js +5 -5
  87. package/dist/domains/chat/messages/skill-message.cjs.js.map +1 -1
  88. package/dist/domains/chat/messages/skill-message.es.js +5 -5
  89. package/dist/domains/chat/messages/skill-message.es.js.map +1 -1
  90. package/dist/domains/chat/messages/system-reminder-badge.cjs.js +1 -1
  91. package/dist/domains/chat/messages/system-reminder-badge.es.js +1 -1
  92. package/dist/domains/chat/tools/badges/agent-badge-wrapper.cjs.js +1 -1
  93. package/dist/domains/chat/tools/badges/agent-badge-wrapper.es.js +1 -1
  94. package/dist/domains/chat/tools/badges/agent-badge.cjs.js +1 -1
  95. package/dist/domains/chat/tools/badges/agent-badge.es.js +1 -1
  96. package/dist/domains/chat/tools/badges/file-tree-badge.cjs.js +1 -1
  97. package/dist/domains/chat/tools/badges/file-tree-badge.es.js +1 -1
  98. package/dist/domains/chat/tools/badges/knowledge-tool-badge.cjs.js +1 -1
  99. package/dist/domains/chat/tools/badges/knowledge-tool-badge.es.js +1 -1
  100. package/dist/domains/chat/tools/badges/observation-marker-badge.cjs.js +2 -2
  101. package/dist/domains/chat/tools/badges/observation-marker-badge.es.js +2 -2
  102. package/dist/domains/chat/tools/badges/observation-marker-details.cjs.js +1 -1
  103. package/dist/domains/chat/tools/badges/observation-marker-details.es.js +1 -1
  104. package/dist/domains/chat/tools/badges/sandbox-execution-badge.cjs.js +1 -1
  105. package/dist/domains/chat/tools/badges/sandbox-execution-badge.es.js +1 -1
  106. package/dist/domains/chat/tools/badges/tool-approval-badge.cjs.js +1 -1
  107. package/dist/domains/chat/tools/badges/tool-approval-badge.es.js +1 -1
  108. package/dist/domains/chat/tools/badges/tool-badge.cjs.js +1 -1
  109. package/dist/domains/chat/tools/badges/tool-badge.es.js +1 -1
  110. package/dist/domains/chat/tools/badges/workflow-badge.cjs.js +1 -1
  111. package/dist/domains/chat/tools/badges/workflow-badge.es.js +1 -1
  112. package/dist/domains/chat/tools/tool-card.cjs.js +1 -1
  113. package/dist/domains/chat/tools/tool-card.es.js +1 -1
  114. package/dist/domains/chat/tools/tool-groups.cjs.js +1 -1
  115. package/dist/domains/chat/tools/tool-groups.es.js +1 -1
  116. package/dist/domains/dashboards/components/dashboard-renderer.cjs.js +1 -1
  117. package/dist/domains/dashboards/components/dashboard-renderer.es.js +1 -1
  118. package/dist/domains/dashboards/components/widget-chrome.cjs.js +1 -1
  119. package/dist/domains/dashboards/components/widget-chrome.es.js +1 -1
  120. package/dist/domains/dashboards/components/widget-error.cjs.js +1 -1
  121. package/dist/domains/dashboards/components/widget-error.es.js +1 -1
  122. package/dist/domains/dashboards/kinds/kpis/kpis-widget.cjs.js +2 -2
  123. package/dist/domains/dashboards/kinds/kpis/kpis-widget.es.js +2 -2
  124. package/dist/domains/dashboards/kinds/table/table-tabs.cjs.js +1 -1
  125. package/dist/domains/dashboards/kinds/table/table-tabs.es.js +1 -1
  126. package/dist/domains/dashboards/kinds/table/table-view.cjs.js +1 -1
  127. package/dist/domains/dashboards/kinds/table/table-view.es.js +1 -1
  128. package/dist/domains/dashboards/kinds/table/table-widget.cjs.js +1 -1
  129. package/dist/domains/dashboards/kinds/table/table-widget.es.js +1 -1
  130. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js +1 -1
  131. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js +1 -1
  132. package/dist/domains/metrics/components/agent-runs-card.cjs.js +1 -1
  133. package/dist/domains/metrics/components/agent-runs-card.es.js +1 -1
  134. package/dist/domains/metrics/components/breakdown/breakdown-tab-body.cjs.js +1 -1
  135. package/dist/domains/metrics/components/breakdown/breakdown-tab-body.es.js +1 -1
  136. package/dist/domains/metrics/components/breakdown/breakdown-table.cjs.js +1 -1
  137. package/dist/domains/metrics/components/breakdown/breakdown-table.es.js +1 -1
  138. package/dist/domains/metrics/components/breakdown-card.cjs.js +1 -1
  139. package/dist/domains/metrics/components/breakdown-card.es.js +1 -1
  140. package/dist/domains/metrics/components/chart-card-error.cjs.js +1 -1
  141. package/dist/domains/metrics/components/chart-card-error.es.js +1 -1
  142. package/dist/domains/metrics/components/chart-card.cjs.js +2 -2
  143. package/dist/domains/metrics/components/chart-card.cjs.js.map +1 -1
  144. package/dist/domains/metrics/components/chart-card.es.js +2 -2
  145. package/dist/domains/metrics/components/chart-card.es.js.map +1 -1
  146. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js +1 -1
  147. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js +1 -1
  148. package/dist/domains/metrics/components/failure-rate-card.cjs.js +1 -1
  149. package/dist/domains/metrics/components/failure-rate-card.es.js +1 -1
  150. package/dist/domains/metrics/components/latency-card.cjs.js +1 -1
  151. package/dist/domains/metrics/components/latency-card.es.js +1 -1
  152. package/dist/domains/metrics/components/token-usage-card.cjs.js +1 -1
  153. package/dist/domains/metrics/components/token-usage-card.es.js +1 -1
  154. package/dist/domains/metrics/components/trace-aggregate-card.cjs.js +1 -1
  155. package/dist/domains/metrics/components/trace-aggregate-card.es.js +1 -1
  156. package/dist/domains/metrics/components/trace-volume-card.cjs.js +1 -1
  157. package/dist/domains/metrics/components/trace-volume-card.es.js +1 -1
  158. package/dist/domains/metrics/components/usage-card.cjs.js +1 -1
  159. package/dist/domains/metrics/components/usage-card.es.js +1 -1
  160. package/dist/domains/skills/skill-simple-form.cjs.js +39 -16
  161. package/dist/domains/skills/skill-simple-form.cjs.js.map +1 -1
  162. package/dist/domains/skills/skill-simple-form.es.js +39 -16
  163. package/dist/domains/skills/skill-simple-form.es.js.map +1 -1
  164. package/dist/domains/traces/components/span-payload/span-error-renderer.cjs.js +1 -1
  165. package/dist/domains/traces/components/span-payload/span-error-renderer.es.js +1 -1
  166. package/dist/domains/traces/components/span-payload/span-input-renderers.cjs.js +1 -1
  167. package/dist/domains/traces/components/span-payload/span-input-renderers.es.js +1 -1
  168. package/dist/domains/traces/components/span-payload/span-output-renderers.cjs.js +2 -2
  169. package/dist/domains/traces/components/span-payload/span-output-renderers.es.js +2 -2
  170. package/dist/domains/traces/components/span-payload/span-payload-messages.cjs.js +2 -2
  171. package/dist/domains/traces/components/span-payload/span-payload-messages.es.js +2 -2
  172. package/dist/domains/traces/components/span-payload/span-payload-primitives.cjs.js +1 -1
  173. package/dist/domains/traces/components/span-payload/span-payload-primitives.es.js +1 -1
  174. package/dist/domains/traces/components/span-payload/span-payload-processor.cjs.js +1 -1
  175. package/dist/domains/traces/components/span-payload/span-payload-processor.es.js +1 -1
  176. package/dist/domains/traces/components/span-payload/span-payload-tool.cjs.js +1 -1
  177. package/dist/domains/traces/components/span-payload/span-payload-tool.es.js +1 -1
  178. package/dist/domains/traces/components/span-payload/span-processor-mutations.cjs.js +1 -1
  179. package/dist/domains/traces/components/span-payload/span-processor-mutations.es.js +1 -1
  180. package/dist/domains/traces/components/span-payload/span-tools-section.cjs.js +1 -1
  181. package/dist/domains/traces/components/span-payload/span-tools-section.es.js +1 -1
  182. package/dist/domains/traces/components/trace-error-summary.cjs.js +2 -2
  183. package/dist/domains/traces/components/trace-error-summary.cjs.js.map +1 -1
  184. package/dist/domains/traces/components/trace-error-summary.es.js +2 -2
  185. package/dist/domains/traces/components/trace-error-summary.es.js.map +1 -1
  186. package/dist/{span-payload-primitives-DtNPyDuA.js → span-payload-primitives-BSdjyIm9.js} +2 -2
  187. package/dist/{span-payload-primitives-DtNPyDuA.js.map → span-payload-primitives-BSdjyIm9.js.map} +1 -1
  188. package/dist/{span-payload-primitives-BsPTaFi1.cjs → span-payload-primitives-TC2Qrujc.cjs} +2 -2
  189. package/dist/{span-payload-primitives-BsPTaFi1.cjs.map → span-payload-primitives-TC2Qrujc.cjs.map} +1 -1
  190. package/dist/src/domains/chat/messages/skill-activation.d.ts +5 -5
  191. package/dist/src/ds/components/Sidebar/index.d.ts +1 -1
  192. package/dist/src/ds/components/Sidebar/nav/sidebar-nav-item-classes.d.ts +1 -1
  193. package/dist/src/ds/components/Sidebar/nav/sidebar-nav-label.d.ts +7 -2
  194. package/dist/src/ds/components/Sidebar/nav/sidebar-nav-link.d.ts +9 -0
  195. package/dist/src/ds/components/Sidebar/nav-stack/sidebar-nav-stack-view.d.ts +3 -1
  196. package/dist/src/ds/components/Sidebar/sidebar.d.ts +2 -1
  197. package/dist/style.css +67 -31
  198. package/dist/{tool-approval-Ckgwz5wl.cjs → tool-approval-C3ru26D5.cjs} +3 -3
  199. package/dist/{tool-approval-Ckgwz5wl.cjs.map → tool-approval-C3ru26D5.cjs.map} +1 -1
  200. package/dist/{tool-approval-DHTi7xbQ.js → tool-approval-Dnzl9XAF.js} +3 -3
  201. package/dist/{tool-approval-DHTi7xbQ.js.map → tool-approval-Dnzl9XAF.js.map} +1 -1
  202. package/dist/{tool-call-D0-1XVLR.js → tool-call-C9ilwEcV.js} +2 -2
  203. package/dist/{tool-call-D0-1XVLR.js.map → tool-call-C9ilwEcV.js.map} +1 -1
  204. package/dist/{tool-call-bM7j6g8Y.cjs → tool-call-DNwA_s3L.cjs} +2 -2
  205. package/dist/{tool-call-bM7j6g8Y.cjs.map → tool-call-DNwA_s3L.cjs.map} +1 -1
  206. package/dist/{tool-card-D7WvTHyz.cjs → tool-card-DgPsO-en.cjs} +2 -2
  207. package/dist/{tool-card-D7WvTHyz.cjs.map → tool-card-DgPsO-en.cjs.map} +1 -1
  208. package/dist/{tool-card-D1ixMsiy.js → tool-card-MY96BEys.js} +2 -2
  209. package/dist/{tool-card-D1ixMsiy.js.map → tool-card-MY96BEys.js.map} +1 -1
  210. package/fonts/OFL-CommitMono.txt +90 -0
  211. package/fonts/OFL-MonaSans.txt +93 -0
  212. package/fonts/commit-mono-latin-400-normal.woff2 +0 -0
  213. package/fonts/commit-mono-latin-700-normal.woff2 +0 -0
  214. package/fonts/mona-sans-latin-ext-standard-italic.woff2 +0 -0
  215. package/fonts/mona-sans-latin-ext-standard-normal.woff2 +0 -0
  216. package/fonts/mona-sans-latin-standard-italic.woff2 +0 -0
  217. package/fonts/mona-sans-latin-standard-normal.woff2 +0 -0
  218. package/fonts/mona-sans-vietnamese-standard-italic.woff2 +0 -0
  219. package/fonts/mona-sans-vietnamese-standard-normal.woff2 +0 -0
  220. package/fonts.css +124 -0
  221. package/package.json +14 -11
  222. package/theme/typography.css +33 -24
  223. package/dist/MetricsCard-CjRMuW3D.js.map +0 -1
  224. package/dist/MetricsCard-pwQQISEa.cjs.map +0 -1
  225. package/dist/MetricsCardGroup-C1UrcquB.js.map +0 -1
  226. package/dist/MetricsCardGroup-JRNIwLDb.cjs.map +0 -1
  227. package/dist/ShareBar-DERy_egz.cjs.map +0 -1
  228. package/dist/ShareBar-KrzzdcyI.js.map +0 -1
package/README.md CHANGED
@@ -29,6 +29,12 @@ With a Tailwind build of your own, compile one sheet instead of `style.css`: imp
29
29
  @import '@mastra/playground-ui/sources.css';
30
30
  ```
31
31
 
32
+ To use Mastra's product fonts, Mona Sans for text and Commit Mono for code, add `fonts.css`. The font files ship inside the package as woff2, split by script so a page only downloads the characters it renders, and the stylesheet points the font tokens at them. Without it, text uses the system font stacks.
33
+
34
+ ```css
35
+ @import '@mastra/playground-ui/fonts.css';
36
+ ```
37
+
32
38
  ### Metadata
33
39
 
34
40
  Use separate elements for metadata fields. `Metadata` keeps a compact gap between fields, and `Metadata.Item` groups an icon with its label. Fields wrap as space narrows.
@@ -430,9 +436,11 @@ Foundations/Color has one story each for monochrome and chromatic ramps, semanti
430
436
 
431
437
  Text uses roles, not sizes. A role such as `body-sm` or `caption` sets size, line height, weight, and tracking together. Render text with `Txt`, or use the matching `text-<role>` utility inside a component's own markup.
432
438
 
439
+ Roles use two weights. Regular (`--font-weight-normal`, 465) is for anything read: `body`, `body-sm`, `caption`, `lead`, and `menu`. Strong (`--font-weight-medium`, 515) is for anything that labels or heads something: `label`, `column`, `eyebrow`, `meta`, and every heading role. Text without a role inherits regular. `font-normal` and `font-medium` resolve to the same two weights, so inline emphasis such as a highlighted name in a sentence stays on the scale. Before adding `font-medium` to a role, check whether another role already pairs that size with the strong weight: `text-body font-medium` is `subheading`, and `text-body-sm font-medium` is `label`.
440
+
433
441
  Shared components own their typography. Use their existing size and semantic variant APIs, and let compound slots style direct children through inheritance. Use `Txt` for text that the call site owns. Do not add a generic text-role prop or wrap arbitrary children just to migrate a CSS class. A specialized surface can use the existing `className` escape hatch with a DS role when the component's defaults do not fit.
434
442
 
435
- Floating menu rows, values, and search fields use `menu`: 13px text at weight 450 with a 20px line height and −0.01em tracking. DropdownMenu, ContextMenu, Select, and Combobox share this role; their triggers keep the button label role. Labels use the muted foreground tone, with lighter icons. Hover, keyboard highlight, and open submenus increase the contrast of both labels and icons together.
443
+ Floating menu rows, values, and search fields use `menu`: 13px text at the regular weight with a 20px line height and −0.01em tracking. DropdownMenu, ContextMenu, Select, and Combobox share this role; their triggers keep the button label role. Labels use the muted foreground tone, with lighter icons. Hover, keyboard highlight, and open submenus increase the contrast of both labels and icons together.
436
444
 
437
445
  `hero` and `lead` share the responsive typography of welcome pages. `eyebrow` supplies the size, weight, tracking, and uppercase treatment of section labels. Use `font="display"` when the display family is needed independently of the role.
438
446
 
@@ -481,7 +489,7 @@ Card titles use 13px text with a 150% line height. Choose the complete role rath
481
489
  </Txt>
482
490
  ```
483
491
 
484
- These roles preserve the existing Factory card typography. Control labels remain `label` at 500 weight.
492
+ These roles preserve the existing Factory card typography. Control labels remain `label` at the strong weight.
485
493
 
486
494
  #### Monospace
487
495
 
@@ -507,9 +515,9 @@ Mono pairs with the text roles: `body` for logs, `body-sm` for values in tables
507
515
 
508
516
  Product code never writes the `font-mono` class, and lint rejects it outside the design system. Use `Txt font="mono"` for identifiers, timestamps, and durations, `InlineCode` or `CodeBlock` for code, and `tabular-nums` for numbers. A raw `<pre>` or `<code>` element is already monospace.
509
517
 
510
- `--font-mono` defaults to the system monospace stack. Override it in an unlayered rule in your own CSS to use a product face, and every mono value follows.
518
+ `--font-mono` defaults to the system monospace stack, and `fonts.css` points it at Commit Mono. To use another face, override it in an unlayered rule in your own CSS, and every mono value follows.
511
519
 
512
- At the same font size, a monospace face usually looks larger than the body face because its lowercase letters are taller. Set `--font-mono-size-adjust` to the body face's x-height ratio and mono text scales to match it. Measure the ratio for your body face; `0.508` is Mona Sans. Keycaps (`kbd`) keep their full size, because they are single capitals and x-height matching would only shrink them.
520
+ At the same font size, a monospace face usually looks larger than the body face because its lowercase letters are taller. Set `--font-mono-size-adjust` to the body face's x-height ratio and mono text scales to match it. Measure the ratio for your body face; `fonts.css` sets `0.508` for Mona Sans. Keycaps (`kbd`) keep their full size, because they are single capitals and x-height matching would only shrink them.
513
521
 
514
522
  ```css
515
523
  :root {
package/components.css CHANGED
@@ -231,6 +231,8 @@
231
231
  body {
232
232
  background-color: var(--sidebar);
233
233
  color: var(--foreground);
234
+ /* Text without a role inherits the regular weight instead of the browser's 400. */
235
+ font-weight: var(--font-weight-normal);
234
236
  -webkit-font-smoothing: antialiased;
235
237
  -moz-osx-font-smoothing: grayscale;
236
238
  }
@@ -33,7 +33,7 @@
33
33
  .mastra-markdown :is(h1, h2, h3, h4, h5, h6) {
34
34
  margin: 1.6em 0 0.6em;
35
35
  color: var(--foreground);
36
- font-weight: 500;
36
+ font-weight: var(--font-weight-medium);
37
37
  letter-spacing: -0.012em;
38
38
  line-height: 1.35;
39
39
  }
@@ -54,9 +54,11 @@
54
54
  font-size: 1em;
55
55
  }
56
56
 
57
+ /* Markdown has one bold. Inside prose it has no size or colour change to lean on, so it
58
+ needs a bigger step than the strong weight (515) gives over regular text (465). */
57
59
  .mastra-markdown strong {
58
60
  color: var(--foreground);
59
- font-weight: 500;
61
+ font-weight: 550;
60
62
  }
61
63
 
62
64
  .mastra-markdown em {
@@ -110,7 +110,7 @@ function MetricsCardRoot({ children, className }) {
110
110
  // src/ds/components/MetricsCard/metrics-card-title.tsx
111
111
  function MetricsCardTitle({ children, className, as: Tag = "h3" }) {
112
112
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {
113
- className: require_utils.cn("text-body font-medium text-foreground", className),
113
+ className: require_utils.cn("text-subheading text-foreground", className),
114
114
  children
115
115
  });
116
116
  }
@@ -130,7 +130,7 @@ function MetricsCardTitleMenu({ title, value, onValueChange, options, className
130
130
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_dropdown_menu.DropdownMenu.Trigger, {
131
131
  render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
132
132
  type: "button",
133
- className: require_utils.cn("-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-body font-medium text-foreground hover:bg-fill-subtle", className)
133
+ className: require_utils.cn("-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-subheading text-foreground hover:bg-fill-subtle", className)
134
134
  }),
135
135
  children: [title, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, { className: "size-3.5 text-muted-foreground" })]
136
136
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dropdown_menu.DropdownMenu.Content, {
@@ -174,7 +174,7 @@ function MetricsCardTopBar({ children, className }) {
174
174
  */
175
175
  function MetricsCardTotal({ value, isLoading = false, className }) {
176
176
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
177
- className: require_utils.cn("order-last shrink-0 text-body font-medium text-foreground tabular-nums", className),
177
+ className: require_utils.cn("order-last shrink-0 text-subheading text-foreground tabular-nums", className),
178
178
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TotalValue, {
179
179
  value,
180
180
  isLoading
@@ -230,4 +230,4 @@ Object.defineProperty(exports, "MetricsCard", {
230
230
  }
231
231
  });
232
232
 
233
- //# sourceMappingURL=MetricsCard-pwQQISEa.cjs.map
233
+ //# sourceMappingURL=MetricsCard-CrIFHYqU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCard-CrIFHYqU.cjs","names":["cn","cn","Button","cn","GripVerticalIcon","cn","Txt","cn","_Fragment","Skeleton","cn","Spinner","cn","Txt","Card","cn","cn","DropdownMenu","cn","ChevronDownIcon","cn","cn","cn","SkeletonText","MetricsKpiCard"],"sources":["../src/ds/components/MetricsCard/metrics-card-actions.tsx","../src/ds/components/MetricsCard/metrics-card-content.tsx","../src/ds/components/MetricsCard/metrics-card-drag-handle.tsx","../src/ds/components/MetricsCard/metrics-card-error.tsx","../src/ds/components/MetricsCard/metrics-card-headline.tsx","../src/ds/components/MetricsCard/metrics-card-loading.tsx","../src/ds/components/MetricsCard/metrics-card-no-data.tsx","../src/ds/components/MetricsCard/metrics-card-root.tsx","../src/ds/components/MetricsCard/metrics-card-title.tsx","../src/ds/components/MetricsCard/metrics-card-title-menu.tsx","../src/ds/components/MetricsCard/metrics-card-toolbar.tsx","../src/ds/components/MetricsCard/metrics-card-top-bar.tsx","../src/ds/components/MetricsCard/metrics-card-total.tsx","../src/ds/components/MetricsCard/metrics-card.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/** Container for icon buttons / small actions in the top bar of a MetricsCard,\n * placed between the title and `Total` (which always renders last). Small (28px) buttons sit\n * centered on the 20px title line without making the top bar taller. */\nexport function MetricsCardActions({\n children,\n reveal = 'always',\n className,\n}: {\n children: ReactNode;\n /**\n * `hover`: the actions appear while the card is hovered or one of them has focus, so a page\n * of cards doesn't read as a page of buttons.\n */\n reveal?: 'always' | 'hover';\n className?: string;\n}) {\n return (\n <div\n className={cn(\n '-my-1 flex shrink-0 items-center gap-1 self-start',\n reveal === 'hover' &&\n 'opacity-0 transition-opacity duration-150 group-hover/metrics-card:opacity-100 focus-within:opacity-100 has-data-popup-open:opacity-100',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * Scrolls sideways only (wide tables). Vertical overflow is hidden: a chart filling a card with a\n * fractional height rounds 1px past it, which otherwise turns the content into a scroll box.\n * Tables inside a card drop the last row's border: the card edge already closes them.\n */\nexport function MetricsCardContent({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('overflow-x-auto overflow-y-hidden [&_tbody>tr:last-child]:border-b-0', className)}>\n {children}\n </div>\n );\n}\n","import { GripVerticalIcon } from 'lucide-react';\nimport type { DragEventHandler } from 'react';\nimport { Button } from '@/ds/components/Button';\nimport { cn } from '@/lib/utils';\n\n/** What a host's layout hands a card so it can be dragged, e.g. to rearrange a dashboard. */\nexport type MetricsCardDragHandleProps = {\n /** What dragging does, e.g. \"Move widget\". */\n 'aria-label': string;\n draggable?: boolean;\n onDragStart?: DragEventHandler<HTMLElement>;\n onDragEnd?: DragEventHandler<HTMLElement>;\n className?: string;\n};\n\n/** The grip a card is dragged by, left of its title. Its negative margin keeps the top bar's height. */\nexport function MetricsCardDragHandle({ className, ...props }: MetricsCardDragHandleProps) {\n return (\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className={cn('-my-1 shrink-0 cursor-grab active:cursor-grabbing', className)}\n {...props}\n >\n <GripVerticalIcon />\n </Button>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardError({\n message = 'Failed to load data',\n className,\n}: {\n message?: string;\n className?: string;\n}) {\n return (\n <div className={cn('flex flex-col items-center justify-center gap-3', className)}>\n <Txt variant=\"caption\" className=\"text-destructive-foreground\">\n {message}\n </Txt>\n </div>\n );\n}\n","import { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * The header of a card with one large chart (an explorer, a detail page): the label over a large\n * value, the change against the previous period beside it. Cards in a grid use the compact title\n * and `MetricsCard.Total` instead. A skeleton while loading, at the value's own trimmed height.\n */\nexport function MetricsCardHeadline({\n label,\n value,\n change,\n isLoading = false,\n className,\n}: {\n label: string;\n value: string;\n /** E.g. \"+71.4%\"; shown as \"+71.4% vs previous\". */\n change?: string;\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <div className={cn('grid gap-1.5', className)}>\n <h3 className=\"text-body-sm text-muted-foreground\">{label}</h3>\n <span className=\"flex items-baseline gap-2\">\n <span\n className={cn(\n 'text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]',\n isLoading && 'relative min-w-24',\n )}\n >\n {isLoading ? (\n // Hidden text keeps the value's trimmed height, so the row (and the actions centred on\n // it) doesn't move when the value arrives; the bar covers it.\n <>\n <span className=\"invisible\">0</span>\n <Skeleton className=\"absolute inset-0\" />\n </>\n ) : (\n value\n )}\n </span>\n {!isLoading &&\n change && (\n // Trimmed like the value, so its line box doesn't make the row taller than while loading.\n <span className=\"text-body-sm text-muted-foreground tabular-nums [text-box:trim-both_cap_alphabetic]\">\n {change} vs previous\n </span>\n )}\n </span>\n </div>\n );\n}\n","import { Spinner } from '@/ds/components/Spinner/spinner';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardLoading({ className }: { className?: string }) {\n return (\n <div className={cn('flex items-center justify-center', className)}>\n <Spinner size=\"md\" variant=\"pulse\" className=\"text-placeholder\" />\n </div>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardNoData({ message = 'No data yet', className }: { message?: string; className?: string }) {\n return (\n <div className={cn('flex h-full items-center justify-center', className)}>\n <Txt tone=\"faint\">{message}</Txt>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Card } from '@/ds/components/Card';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardRoot({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <Card\n className={cn(\n 'group/metrics-card grid min-h-72 min-w-80 flex-1 grid-rows-[auto_1fr] gap-4 px-4 py-3 2xl:min-w-120 md:min-w-88 lg:min-w-sm xl:min-w-104',\n className,\n )}\n >\n {children}\n </Card>\n );\n}\n","import { cn } from '@/lib/utils';\n\nexport function MetricsCardTitle({\n children,\n className,\n as: Tag = 'h3',\n}: {\n children: string;\n className?: string;\n as?: 'h2' | 'h3' | 'h4';\n}) {\n return <Tag className={cn('text-subheading text-foreground', className)}>{children}</Tag>;\n}\n","import { ChevronDownIcon } from 'lucide-react';\nimport { DropdownMenu } from '@/ds/components/DropdownMenu';\nimport type { DropdownMenuRadioOption } from '@/ds/components/DropdownMenu';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsCardTitleMenuProps<V extends string> = {\n /** The card title for the picked view (e.g. \"Spend by model\"). */\n title: string;\n value: V;\n onValueChange: (value: V) => void;\n /** The views (e.g. \"By model\", \"By provider\"). */\n options: readonly DropdownMenuRadioOption<V>[];\n className?: string;\n};\n\n/**\n * A card title that switches the card's view, as on Vercel's usage cards: the title is the\n * trigger, with a chevron. The hover fill bleeds past the text so the title stays aligned.\n * Wrapped, so the top bar stretches the wrapper rather than the button, and the menu's open-state\n * nodes next to the trigger don't become the top bar's first child. Not modal: the card's actions\n * (pin, alert) stay shown while it's open, so they stay clickable too.\n */\nexport function MetricsCardTitleMenu<V extends string>({\n title,\n value,\n onValueChange,\n options,\n className,\n}: MetricsCardTitleMenuProps<V>) {\n return (\n <div className=\"flex min-w-0\">\n <DropdownMenu modal={false}>\n <DropdownMenu.Trigger\n render={\n <button\n type=\"button\"\n className={cn(\n '-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-subheading text-foreground hover:bg-fill-subtle',\n className,\n )}\n />\n }\n >\n {title}\n <ChevronDownIcon className=\"size-3.5 text-muted-foreground\" />\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"start\">\n <DropdownMenu.RadioOptions options={options} value={value} onValueChange={onValueChange} closeOnSelect />\n </DropdownMenu.Content>\n </DropdownMenu>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * One row under the top bar for a card's controls: a legend, list column headers.\n * The first child sits on the left, the last on the right; either side may be omitted. When\n * both don't fit (a narrow card), the right side wraps to its own line, still on the right. At least 24px\n * tall, so toolbars line up across cards in the same row.\n */\nexport function MetricsCardToolbar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div\n className={cn(\n 'flex min-h-6 min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 [&>*:first-child]:min-w-0 [&>*:last-child:not(:first-child)]:ml-auto',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardTopBar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('flex items-start gap-4 [&>:first-child]:min-w-0 [&>:first-child]:flex-1', className)}>\n {children}\n </div>\n );\n}\n","import { SkeletonText } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/** One of several totals in a card that charts a few series, marked with its series' color. */\nexport type MetricsCardTotalPart = { label: string; value: string; color: string };\n\n/**\n * A card's total, right of the title in the same type (14px, medium). Always the top\n * bar's last item. A skeleton while loading, in the value's own line box. A card charting a\n * few series of different things (resources, threads) can give one total each, each after a\n * marker in its series' color, like the legend.\n */\nexport function MetricsCardTotal({\n value,\n isLoading = false,\n className,\n}: {\n value: string | readonly MetricsCardTotalPart[];\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <span className={cn('order-last shrink-0 text-subheading text-foreground tabular-nums', className)}>\n <TotalValue value={value} isLoading={isLoading} />\n </span>\n );\n}\n\nfunction TotalValue({ value, isLoading }: { value: string | readonly MetricsCardTotalPart[]; isLoading: boolean }) {\n if (isLoading) return <SkeletonText line=\"text-body\" className=\"h-4 w-14\" />;\n if (typeof value === 'string') return value;\n return (\n <span className=\"inline-flex items-center gap-3\">\n {value.map(part => (\n <span key={part.label} className=\"inline-flex items-center gap-1.5\">\n <span aria-hidden className=\"size-2 shrink-0 rounded-[2px]\" style={{ backgroundColor: part.color }} />\n {/* The marker is decorative; screen readers hear which total this is. */}\n <span className=\"sr-only\">{part.label} </span>\n {part.value}\n </span>\n ))}\n </span>\n );\n}\n","import { MetricsCardActions } from './metrics-card-actions';\nimport { MetricsCardContent } from './metrics-card-content';\nimport { MetricsCardDragHandle } from './metrics-card-drag-handle';\nimport { MetricsCardError } from './metrics-card-error';\nimport { MetricsCardHeadline } from './metrics-card-headline';\nimport { MetricsCardLoading } from './metrics-card-loading';\nimport { MetricsCardNoData } from './metrics-card-no-data';\nimport { MetricsCardRoot } from './metrics-card-root';\nimport { MetricsCardTitle } from './metrics-card-title';\nimport { MetricsCardTitleMenu } from './metrics-card-title-menu';\nimport { MetricsCardToolbar } from './metrics-card-toolbar';\nimport { MetricsCardTopBar } from './metrics-card-top-bar';\nimport { MetricsCardTotal } from './metrics-card-total';\nimport { MetricsKpiCard } from '@/ds/components/MetricsKpiCard';\n\nexport const MetricsCard = Object.assign(MetricsCardRoot, {\n Root: MetricsCardRoot,\n Kpi: MetricsKpiCard,\n TopBar: MetricsCardTopBar,\n Toolbar: MetricsCardToolbar,\n Actions: MetricsCardActions,\n DragHandle: MetricsCardDragHandle,\n Title: MetricsCardTitle,\n TitleMenu: MetricsCardTitleMenu,\n Total: MetricsCardTotal,\n Headline: MetricsCardHeadline,\n Loading: MetricsCardLoading,\n Error: MetricsCardError,\n Content: MetricsCardContent,\n NoData: MetricsCardNoData,\n});\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,mBAAmB,EACjC,UACA,SAAS,UACT,aASC;CACD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAWA,cAAAA,GACT,qDACA,WAAW,WACT,2IACF,SACF;EAEC;CACE,CAAA;AAET;;;;;;;ACvBA,SAAgB,mBAAmB,EAAE,UAAU,aAA0D;CACvG,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAWC,cAAAA,GAAG,wEAAwE,SAAS;EACjG;CACE,CAAA;AAET;;;ACEA,SAAgB,sBAAsB,EAAE,WAAW,GAAG,SAAqC;CACzF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,QAAD;EACE,SAAQ;EACR,MAAK;EACL,WAAWC,cAAAA,GAAG,qDAAqD,SAAS;EAC5E,GAAI;EAEJ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,kBAAD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KAAA,CAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAA2B,KAAK,OAAM,GAAO;;IAC5C,KAAK;GACF;EALK,GAAA,KAAK,KAKV,CACP;CACG,CAAA;AAEV;;AC5BA,IAAa,cAAc,OAAO,OAAO,iBAAiB;CACxD,MAAM;CACN,KAAKC,uBAAAA;CACL,QAAQ;CACR,SAAS;CACT,SAAS;CACT,YAAY;CACZ,OAAO;CACP,WAAW;CACX,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;AACV,CAAC"}
@@ -110,7 +110,7 @@ function MetricsCardRoot({ children, className }) {
110
110
  // src/ds/components/MetricsCard/metrics-card-title.tsx
111
111
  function MetricsCardTitle({ children, className, as: Tag = "h3" }) {
112
112
  return /* @__PURE__ */ jsx(Tag, {
113
- className: cn("text-body font-medium text-foreground", className),
113
+ className: cn("text-subheading text-foreground", className),
114
114
  children
115
115
  });
116
116
  }
@@ -130,7 +130,7 @@ function MetricsCardTitleMenu({ title, value, onValueChange, options, className
130
130
  children: [/* @__PURE__ */ jsxs(DropdownMenu.Trigger, {
131
131
  render: /* @__PURE__ */ jsx("button", {
132
132
  type: "button",
133
- className: cn("-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-body font-medium text-foreground hover:bg-fill-subtle", className)
133
+ className: cn("-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-subheading text-foreground hover:bg-fill-subtle", className)
134
134
  }),
135
135
  children: [title, /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-3.5 text-muted-foreground" })]
136
136
  }), /* @__PURE__ */ jsx(DropdownMenu.Content, {
@@ -174,7 +174,7 @@ function MetricsCardTopBar({ children, className }) {
174
174
  */
175
175
  function MetricsCardTotal({ value, isLoading = false, className }) {
176
176
  return /* @__PURE__ */ jsx("span", {
177
- className: cn("order-last shrink-0 text-body font-medium text-foreground tabular-nums", className),
177
+ className: cn("order-last shrink-0 text-subheading text-foreground tabular-nums", className),
178
178
  children: /* @__PURE__ */ jsx(TotalValue, {
179
179
  value,
180
180
  isLoading
@@ -225,4 +225,4 @@ var MetricsCard = Object.assign(MetricsCardRoot, {
225
225
  });
226
226
  export { MetricsCard as t };
227
227
 
228
- //# sourceMappingURL=MetricsCard-CjRMuW3D.js.map
228
+ //# sourceMappingURL=MetricsCard-DCpENWoD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCard-DCpENWoD.js","names":["_Fragment"],"sources":["../src/ds/components/MetricsCard/metrics-card-actions.tsx","../src/ds/components/MetricsCard/metrics-card-content.tsx","../src/ds/components/MetricsCard/metrics-card-drag-handle.tsx","../src/ds/components/MetricsCard/metrics-card-error.tsx","../src/ds/components/MetricsCard/metrics-card-headline.tsx","../src/ds/components/MetricsCard/metrics-card-loading.tsx","../src/ds/components/MetricsCard/metrics-card-no-data.tsx","../src/ds/components/MetricsCard/metrics-card-root.tsx","../src/ds/components/MetricsCard/metrics-card-title.tsx","../src/ds/components/MetricsCard/metrics-card-title-menu.tsx","../src/ds/components/MetricsCard/metrics-card-toolbar.tsx","../src/ds/components/MetricsCard/metrics-card-top-bar.tsx","../src/ds/components/MetricsCard/metrics-card-total.tsx","../src/ds/components/MetricsCard/metrics-card.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/** Container for icon buttons / small actions in the top bar of a MetricsCard,\n * placed between the title and `Total` (which always renders last). Small (28px) buttons sit\n * centered on the 20px title line without making the top bar taller. */\nexport function MetricsCardActions({\n children,\n reveal = 'always',\n className,\n}: {\n children: ReactNode;\n /**\n * `hover`: the actions appear while the card is hovered or one of them has focus, so a page\n * of cards doesn't read as a page of buttons.\n */\n reveal?: 'always' | 'hover';\n className?: string;\n}) {\n return (\n <div\n className={cn(\n '-my-1 flex shrink-0 items-center gap-1 self-start',\n reveal === 'hover' &&\n 'opacity-0 transition-opacity duration-150 group-hover/metrics-card:opacity-100 focus-within:opacity-100 has-data-popup-open:opacity-100',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * Scrolls sideways only (wide tables). Vertical overflow is hidden: a chart filling a card with a\n * fractional height rounds 1px past it, which otherwise turns the content into a scroll box.\n * Tables inside a card drop the last row's border: the card edge already closes them.\n */\nexport function MetricsCardContent({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('overflow-x-auto overflow-y-hidden [&_tbody>tr:last-child]:border-b-0', className)}>\n {children}\n </div>\n );\n}\n","import { GripVerticalIcon } from 'lucide-react';\nimport type { DragEventHandler } from 'react';\nimport { Button } from '@/ds/components/Button';\nimport { cn } from '@/lib/utils';\n\n/** What a host's layout hands a card so it can be dragged, e.g. to rearrange a dashboard. */\nexport type MetricsCardDragHandleProps = {\n /** What dragging does, e.g. \"Move widget\". */\n 'aria-label': string;\n draggable?: boolean;\n onDragStart?: DragEventHandler<HTMLElement>;\n onDragEnd?: DragEventHandler<HTMLElement>;\n className?: string;\n};\n\n/** The grip a card is dragged by, left of its title. Its negative margin keeps the top bar's height. */\nexport function MetricsCardDragHandle({ className, ...props }: MetricsCardDragHandleProps) {\n return (\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className={cn('-my-1 shrink-0 cursor-grab active:cursor-grabbing', className)}\n {...props}\n >\n <GripVerticalIcon />\n </Button>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardError({\n message = 'Failed to load data',\n className,\n}: {\n message?: string;\n className?: string;\n}) {\n return (\n <div className={cn('flex flex-col items-center justify-center gap-3', className)}>\n <Txt variant=\"caption\" className=\"text-destructive-foreground\">\n {message}\n </Txt>\n </div>\n );\n}\n","import { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * The header of a card with one large chart (an explorer, a detail page): the label over a large\n * value, the change against the previous period beside it. Cards in a grid use the compact title\n * and `MetricsCard.Total` instead. A skeleton while loading, at the value's own trimmed height.\n */\nexport function MetricsCardHeadline({\n label,\n value,\n change,\n isLoading = false,\n className,\n}: {\n label: string;\n value: string;\n /** E.g. \"+71.4%\"; shown as \"+71.4% vs previous\". */\n change?: string;\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <div className={cn('grid gap-1.5', className)}>\n <h3 className=\"text-body-sm text-muted-foreground\">{label}</h3>\n <span className=\"flex items-baseline gap-2\">\n <span\n className={cn(\n 'text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]',\n isLoading && 'relative min-w-24',\n )}\n >\n {isLoading ? (\n // Hidden text keeps the value's trimmed height, so the row (and the actions centred on\n // it) doesn't move when the value arrives; the bar covers it.\n <>\n <span className=\"invisible\">0</span>\n <Skeleton className=\"absolute inset-0\" />\n </>\n ) : (\n value\n )}\n </span>\n {!isLoading &&\n change && (\n // Trimmed like the value, so its line box doesn't make the row taller than while loading.\n <span className=\"text-body-sm text-muted-foreground tabular-nums [text-box:trim-both_cap_alphabetic]\">\n {change} vs previous\n </span>\n )}\n </span>\n </div>\n );\n}\n","import { Spinner } from '@/ds/components/Spinner/spinner';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardLoading({ className }: { className?: string }) {\n return (\n <div className={cn('flex items-center justify-center', className)}>\n <Spinner size=\"md\" variant=\"pulse\" className=\"text-placeholder\" />\n </div>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardNoData({ message = 'No data yet', className }: { message?: string; className?: string }) {\n return (\n <div className={cn('flex h-full items-center justify-center', className)}>\n <Txt tone=\"faint\">{message}</Txt>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Card } from '@/ds/components/Card';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardRoot({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <Card\n className={cn(\n 'group/metrics-card grid min-h-72 min-w-80 flex-1 grid-rows-[auto_1fr] gap-4 px-4 py-3 2xl:min-w-120 md:min-w-88 lg:min-w-sm xl:min-w-104',\n className,\n )}\n >\n {children}\n </Card>\n );\n}\n","import { cn } from '@/lib/utils';\n\nexport function MetricsCardTitle({\n children,\n className,\n as: Tag = 'h3',\n}: {\n children: string;\n className?: string;\n as?: 'h2' | 'h3' | 'h4';\n}) {\n return <Tag className={cn('text-subheading text-foreground', className)}>{children}</Tag>;\n}\n","import { ChevronDownIcon } from 'lucide-react';\nimport { DropdownMenu } from '@/ds/components/DropdownMenu';\nimport type { DropdownMenuRadioOption } from '@/ds/components/DropdownMenu';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsCardTitleMenuProps<V extends string> = {\n /** The card title for the picked view (e.g. \"Spend by model\"). */\n title: string;\n value: V;\n onValueChange: (value: V) => void;\n /** The views (e.g. \"By model\", \"By provider\"). */\n options: readonly DropdownMenuRadioOption<V>[];\n className?: string;\n};\n\n/**\n * A card title that switches the card's view, as on Vercel's usage cards: the title is the\n * trigger, with a chevron. The hover fill bleeds past the text so the title stays aligned.\n * Wrapped, so the top bar stretches the wrapper rather than the button, and the menu's open-state\n * nodes next to the trigger don't become the top bar's first child. Not modal: the card's actions\n * (pin, alert) stay shown while it's open, so they stay clickable too.\n */\nexport function MetricsCardTitleMenu<V extends string>({\n title,\n value,\n onValueChange,\n options,\n className,\n}: MetricsCardTitleMenuProps<V>) {\n return (\n <div className=\"flex min-w-0\">\n <DropdownMenu modal={false}>\n <DropdownMenu.Trigger\n render={\n <button\n type=\"button\"\n className={cn(\n '-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-subheading text-foreground hover:bg-fill-subtle',\n className,\n )}\n />\n }\n >\n {title}\n <ChevronDownIcon className=\"size-3.5 text-muted-foreground\" />\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"start\">\n <DropdownMenu.RadioOptions options={options} value={value} onValueChange={onValueChange} closeOnSelect />\n </DropdownMenu.Content>\n </DropdownMenu>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * One row under the top bar for a card's controls: a legend, list column headers.\n * The first child sits on the left, the last on the right; either side may be omitted. When\n * both don't fit (a narrow card), the right side wraps to its own line, still on the right. At least 24px\n * tall, so toolbars line up across cards in the same row.\n */\nexport function MetricsCardToolbar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div\n className={cn(\n 'flex min-h-6 min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 [&>*:first-child]:min-w-0 [&>*:last-child:not(:first-child)]:ml-auto',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardTopBar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('flex items-start gap-4 [&>:first-child]:min-w-0 [&>:first-child]:flex-1', className)}>\n {children}\n </div>\n );\n}\n","import { SkeletonText } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/** One of several totals in a card that charts a few series, marked with its series' color. */\nexport type MetricsCardTotalPart = { label: string; value: string; color: string };\n\n/**\n * A card's total, right of the title in the same type (14px, medium). Always the top\n * bar's last item. A skeleton while loading, in the value's own line box. A card charting a\n * few series of different things (resources, threads) can give one total each, each after a\n * marker in its series' color, like the legend.\n */\nexport function MetricsCardTotal({\n value,\n isLoading = false,\n className,\n}: {\n value: string | readonly MetricsCardTotalPart[];\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <span className={cn('order-last shrink-0 text-subheading text-foreground tabular-nums', className)}>\n <TotalValue value={value} isLoading={isLoading} />\n </span>\n );\n}\n\nfunction TotalValue({ value, isLoading }: { value: string | readonly MetricsCardTotalPart[]; isLoading: boolean }) {\n if (isLoading) return <SkeletonText line=\"text-body\" className=\"h-4 w-14\" />;\n if (typeof value === 'string') return value;\n return (\n <span className=\"inline-flex items-center gap-3\">\n {value.map(part => (\n <span key={part.label} className=\"inline-flex items-center gap-1.5\">\n <span aria-hidden className=\"size-2 shrink-0 rounded-[2px]\" style={{ backgroundColor: part.color }} />\n {/* The marker is decorative; screen readers hear which total this is. */}\n <span className=\"sr-only\">{part.label} </span>\n {part.value}\n </span>\n ))}\n </span>\n );\n}\n","import { MetricsCardActions } from './metrics-card-actions';\nimport { MetricsCardContent } from './metrics-card-content';\nimport { MetricsCardDragHandle } from './metrics-card-drag-handle';\nimport { MetricsCardError } from './metrics-card-error';\nimport { MetricsCardHeadline } from './metrics-card-headline';\nimport { MetricsCardLoading } from './metrics-card-loading';\nimport { MetricsCardNoData } from './metrics-card-no-data';\nimport { MetricsCardRoot } from './metrics-card-root';\nimport { MetricsCardTitle } from './metrics-card-title';\nimport { MetricsCardTitleMenu } from './metrics-card-title-menu';\nimport { MetricsCardToolbar } from './metrics-card-toolbar';\nimport { MetricsCardTopBar } from './metrics-card-top-bar';\nimport { MetricsCardTotal } from './metrics-card-total';\nimport { MetricsKpiCard } from '@/ds/components/MetricsKpiCard';\n\nexport const MetricsCard = Object.assign(MetricsCardRoot, {\n Root: MetricsCardRoot,\n Kpi: MetricsKpiCard,\n TopBar: MetricsCardTopBar,\n Toolbar: MetricsCardToolbar,\n Actions: MetricsCardActions,\n DragHandle: MetricsCardDragHandle,\n Title: MetricsCardTitle,\n TitleMenu: MetricsCardTitleMenu,\n Total: MetricsCardTotal,\n Headline: MetricsCardHeadline,\n Loading: MetricsCardLoading,\n Error: MetricsCardError,\n Content: MetricsCardContent,\n NoData: MetricsCardNoData,\n});\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,mBAAmB,EACjC,UACA,SAAS,UACT,aASC;CACD,OACE,oBAAC,OAAD;EACE,WAAW,GACT,qDACA,WAAW,WACT,2IACF,SACF;EAEC;CACE,CAAA;AAET;;;;;;;ACvBA,SAAgB,mBAAmB,EAAE,UAAU,aAA0D;CACvG,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,wEAAwE,SAAS;EACjG;CACE,CAAA;AAET;;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C,YAAD;GAAmB;GAAkB;EAAY,CAAA;CAC7C,CAAA;AAEV;AAEA,SAAS,WAAW,EAAE,OAAO,aAAsF;CACjH,IAAI,WAAW,OAAO,oBAAC,cAAD;EAAc,MAAK;EAAY,WAAU;CAAY,CAAA;CAC3E,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA,MAAM,KAAI,SACT,qBAAC,QAAD;GAAuB,WAAU;GAAjC,UAAA;IACE,oBAAC,QAAD;KAAM,eAAA;KAAY,WAAU;KAAgC,OAAO,EAAE,iBAAiB,KAAK,MAAM;IAAI,CAAA;IAErG,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAA2B,KAAK,OAAM,GAAO;;IAC5C,KAAK;GACF;EALK,GAAA,KAAK,KAKV,CACP;CACG,CAAA;AAEV;;AC5BA,IAAa,cAAc,OAAO,OAAO,iBAAiB;CACxD,MAAM;CACN,KAAK;CACL,QAAQ;CACR,SAAS;CACT,SAAS;CACT,YAAY;CACZ,OAAO;CACP,WAAW;CACX,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;AACV,CAAC"}
@@ -16,11 +16,11 @@ function MetricsCardGroup({ children, className }) {
16
16
  return /* @__PURE__ */ jsx("div", {
17
17
  className: "@container",
18
18
  children: /* @__PURE__ */ jsx("div", {
19
- className: cn("grid gap-4 *:min-w-0! @xl:grid-cols-2 @3xl:has-[>:nth-child(5)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(3)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(4):last-child]:grid-cols-2 @4xl:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))] @6xl:has-[>:nth-child(5)]:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))]!", className),
19
+ className: cn("grid gap-4 *:min-w-0! @xl:@max-4xl:grid-cols-2 @3xl:@max-4xl:has-[>:nth-child(3)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(4):last-child]:grid-cols-2 @4xl:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))] @4xl:@max-6xl:has-[>:nth-child(5)]:grid-cols-3", className),
20
20
  children
21
21
  })
22
22
  });
23
23
  }
24
24
  export { MetricsCardGroup as t };
25
25
 
26
- //# sourceMappingURL=MetricsCardGroup-C1UrcquB.js.map
26
+ //# sourceMappingURL=MetricsCardGroup-CxvEpv7U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCardGroup-CxvEpv7U.js","names":[],"sources":["../src/ds/components/MetricsCardGroup/metrics-card-group.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsCardGroupProps = {\n children: ReactNode;\n className?: string;\n};\n\n/**\n * A row of metrics cards (KPI, chart, …) held as one unit. No frame of its own: the cards\n * sit directly on the page with the page's 16px gap, so there is never a card inside a card.\n * Columns follow the group's own width (container queries), not the viewport, so a sidebar or\n * a narrow pane never squeezes cards into one row. One column, two, then three from 48rem for groups\n * of three or more, so one or two cards never leave an empty column, and four cards stay 2 + 2 there\n * rather than leave one alone. Up to four cards share one row\n * from 56rem; five stay 3 + 2 until they share one row from 72rem. Every card stays at least\n * 12rem wide, room for its value, change badge and footer on one line each.\n * The group owns their width, so each card's own `min-w-*` is neutralised.\n */\n// An app that loads this package's CSS next to its own Tailwind output can emit the same utility\n// (say `@xl:grid-cols-2`) again, later in the cascade. So no two column rules of equal specificity\n// may apply at the same width, or the later copy wins whatever the breakpoint: each plain rule owns\n// its own width range (one column needs no rule), and the `has-*` overrides win by specificity.\nexport function MetricsCardGroup({ children, className }: MetricsCardGroupProps) {\n return (\n <div className=\"@container\">\n <div\n className={cn(\n 'grid gap-4 *:min-w-0! @xl:@max-4xl:grid-cols-2 @3xl:@max-4xl:has-[>:nth-child(3)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(4):last-child]:grid-cols-2 @4xl:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))] @4xl:@max-6xl:has-[>:nth-child(5)]:grid-cols-3',\n className,\n )}\n >\n {children}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,SAAgB,iBAAiB,EAAE,UAAU,aAAoC;CAC/E,OACE,oBAAC,OAAD;EAAK,WAAU;EACb,UAAA,oBAAC,OAAD;GACE,WAAW,GACT,8PACA,SACF;GAEC;EACE,CAAA;CACF,CAAA;AAET"}
@@ -16,7 +16,7 @@ function MetricsCardGroup({ children, className }) {
16
16
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
17
17
  className: "@container",
18
18
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
19
- className: require_utils.cn("grid gap-4 *:min-w-0! @xl:grid-cols-2 @3xl:has-[>:nth-child(5)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(3)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(4):last-child]:grid-cols-2 @4xl:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))] @6xl:has-[>:nth-child(5)]:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))]!", className),
19
+ className: require_utils.cn("grid gap-4 *:min-w-0! @xl:@max-4xl:grid-cols-2 @3xl:@max-4xl:has-[>:nth-child(3)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(4):last-child]:grid-cols-2 @4xl:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))] @4xl:@max-6xl:has-[>:nth-child(5)]:grid-cols-3", className),
20
20
  children
21
21
  })
22
22
  });
@@ -28,4 +28,4 @@ Object.defineProperty(exports, "MetricsCardGroup", {
28
28
  }
29
29
  });
30
30
 
31
- //# sourceMappingURL=MetricsCardGroup-JRNIwLDb.cjs.map
31
+ //# sourceMappingURL=MetricsCardGroup-DRSzsF4g.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCardGroup-DRSzsF4g.cjs","names":["cn"],"sources":["../src/ds/components/MetricsCardGroup/metrics-card-group.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsCardGroupProps = {\n children: ReactNode;\n className?: string;\n};\n\n/**\n * A row of metrics cards (KPI, chart, …) held as one unit. No frame of its own: the cards\n * sit directly on the page with the page's 16px gap, so there is never a card inside a card.\n * Columns follow the group's own width (container queries), not the viewport, so a sidebar or\n * a narrow pane never squeezes cards into one row. One column, two, then three from 48rem for groups\n * of three or more, so one or two cards never leave an empty column, and four cards stay 2 + 2 there\n * rather than leave one alone. Up to four cards share one row\n * from 56rem; five stay 3 + 2 until they share one row from 72rem. Every card stays at least\n * 12rem wide, room for its value, change badge and footer on one line each.\n * The group owns their width, so each card's own `min-w-*` is neutralised.\n */\n// An app that loads this package's CSS next to its own Tailwind output can emit the same utility\n// (say `@xl:grid-cols-2`) again, later in the cascade. So no two column rules of equal specificity\n// may apply at the same width, or the later copy wins whatever the breakpoint: each plain rule owns\n// its own width range (one column needs no rule), and the `has-*` overrides win by specificity.\nexport function MetricsCardGroup({ children, className }: MetricsCardGroupProps) {\n return (\n <div className=\"@container\">\n <div\n className={cn(\n 'grid gap-4 *:min-w-0! @xl:@max-4xl:grid-cols-2 @3xl:@max-4xl:has-[>:nth-child(3)]:grid-cols-3 @3xl:@max-4xl:has-[>:nth-child(4):last-child]:grid-cols-2 @4xl:grid-cols-[repeat(auto-fit,minmax(12rem,1fr))] @4xl:@max-6xl:has-[>:nth-child(5)]:grid-cols-3',\n className,\n )}\n >\n {children}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,SAAgB,iBAAiB,EAAE,UAAU,aAAoC;CAC/E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EACb,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GACE,WAAWA,cAAAA,GACT,8PACA,SACF;GAEC;EACE,CAAA;CACF,CAAA;AAET"}
@@ -286,7 +286,7 @@ function MetricsTable({ columns, rows, getRowKey, sort, defaultSort, onSortChang
286
286
  style: template,
287
287
  children: [/* @__PURE__ */ jsx("div", {
288
288
  role: "row",
289
- className: cn("relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-body-sm font-medium text-placeholder", HEADER_LINE),
289
+ className: cn("relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-label text-placeholder", HEADER_LINE),
290
290
  children: columns.map((column) => {
291
291
  const direction = current?.column === column.id ? current.direction : void 0;
292
292
  return /* @__PURE__ */ jsx("div", {
@@ -324,4 +324,4 @@ function MetricsTable({ columns, rows, getRowKey, sort, defaultSort, onSortChang
324
324
  }
325
325
  export { MetricsTable as t };
326
326
 
327
- //# sourceMappingURL=MetricsTable-DIjbD5Xk.js.map
327
+ //# sourceMappingURL=MetricsTable-BseaftQ7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetricsTable-DIjbD5Xk.js","names":[],"sources":["../src/ds/components/MetricsTable/metrics-table-header.tsx","../src/ds/components/MetricsTable/metrics-table-rows.tsx","../src/ds/components/MetricsTable/metrics-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from 'lucide-react';\nimport { useId } from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport type { MetricsTableSortDirection } from './metrics-table-types';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/ds/components/Tooltip';\nimport { cn } from '@/lib/utils';\n\nconst SORT_ICON = { asc: ArrowUpIcon, desc: ArrowDownIcon };\n\nexport const FOCUS =\n 'focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:-outline-offset-1';\n\n/**\n * A faint dotted underline under the label: the header explains itself on hover or focus. It\n * brightens while the header is hovered or focused, so it hints without pulling the eye at rest.\n */\nconst EXPLAINED =\n 'cursor-help underline decoration-dotted decoration-placeholder/45 underline-offset-4 transition-[text-decoration-color] duration-150 group-hover/header:decoration-placeholder group-focus-visible/header:decoration-placeholder';\n\ntype HeaderTextProps = {\n header: string;\n /** Underlines the label: the header has a tooltip. */\n explained: boolean;\n};\n\n/** The header's label, as a sort button with the sorted direction's arrow. Takes a tooltip's trigger props. */\nfunction SortButton({\n header,\n explained,\n sorted,\n className,\n ...props\n}: HeaderTextProps & { sorted?: MetricsTableSortDirection } & ComponentProps<'button'>) {\n const SortIcon = sorted && SORT_ICON[sorted];\n return (\n <button\n type=\"button\"\n {...props}\n className={cn(\n 'group/header flex items-center gap-1 rounded whitespace-nowrap hover:text-muted-foreground',\n FOCUS,\n className,\n )}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n {SortIcon && <SortIcon aria-hidden className=\"size-3\" />}\n </button>\n );\n}\n\n/** The header's label as text; focusable when it has a tooltip, so the keyboard reaches it. */\nfunction HeaderText({ header, explained, className, ...props }: HeaderTextProps & ComponentProps<'span'>) {\n return (\n <span\n tabIndex={explained ? 0 : undefined}\n {...props}\n className={cn('group/header rounded whitespace-nowrap', FOCUS, className)}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n </span>\n );\n}\n\n/**\n * A column's header: a sort button when the column sorts, plain text otherwise. With a\n * `description`, the label itself shows it in a tooltip (no separate info icon), marked by a\n * dotted underline, and screen readers get it as the header's description.\n */\nexport function MetricsTableHeaderLabel({\n header,\n description,\n sorted,\n onSort,\n}: {\n header: string;\n description?: ReactNode;\n sorted?: MetricsTableSortDirection;\n /** Makes the header a sort button. */\n onSort?: () => void;\n}) {\n const descriptionId = useId();\n const explained = Boolean(description);\n const describedBy = explained ? descriptionId : undefined;\n const trigger = onSort ? (\n <SortButton header={header} explained={explained} sorted={sorted} onClick={onSort} aria-describedby={describedBy} />\n ) : (\n <HeaderText header={header} explained={explained} aria-describedby={describedBy} />\n );\n\n if (!explained) return trigger;\n return (\n <Tooltip>\n <TooltipTrigger render={trigger} />\n {/* Kept mounted (hidden) while closed, so screen readers always get the text. */}\n <TooltipContent id={descriptionId} keepMounted side=\"top\" className=\"max-w-72\">\n {description}\n </TooltipContent>\n </Tooltip>\n );\n}\n","import type { KeyboardEvent, MouseEvent } from 'react';\nimport { FOCUS } from './metrics-table-header';\nimport type { MetricsTableColumn, MetricsTableProps } from './metrics-table-types';\nimport { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * Full-width lines that fade over their last 6px. A hovered row covers the lines above and below\n * it, which then fade over 24px so they read as part of the hover. Written out in full so Tailwind\n * finds every class.\n */\nconst ROW_LINE =\n 'isolate before:absolute before:inset-x-0 before:-top-px before:bottom-0 before:-z-10 before:rounded hover:before:bg-fill-subtle after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border last:after:hidden after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] hover:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\n/**\n * Rows are 34.5px: 7px above 13px text (a 19.5px line) and 8px below, one more pixel for the\n * separator drawn in the row's last pixel, so text sits centered between the lines.\n */\nconst ROW_BOX = 'pt-1.75 pb-2 text-body-sm';\n\nconst ROW = cn('relative col-span-full grid grid-cols-subgrid items-center px-3', ROW_BOX, ROW_LINE);\n\n/** Skeleton widths for the first column's names, so loading rows don't look stamped. */\nconst SKELETON_NAMES = ['w-32', 'w-24', 'w-36', 'w-20', 'w-28'];\n\n/** Controls a cell can hold; their own clicks and keys don't count as the row's. */\nconst CONTROLS = 'a, button, input, select, textarea, label, [role=\"button\"], [role=\"link\"], [contenteditable]';\n\n/** Whether an event started on a control inside the row rather than on the row itself. */\nfunction fromControl(event: MouseEvent | KeyboardEvent) {\n if (!(event.target instanceof Element)) return false;\n const control = event.target.closest(CONTROLS);\n return Boolean(control && event.currentTarget.contains(control));\n}\n\n/** Where a loading cell's bar sits and how wide it is: figures right, the name in varied widths. */\nfunction skeletonBar<Row>(column: MetricsTableColumn<Row>, columnIndex: number, rowIndex: number) {\n if (column.align === 'end') return 'right-0 w-10';\n if (columnIndex > 0) return 'left-0 w-16';\n return cn('left-0', SKELETON_NAMES[rowIndex % SKELETON_NAMES.length]);\n}\n\ntype RowBehavior<Row> = Pick<\n MetricsTableProps<Row>,\n 'onRowClick' | 'onRowHover' | 'isRowDimmed' | 'isRowActive' | 'rowTitle'\n>;\n\nexport type MetricsTableBodyProps<Row> = RowBehavior<Row> & {\n columns: MetricsTableColumn<Row>[];\n /** The rows on the current page, sorted. */\n rows: Row[];\n getRowKey: (row: Row) => string;\n empty: MetricsTableProps<Row>['empty'];\n /** A paged table's rows per page: drawn while loading, and kept as the empty table's height. */\n pageSize: number | undefined;\n isLoading: boolean;\n};\n\n/** Skeleton rows while loading, the empty message without rows, else the page's rows. */\nexport function MetricsTableBody<Row>({\n columns,\n rows,\n getRowKey,\n empty,\n pageSize,\n isLoading,\n ...behavior\n}: MetricsTableBodyProps<Row>) {\n if (isLoading) {\n return Array.from({ length: pageSize ?? 5 }, (_, i) => (\n <MetricsTableSkeletonRow key={i} columns={columns} rowIndex={i} />\n ));\n }\n if (rows.length === 0) {\n if (pageSize) {\n if (empty === undefined) return <MetricsTableFiller count={pageSize} />;\n // Empty, a paged table keeps at least a full page's height, with the message in its middle.\n // Both share one grid cell, so a message taller than the page still grows the row.\n return (\n <div role=\"row\" className=\"col-span-full grid *:col-start-1 *:row-start-1\">\n <MetricsTableFiller count={pageSize} />\n <p\n role=\"cell\"\n className=\"flex items-center justify-center px-3 py-4 text-center text-body-sm text-muted-foreground\"\n >\n {empty}\n </p>\n </div>\n );\n }\n if (empty === undefined) return null;\n return (\n <div role=\"row\" className=\"col-span-full\">\n <p role=\"cell\" className=\"py-8 text-center text-body-sm text-muted-foreground\">\n {empty}\n </p>\n </div>\n );\n }\n return rows.map(row => <MetricsTableRow key={getRowKey(row)} row={row} columns={columns} {...behavior} />);\n}\n\n/**\n * Blank space as tall as `count` rows, so a paged table is a full page tall however many rows it\n * shows. Rows of the same box, not a fixed height, so it follows the row's text size.\n */\nexport function MetricsTableFiller({ count }: { count: number }) {\n if (count <= 0) return null;\n return (\n <div aria-hidden data-slot=\"metrics-table-filler\" className=\"col-span-full\">\n {Array.from({ length: count }, (_, i) => (\n <div key={i} className={ROW_BOX}>\n {'\\u200b'}\n </div>\n ))}\n </div>\n );\n}\n\n/** A loading row: the real row's markup with a bar in each cell, so it has the same height. */\nfunction MetricsTableSkeletonRow<Row>({ columns, rowIndex }: { columns: MetricsTableColumn<Row>[]; rowIndex: number }) {\n return (\n <div role=\"row\" aria-busy className={ROW}>\n {columns.map((column, columnIndex) => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('relative flex min-w-0', column.align === 'end' && 'justify-end')}\n >\n {/* A zero-width space gives the cell a real line box, so loading rows match loaded ones. */}\n {'​'}\n <Skeleton\n className={cn('absolute top-1/2 h-3.5 -translate-y-1/2', skeletonBar(column, columnIndex, rowIndex))}\n />\n </div>\n ))}\n </div>\n );\n}\n\n/** One row: its cells, and with `onRowClick` a focusable row that Enter and Space also click. */\nfunction MetricsTableRow<Row>({\n row,\n columns,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n}: RowBehavior<Row> & { row: Row; columns: MetricsTableColumn<Row>[] }) {\n const active = isRowActive?.(row) ?? false;\n const dimmed = isRowDimmed?.(row) ?? false;\n\n const handleClick = (event: MouseEvent) => {\n if (!fromControl(event)) onRowClick?.(row);\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n // Only while the row itself has focus, so a cell's link or input keeps its keys.\n if (event.target !== event.currentTarget) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // Space would also scroll the page.\n event.preventDefault();\n onRowClick?.(row);\n };\n\n return (\n <div\n role=\"row\"\n aria-current={active || undefined}\n tabIndex={onRowClick ? 0 : undefined}\n title={rowTitle?.(row)}\n onClick={onRowClick ? handleClick : undefined}\n onKeyDown={onRowClick ? handleKeyDown : undefined}\n onMouseEnter={onRowHover ? () => onRowHover(row) : undefined}\n onMouseLeave={onRowHover ? () => onRowHover(undefined) : undefined}\n className={cn(\n ROW,\n 'rounded text-foreground transition-opacity duration-150',\n onRowClick && cn('cursor-pointer', FOCUS),\n active && 'before:bg-fill-subtle',\n dimmed && 'opacity-40',\n )}\n >\n {columns.map(column => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('flex min-w-0 items-center', column.align === 'end' && 'justify-end text-right')}\n >\n {column.cell(row)}\n </div>\n ))}\n </div>\n );\n}\n","import { useState } from 'react';\nimport { MetricsTableHeaderLabel } from './metrics-table-header';\nimport { MetricsTableBody, MetricsTableFiller } from './metrics-table-rows';\nimport type { MetricsTableColumn, MetricsTableProps, MetricsTableSort } from './metrics-table-types';\nimport { ScrollArea } from '@/ds/components/ScrollArea/scroll-area';\nimport { TablePagination } from '@/ds/components/Table/table-pagination';\nimport { cn } from '@/lib/utils';\n\n/**\n * A full-width line that fades over its last 6px; over 24px when the first row is hovered, so it\n * reads as part of the hover. Written out in full so Tailwind finds every class.\n */\nconst HEADER_LINE =\n 'after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\nconst ARIA_SORT = { asc: 'ascending', desc: 'descending' } as const;\n\n/**\n * Clicks on a column cycle its first direction, the other one, then off: off goes back to the\n * table's default order. Another column starts at its own first direction.\n */\nfunction nextSort<Row>(\n current: MetricsTableSort | undefined,\n column: MetricsTableColumn<Row>,\n): MetricsTableSort | undefined {\n const first = column.firstDirection ?? 'desc';\n if (current?.column !== column.id) return { column: column.id, direction: first };\n if (current.direction !== first) return undefined;\n return { column: column.id, direction: first === 'desc' ? 'asc' : 'desc' };\n}\n\n/** Ascending order of two present sort values. */\nfunction compareAscending(x: number | string, y: number | string) {\n if (typeof x === 'number' && typeof y === 'number') return x - y;\n return String(x).localeCompare(String(y));\n}\n\nfunction sortRows<Row>(rows: Row[], columns: MetricsTableColumn<Row>[], sort: MetricsTableSort | undefined) {\n const by = columns.find(c => c.id === sort?.column)?.sortValue;\n if (!sort || !by) return rows;\n const sign = sort.direction === 'desc' ? -1 : 1;\n // A row without a value goes last whichever way the column sorts.\n return rows.toSorted((a, b) => {\n const x = by(a);\n const y = by(b);\n if (x === undefined && y === undefined) return 0;\n if (x === undefined) return 1;\n if (y === undefined) return -1;\n return sign * compareAscending(x, y);\n });\n}\n\n/**\n * A column's grid track. Figures take a share of the spare width, like an HTML table's auto\n * layout: never narrower than their values, wider when the card has room.\n */\nconst columnWidth = <Row,>(column: MetricsTableColumn<Row>) =>\n column.width ?? (column.align === 'end' ? 'minmax(max-content,1fr)' : 'max-content');\n\n/**\n * A table for the numbers behind a chart: one row per series or group, columns for its figures,\n * separated by lines that fade at the ends. With `SeriesMark` and `Sparkline` cells and the row\n * hover and click hooks it doubles as the chart's legend; without them it's a plain data table.\n * With `pageSize` it pages long lists, and is always a full page tall. For a share of a total, a compact `ShareBar` fits better.\n */\nexport function MetricsTable<Row>({\n columns,\n rows,\n getRowKey,\n sort,\n defaultSort,\n onSortChange,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n empty,\n pageSize,\n isLoading = false,\n 'aria-label': ariaLabel,\n className,\n}: MetricsTableProps<Row>) {\n const [ownSort, setOwnSort] = useState(defaultSort);\n const [page, setPage] = useState(0);\n const current = sort ?? ownSort;\n const sorted = sortRows(rows, columns, current);\n const pageCount = pageSize ? Math.ceil(sorted.length / pageSize) : 1;\n // Fewer rows than before (a narrower filter) keeps the last page rather than an empty one.\n const safePage = Math.min(page, Math.max(0, pageCount - 1));\n const shown = pageSize ? sorted.slice(safePage * pageSize, (safePage + 1) * pageSize) : sorted;\n const template = { gridTemplateColumns: columns.map(columnWidth).join(' ') };\n const showsPagination = !isLoading && pageCount > 1;\n\n const sortBy = (column: MetricsTableColumn<Row>) => {\n const next = nextSort(current, column) ?? defaultSort;\n setOwnSort(next);\n setPage(0);\n onSortChange?.(next);\n };\n\n return (\n <div className={cn('grid min-w-0 gap-3', className)}>\n {/* Narrower than its content (a phone), the table scrolls sideways instead of squeezing columns or the page. */}\n <ScrollArea orientation=\"horizontal\">\n {/* One set of column tracks for the header and every row (each row is a subgrid), so a column's\n width follows its widest cell in the whole table and headers sit over their cells. */}\n <div\n role=\"table\"\n aria-label={ariaLabel}\n // min-content, not max-content: a long name would otherwise grow every `fr` column with it.\n className=\"grid min-w-min gap-x-4\"\n style={template}\n >\n <div\n role=\"row\"\n className={cn(\n 'relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-body-sm font-medium text-placeholder',\n HEADER_LINE,\n )}\n >\n {columns.map(column => {\n const direction = current?.column === column.id ? current.direction : undefined;\n return (\n <div\n key={column.id}\n role=\"columnheader\"\n aria-sort={direction && ARIA_SORT[direction]}\n className={cn('flex min-w-0 items-center gap-1', column.align === 'end' && 'justify-end text-right')}\n >\n <MetricsTableHeaderLabel\n header={column.header}\n description={column.description}\n sorted={direction}\n onSort={column.sortValue ? () => sortBy(column) : undefined}\n />\n </div>\n );\n })}\n </div>\n <MetricsTableBody\n columns={columns}\n rows={shown}\n getRowKey={getRowKey}\n onRowClick={onRowClick}\n onRowHover={onRowHover}\n isRowDimmed={isRowDimmed}\n isRowActive={isRowActive}\n rowTitle={rowTitle}\n empty={empty}\n pageSize={pageSize}\n isLoading={isLoading}\n />\n </div>\n {/* Always a full page tall, so loading, paging and switching data don't move what's below. */}\n {pageSize !== undefined && !isLoading && shown.length > 0 && (\n <MetricsTableFiller count={pageSize - shown.length} />\n )}\n </ScrollArea>\n {showsPagination && <TablePagination page={safePage} pageCount={pageCount} onPageChange={setPage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,YAAY;CAAE,KAAK;CAAa,MAAM;AAAc;AAE1D,IAAa,QACX;;;;;AAMF,IAAM,YACJ;;AASF,SAAS,WAAW,EAClB,QACA,WACA,Q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OAClC,WAAW,GAAG,mCAAmC,OAAO,UAAU,SAAS,wBAAwB;OAEnG,UAAA,oBAAC,yBAAD;QACE,QAAQ,OAAO;QACf,aAAa,OAAO;QACpB,QAAQ;QACR,QAAQ,OAAO,kBAAkB,OAAO,MAAM,IAAI,KAAA;OACnD,CAAA;MACE,GAXE,OAAO,EAWT;KAET,CAAC;IACE,CAAA,GACL,oBAAC,kBAAD;KACW;KACT,MAAM;KACK;KACC;KACA;KACC;KACA;KACH;KACH;KACG;KACC;IACZ,CAAA,CACE;GAEJ,CAAA,GAAA,aAAa,KAAA,KAAa,CAAC,aAAa,MAAM,SAAS,KACtD,oBAAC,oBAAD,EAAoB,OAAO,WAAW,MAAM,OAAS,CAAA,CAE7C;EACX,CAAA,GAAA,mBAAmB,oBAAC,iBAAD;GAAiB,MAAM;GAAqB;GAAW,cAAc;EAAU,CAAA,CAChG;;AAET"}
1
+ {"version":3,"file":"MetricsTable-BseaftQ7.js","names":[],"sources":["../src/ds/components/MetricsTable/metrics-table-header.tsx","../src/ds/components/MetricsTable/metrics-table-rows.tsx","../src/ds/components/MetricsTable/metrics-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from 'lucide-react';\nimport { useId } from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport type { MetricsTableSortDirection } from './metrics-table-types';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/ds/components/Tooltip';\nimport { cn } from '@/lib/utils';\n\nconst SORT_ICON = { asc: ArrowUpIcon, desc: ArrowDownIcon };\n\nexport const FOCUS =\n 'focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:-outline-offset-1';\n\n/**\n * A faint dotted underline under the label: the header explains itself on hover or focus. It\n * brightens while the header is hovered or focused, so it hints without pulling the eye at rest.\n */\nconst EXPLAINED =\n 'cursor-help underline decoration-dotted decoration-placeholder/45 underline-offset-4 transition-[text-decoration-color] duration-150 group-hover/header:decoration-placeholder group-focus-visible/header:decoration-placeholder';\n\ntype HeaderTextProps = {\n header: string;\n /** Underlines the label: the header has a tooltip. */\n explained: boolean;\n};\n\n/** The header's label, as a sort button with the sorted direction's arrow. Takes a tooltip's trigger props. */\nfunction SortButton({\n header,\n explained,\n sorted,\n className,\n ...props\n}: HeaderTextProps & { sorted?: MetricsTableSortDirection } & ComponentProps<'button'>) {\n const SortIcon = sorted && SORT_ICON[sorted];\n return (\n <button\n type=\"button\"\n {...props}\n className={cn(\n 'group/header flex items-center gap-1 rounded whitespace-nowrap hover:text-muted-foreground',\n FOCUS,\n className,\n )}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n {SortIcon && <SortIcon aria-hidden className=\"size-3\" />}\n </button>\n );\n}\n\n/** The header's label as text; focusable when it has a tooltip, so the keyboard reaches it. */\nfunction HeaderText({ header, explained, className, ...props }: HeaderTextProps & ComponentProps<'span'>) {\n return (\n <span\n tabIndex={explained ? 0 : undefined}\n {...props}\n className={cn('group/header rounded whitespace-nowrap', FOCUS, className)}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n </span>\n );\n}\n\n/**\n * A column's header: a sort button when the column sorts, plain text otherwise. With a\n * `description`, the label itself shows it in a tooltip (no separate info icon), marked by a\n * dotted underline, and screen readers get it as the header's description.\n */\nexport function MetricsTableHeaderLabel({\n header,\n description,\n sorted,\n onSort,\n}: {\n header: string;\n description?: ReactNode;\n sorted?: MetricsTableSortDirection;\n /** Makes the header a sort button. */\n onSort?: () => void;\n}) {\n const descriptionId = useId();\n const explained = Boolean(description);\n const describedBy = explained ? descriptionId : undefined;\n const trigger = onSort ? (\n <SortButton header={header} explained={explained} sorted={sorted} onClick={onSort} aria-describedby={describedBy} />\n ) : (\n <HeaderText header={header} explained={explained} aria-describedby={describedBy} />\n );\n\n if (!explained) return trigger;\n return (\n <Tooltip>\n <TooltipTrigger render={trigger} />\n {/* Kept mounted (hidden) while closed, so screen readers always get the text. */}\n <TooltipContent id={descriptionId} keepMounted side=\"top\" className=\"max-w-72\">\n {description}\n </TooltipContent>\n </Tooltip>\n );\n}\n","import type { KeyboardEvent, MouseEvent } from 'react';\nimport { FOCUS } from './metrics-table-header';\nimport type { MetricsTableColumn, MetricsTableProps } from './metrics-table-types';\nimport { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * Full-width lines that fade over their last 6px. A hovered row covers the lines above and below\n * it, which then fade over 24px so they read as part of the hover. Written out in full so Tailwind\n * finds every class.\n */\nconst ROW_LINE =\n 'isolate before:absolute before:inset-x-0 before:-top-px before:bottom-0 before:-z-10 before:rounded hover:before:bg-fill-subtle after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border last:after:hidden after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] hover:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\n/**\n * Rows are 34.5px: 7px above 13px text (a 19.5px line) and 8px below, one more pixel for the\n * separator drawn in the row's last pixel, so text sits centered between the lines.\n */\nconst ROW_BOX = 'pt-1.75 pb-2 text-body-sm';\n\nconst ROW = cn('relative col-span-full grid grid-cols-subgrid items-center px-3', ROW_BOX, ROW_LINE);\n\n/** Skeleton widths for the first column's names, so loading rows don't look stamped. */\nconst SKELETON_NAMES = ['w-32', 'w-24', 'w-36', 'w-20', 'w-28'];\n\n/** Controls a cell can hold; their own clicks and keys don't count as the row's. */\nconst CONTROLS = 'a, button, input, select, textarea, label, [role=\"button\"], [role=\"link\"], [contenteditable]';\n\n/** Whether an event started on a control inside the row rather than on the row itself. */\nfunction fromControl(event: MouseEvent | KeyboardEvent) {\n if (!(event.target instanceof Element)) return false;\n const control = event.target.closest(CONTROLS);\n return Boolean(control && event.currentTarget.contains(control));\n}\n\n/** Where a loading cell's bar sits and how wide it is: figures right, the name in varied widths. */\nfunction skeletonBar<Row>(column: MetricsTableColumn<Row>, columnIndex: number, rowIndex: number) {\n if (column.align === 'end') return 'right-0 w-10';\n if (columnIndex > 0) return 'left-0 w-16';\n return cn('left-0', SKELETON_NAMES[rowIndex % SKELETON_NAMES.length]);\n}\n\ntype RowBehavior<Row> = Pick<\n MetricsTableProps<Row>,\n 'onRowClick' | 'onRowHover' | 'isRowDimmed' | 'isRowActive' | 'rowTitle'\n>;\n\nexport type MetricsTableBodyProps<Row> = RowBehavior<Row> & {\n columns: MetricsTableColumn<Row>[];\n /** The rows on the current page, sorted. */\n rows: Row[];\n getRowKey: (row: Row) => string;\n empty: MetricsTableProps<Row>['empty'];\n /** A paged table's rows per page: drawn while loading, and kept as the empty table's height. */\n pageSize: number | undefined;\n isLoading: boolean;\n};\n\n/** Skeleton rows while loading, the empty message without rows, else the page's rows. */\nexport function MetricsTableBody<Row>({\n columns,\n rows,\n getRowKey,\n empty,\n pageSize,\n isLoading,\n ...behavior\n}: MetricsTableBodyProps<Row>) {\n if (isLoading) {\n return Array.from({ length: pageSize ?? 5 }, (_, i) => (\n <MetricsTableSkeletonRow key={i} columns={columns} rowIndex={i} />\n ));\n }\n if (rows.length === 0) {\n if (pageSize) {\n if (empty === undefined) return <MetricsTableFiller count={pageSize} />;\n // Empty, a paged table keeps at least a full page's height, with the message in its middle.\n // Both share one grid cell, so a message taller than the page still grows the row.\n return (\n <div role=\"row\" className=\"col-span-full grid *:col-start-1 *:row-start-1\">\n <MetricsTableFiller count={pageSize} />\n <p\n role=\"cell\"\n className=\"flex items-center justify-center px-3 py-4 text-center text-body-sm text-muted-foreground\"\n >\n {empty}\n </p>\n </div>\n );\n }\n if (empty === undefined) return null;\n return (\n <div role=\"row\" className=\"col-span-full\">\n <p role=\"cell\" className=\"py-8 text-center text-body-sm text-muted-foreground\">\n {empty}\n </p>\n </div>\n );\n }\n return rows.map(row => <MetricsTableRow key={getRowKey(row)} row={row} columns={columns} {...behavior} />);\n}\n\n/**\n * Blank space as tall as `count` rows, so a paged table is a full page tall however many rows it\n * shows. Rows of the same box, not a fixed height, so it follows the row's text size.\n */\nexport function MetricsTableFiller({ count }: { count: number }) {\n if (count <= 0) return null;\n return (\n <div aria-hidden data-slot=\"metrics-table-filler\" className=\"col-span-full\">\n {Array.from({ length: count }, (_, i) => (\n <div key={i} className={ROW_BOX}>\n {'\\u200b'}\n </div>\n ))}\n </div>\n );\n}\n\n/** A loading row: the real row's markup with a bar in each cell, so it has the same height. */\nfunction MetricsTableSkeletonRow<Row>({ columns, rowIndex }: { columns: MetricsTableColumn<Row>[]; rowIndex: number }) {\n return (\n <div role=\"row\" aria-busy className={ROW}>\n {columns.map((column, columnIndex) => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('relative flex min-w-0', column.align === 'end' && 'justify-end')}\n >\n {/* A zero-width space gives the cell a real line box, so loading rows match loaded ones. */}\n {'​'}\n <Skeleton\n className={cn('absolute top-1/2 h-3.5 -translate-y-1/2', skeletonBar(column, columnIndex, rowIndex))}\n />\n </div>\n ))}\n </div>\n );\n}\n\n/** One row: its cells, and with `onRowClick` a focusable row that Enter and Space also click. */\nfunction MetricsTableRow<Row>({\n row,\n columns,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n}: RowBehavior<Row> & { row: Row; columns: MetricsTableColumn<Row>[] }) {\n const active = isRowActive?.(row) ?? false;\n const dimmed = isRowDimmed?.(row) ?? false;\n\n const handleClick = (event: MouseEvent) => {\n if (!fromControl(event)) onRowClick?.(row);\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n // Only while the row itself has focus, so a cell's link or input keeps its keys.\n if (event.target !== event.currentTarget) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // Space would also scroll the page.\n event.preventDefault();\n onRowClick?.(row);\n };\n\n return (\n <div\n role=\"row\"\n aria-current={active || undefined}\n tabIndex={onRowClick ? 0 : undefined}\n title={rowTitle?.(row)}\n onClick={onRowClick ? handleClick : undefined}\n onKeyDown={onRowClick ? handleKeyDown : undefined}\n onMouseEnter={onRowHover ? () => onRowHover(row) : undefined}\n onMouseLeave={onRowHover ? () => onRowHover(undefined) : undefined}\n className={cn(\n ROW,\n 'rounded text-foreground transition-opacity duration-150',\n onRowClick && cn('cursor-pointer', FOCUS),\n active && 'before:bg-fill-subtle',\n dimmed && 'opacity-40',\n )}\n >\n {columns.map(column => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('flex min-w-0 items-center', column.align === 'end' && 'justify-end text-right')}\n >\n {column.cell(row)}\n </div>\n ))}\n </div>\n );\n}\n","import { useState } from 'react';\nimport { MetricsTableHeaderLabel } from './metrics-table-header';\nimport { MetricsTableBody, MetricsTableFiller } from './metrics-table-rows';\nimport type { MetricsTableColumn, MetricsTableProps, MetricsTableSort } from './metrics-table-types';\nimport { ScrollArea } from '@/ds/components/ScrollArea/scroll-area';\nimport { TablePagination } from '@/ds/components/Table/table-pagination';\nimport { cn } from '@/lib/utils';\n\n/**\n * A full-width line that fades over its last 6px; over 24px when the first row is hovered, so it\n * reads as part of the hover. Written out in full so Tailwind finds every class.\n */\nconst HEADER_LINE =\n 'after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\nconst ARIA_SORT = { asc: 'ascending', desc: 'descending' } as const;\n\n/**\n * Clicks on a column cycle its first direction, the other one, then off: off goes back to the\n * table's default order. Another column starts at its own first direction.\n */\nfunction nextSort<Row>(\n current: MetricsTableSort | undefined,\n column: MetricsTableColumn<Row>,\n): MetricsTableSort | undefined {\n const first = column.firstDirection ?? 'desc';\n if (current?.column !== column.id) return { column: column.id, direction: first };\n if (current.direction !== first) return undefined;\n return { column: column.id, direction: first === 'desc' ? 'asc' : 'desc' };\n}\n\n/** Ascending order of two present sort values. */\nfunction compareAscending(x: number | string, y: number | string) {\n if (typeof x === 'number' && typeof y === 'number') return x - y;\n return String(x).localeCompare(String(y));\n}\n\nfunction sortRows<Row>(rows: Row[], columns: MetricsTableColumn<Row>[], sort: MetricsTableSort | undefined) {\n const by = columns.find(c => c.id === sort?.column)?.sortValue;\n if (!sort || !by) return rows;\n const sign = sort.direction === 'desc' ? -1 : 1;\n // A row without a value goes last whichever way the column sorts.\n return rows.toSorted((a, b) => {\n const x = by(a);\n const y = by(b);\n if (x === undefined && y === undefined) return 0;\n if (x === undefined) return 1;\n if (y === undefined) return -1;\n return sign * compareAscending(x, y);\n });\n}\n\n/**\n * A column's grid track. Figures take a share of the spare width, like an HTML table's auto\n * layout: never narrower than their values, wider when the card has room.\n */\nconst columnWidth = <Row,>(column: MetricsTableColumn<Row>) =>\n column.width ?? (column.align === 'end' ? 'minmax(max-content,1fr)' : 'max-content');\n\n/**\n * A table for the numbers behind a chart: one row per series or group, columns for its figures,\n * separated by lines that fade at the ends. With `SeriesMark` and `Sparkline` cells and the row\n * hover and click hooks it doubles as the chart's legend; without them it's a plain data table.\n * With `pageSize` it pages long lists, and is always a full page tall. For a share of a total, a compact `ShareBar` fits better.\n */\nexport function MetricsTable<Row>({\n columns,\n rows,\n getRowKey,\n sort,\n defaultSort,\n onSortChange,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n empty,\n pageSize,\n isLoading = false,\n 'aria-label': ariaLabel,\n className,\n}: MetricsTableProps<Row>) {\n const [ownSort, setOwnSort] = useState(defaultSort);\n const [page, setPage] = useState(0);\n const current = sort ?? ownSort;\n const sorted = sortRows(rows, columns, current);\n const pageCount = pageSize ? Math.ceil(sorted.length / pageSize) : 1;\n // Fewer rows than before (a narrower filter) keeps the last page rather than an empty one.\n const safePage = Math.min(page, Math.max(0, pageCount - 1));\n const shown = pageSize ? sorted.slice(safePage * pageSize, (safePage + 1) * pageSize) : sorted;\n const template = { gridTemplateColumns: columns.map(columnWidth).join(' ') };\n const showsPagination = !isLoading && pageCount > 1;\n\n const sortBy = (column: MetricsTableColumn<Row>) => {\n const next = nextSort(current, column) ?? defaultSort;\n setOwnSort(next);\n setPage(0);\n onSortChange?.(next);\n };\n\n return (\n <div className={cn('grid min-w-0 gap-3', className)}>\n {/* Narrower than its content (a phone), the table scrolls sideways instead of squeezing columns or the page. */}\n <ScrollArea orientation=\"horizontal\">\n {/* One set of column tracks for the header and every row (each row is a subgrid), so a column's\n width follows its widest cell in the whole table and headers sit over their cells. */}\n <div\n role=\"table\"\n aria-label={ariaLabel}\n // min-content, not max-content: a long name would otherwise grow every `fr` column with it.\n className=\"grid min-w-min gap-x-4\"\n style={template}\n >\n <div\n role=\"row\"\n className={cn(\n 'relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-label text-placeholder',\n HEADER_LINE,\n )}\n >\n {columns.map(column => {\n const direction = current?.column === column.id ? current.direction : undefined;\n return (\n <div\n key={column.id}\n role=\"columnheader\"\n aria-sort={direction && ARIA_SORT[direction]}\n className={cn('flex min-w-0 items-center gap-1', column.align === 'end' && 'justify-end text-right')}\n >\n <MetricsTableHeaderLabel\n header={column.header}\n description={column.description}\n sorted={direction}\n onSort={column.sortValue ? () => sortBy(column) : undefined}\n />\n </div>\n );\n })}\n </div>\n <MetricsTableBody\n columns={columns}\n rows={shown}\n getRowKey={getRowKey}\n onRowClick={onRowClick}\n onRowHover={onRowHover}\n isRowDimmed={isRowDimmed}\n isRowActive={isRowActive}\n rowTitle={rowTitle}\n empty={empty}\n pageSize={pageSize}\n isLoading={isLoading}\n />\n </div>\n {/* Always a full page tall, so loading, paging and switching data don't move what's below. */}\n {pageSize !== undefined && !isLoading && shown.length > 0 && (\n <MetricsTableFiller count={pageSize - shown.length} />\n )}\n </ScrollArea>\n {showsPagination && <TablePagination page={safePage} pageCount={pageCount} onPageChange={setPage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,YAAY;CAAE,KAAK;CAAa,MAAM;AAAc;AAE1D,IAAa,QACX;;;;;AAMF,IAAM,YACJ;;AASF,SAAS,WAAW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aAAW,aAAa,UAAU;OAClC,WAAW,GAAG,mCAAmC,OAAO,UAAU,SAAS,wBAAwB;OAEnG,UAAA,oBAAC,yBAAD;QACE,QAAQ,OAAO;QACf,aAAa,OAAO;QACpB,QAAQ;QACR,QAAQ,OAAO,kBAAkB,OAAO,MAAM,IAAI,KAAA;OACnD,CAAA;MACE,GAXE,OAAO,EAWT;KAET,CAAC;IACE,CAAA,GACL,oBAAC,kBAAD;KACW;KACT,MAAM;KACK;KACC;KACA;KACC;KACA;KACH;KACH;KACG;KACC;IACZ,CAAA,CACE;GAEJ,CAAA,GAAA,aAAa,KAAA,KAAa,CAAC,aAAa,MAAM,SAAS,KACtD,oBAAC,oBAAD,EAAoB,OAAO,WAAW,MAAM,OAAS,CAAA,CAE7C;EACX,CAAA,GAAA,mBAAmB,oBAAC,iBAAD;GAAiB,MAAM;GAAqB;GAAW,cAAc;EAAU,CAAA,CAChG;;AAET"}
@@ -286,7 +286,7 @@ function MetricsTable({ columns, rows, getRowKey, sort, defaultSort, onSortChang
286
286
  style: template,
287
287
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
288
288
  role: "row",
289
- className: require_utils.cn("relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-body-sm font-medium text-placeholder", HEADER_LINE),
289
+ className: require_utils.cn("relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-label text-placeholder", HEADER_LINE),
290
290
  children: columns.map((column) => {
291
291
  const direction = current?.column === column.id ? current.direction : void 0;
292
292
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -329,4 +329,4 @@ Object.defineProperty(exports, "MetricsTable", {
329
329
  }
330
330
  });
331
331
 
332
- //# sourceMappingURL=MetricsTable-CvMoo2vg.cjs.map
332
+ //# sourceMappingURL=MetricsTable-Il_NGyyE.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetricsTable-CvMoo2vg.cjs","names":["ArrowUpIcon","ArrowDownIcon","cn","useId","Tooltip","TooltipTrigger","TooltipContent","cn","Skeleton","useState","cn","ScrollArea","TablePagination"],"sources":["../src/ds/components/MetricsTable/metrics-table-header.tsx","../src/ds/components/MetricsTable/metrics-table-rows.tsx","../src/ds/components/MetricsTable/metrics-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from 'lucide-react';\nimport { useId } from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport type { MetricsTableSortDirection } from './metrics-table-types';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/ds/components/Tooltip';\nimport { cn } from '@/lib/utils';\n\nconst SORT_ICON = { asc: ArrowUpIcon, desc: ArrowDownIcon };\n\nexport const FOCUS =\n 'focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:-outline-offset-1';\n\n/**\n * A faint dotted underline under the label: the header explains itself on hover or focus. It\n * brightens while the header is hovered or focused, so it hints without pulling the eye at rest.\n */\nconst EXPLAINED =\n 'cursor-help underline decoration-dotted decoration-placeholder/45 underline-offset-4 transition-[text-decoration-color] duration-150 group-hover/header:decoration-placeholder group-focus-visible/header:decoration-placeholder';\n\ntype HeaderTextProps = {\n header: string;\n /** Underlines the label: the header has a tooltip. */\n explained: boolean;\n};\n\n/** The header's label, as a sort button with the sorted direction's arrow. Takes a tooltip's trigger props. */\nfunction SortButton({\n header,\n explained,\n sorted,\n className,\n ...props\n}: HeaderTextProps & { sorted?: MetricsTableSortDirection } & ComponentProps<'button'>) {\n const SortIcon = sorted && SORT_ICON[sorted];\n return (\n <button\n type=\"button\"\n {...props}\n className={cn(\n 'group/header flex items-center gap-1 rounded whitespace-nowrap hover:text-muted-foreground',\n FOCUS,\n className,\n )}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n {SortIcon && <SortIcon aria-hidden className=\"size-3\" />}\n </button>\n );\n}\n\n/** The header's label as text; focusable when it has a tooltip, so the keyboard reaches it. */\nfunction HeaderText({ header, explained, className, ...props }: HeaderTextProps & ComponentProps<'span'>) {\n return (\n <span\n tabIndex={explained ? 0 : undefined}\n {...props}\n className={cn('group/header rounded whitespace-nowrap', FOCUS, className)}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n </span>\n );\n}\n\n/**\n * A column's header: a sort button when the column sorts, plain text otherwise. With a\n * `description`, the label itself shows it in a tooltip (no separate info icon), marked by a\n * dotted underline, and screen readers get it as the header's description.\n */\nexport function MetricsTableHeaderLabel({\n header,\n description,\n sorted,\n onSort,\n}: {\n header: string;\n description?: ReactNode;\n sorted?: MetricsTableSortDirection;\n /** Makes the header a sort button. */\n onSort?: () => void;\n}) {\n const descriptionId = useId();\n const explained = Boolean(description);\n const describedBy = explained ? descriptionId : undefined;\n const trigger = onSort ? (\n <SortButton header={header} explained={explained} sorted={sorted} onClick={onSort} aria-describedby={describedBy} />\n ) : (\n <HeaderText header={header} explained={explained} aria-describedby={describedBy} />\n );\n\n if (!explained) return trigger;\n return (\n <Tooltip>\n <TooltipTrigger render={trigger} />\n {/* Kept mounted (hidden) while closed, so screen readers always get the text. */}\n <TooltipContent id={descriptionId} keepMounted side=\"top\" className=\"max-w-72\">\n {description}\n </TooltipContent>\n </Tooltip>\n );\n}\n","import type { KeyboardEvent, MouseEvent } from 'react';\nimport { FOCUS } from './metrics-table-header';\nimport type { MetricsTableColumn, MetricsTableProps } from './metrics-table-types';\nimport { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * Full-width lines that fade over their last 6px. A hovered row covers the lines above and below\n * it, which then fade over 24px so they read as part of the hover. Written out in full so Tailwind\n * finds every class.\n */\nconst ROW_LINE =\n 'isolate before:absolute before:inset-x-0 before:-top-px before:bottom-0 before:-z-10 before:rounded hover:before:bg-fill-subtle after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border last:after:hidden after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] hover:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\n/**\n * Rows are 34.5px: 7px above 13px text (a 19.5px line) and 8px below, one more pixel for the\n * separator drawn in the row's last pixel, so text sits centered between the lines.\n */\nconst ROW_BOX = 'pt-1.75 pb-2 text-body-sm';\n\nconst ROW = cn('relative col-span-full grid grid-cols-subgrid items-center px-3', ROW_BOX, ROW_LINE);\n\n/** Skeleton widths for the first column's names, so loading rows don't look stamped. */\nconst SKELETON_NAMES = ['w-32', 'w-24', 'w-36', 'w-20', 'w-28'];\n\n/** Controls a cell can hold; their own clicks and keys don't count as the row's. */\nconst CONTROLS = 'a, button, input, select, textarea, label, [role=\"button\"], [role=\"link\"], [contenteditable]';\n\n/** Whether an event started on a control inside the row rather than on the row itself. */\nfunction fromControl(event: MouseEvent | KeyboardEvent) {\n if (!(event.target instanceof Element)) return false;\n const control = event.target.closest(CONTROLS);\n return Boolean(control && event.currentTarget.contains(control));\n}\n\n/** Where a loading cell's bar sits and how wide it is: figures right, the name in varied widths. */\nfunction skeletonBar<Row>(column: MetricsTableColumn<Row>, columnIndex: number, rowIndex: number) {\n if (column.align === 'end') return 'right-0 w-10';\n if (columnIndex > 0) return 'left-0 w-16';\n return cn('left-0', SKELETON_NAMES[rowIndex % SKELETON_NAMES.length]);\n}\n\ntype RowBehavior<Row> = Pick<\n MetricsTableProps<Row>,\n 'onRowClick' | 'onRowHover' | 'isRowDimmed' | 'isRowActive' | 'rowTitle'\n>;\n\nexport type MetricsTableBodyProps<Row> = RowBehavior<Row> & {\n columns: MetricsTableColumn<Row>[];\n /** The rows on the current page, sorted. */\n rows: Row[];\n getRowKey: (row: Row) => string;\n empty: MetricsTableProps<Row>['empty'];\n /** A paged table's rows per page: drawn while loading, and kept as the empty table's height. */\n pageSize: number | undefined;\n isLoading: boolean;\n};\n\n/** Skeleton rows while loading, the empty message without rows, else the page's rows. */\nexport function MetricsTableBody<Row>({\n columns,\n rows,\n getRowKey,\n empty,\n pageSize,\n isLoading,\n ...behavior\n}: MetricsTableBodyProps<Row>) {\n if (isLoading) {\n return Array.from({ length: pageSize ?? 5 }, (_, i) => (\n <MetricsTableSkeletonRow key={i} columns={columns} rowIndex={i} />\n ));\n }\n if (rows.length === 0) {\n if (pageSize) {\n if (empty === undefined) return <MetricsTableFiller count={pageSize} />;\n // Empty, a paged table keeps at least a full page's height, with the message in its middle.\n // Both share one grid cell, so a message taller than the page still grows the row.\n return (\n <div role=\"row\" className=\"col-span-full grid *:col-start-1 *:row-start-1\">\n <MetricsTableFiller count={pageSize} />\n <p\n role=\"cell\"\n className=\"flex items-center justify-center px-3 py-4 text-center text-body-sm text-muted-foreground\"\n >\n {empty}\n </p>\n </div>\n );\n }\n if (empty === undefined) return null;\n return (\n <div role=\"row\" className=\"col-span-full\">\n <p role=\"cell\" className=\"py-8 text-center text-body-sm text-muted-foreground\">\n {empty}\n </p>\n </div>\n );\n }\n return rows.map(row => <MetricsTableRow key={getRowKey(row)} row={row} columns={columns} {...behavior} />);\n}\n\n/**\n * Blank space as tall as `count` rows, so a paged table is a full page tall however many rows it\n * shows. Rows of the same box, not a fixed height, so it follows the row's text size.\n */\nexport function MetricsTableFiller({ count }: { count: number }) {\n if (count <= 0) return null;\n return (\n <div aria-hidden data-slot=\"metrics-table-filler\" className=\"col-span-full\">\n {Array.from({ length: count }, (_, i) => (\n <div key={i} className={ROW_BOX}>\n {'\\u200b'}\n </div>\n ))}\n </div>\n );\n}\n\n/** A loading row: the real row's markup with a bar in each cell, so it has the same height. */\nfunction MetricsTableSkeletonRow<Row>({ columns, rowIndex }: { columns: MetricsTableColumn<Row>[]; rowIndex: number }) {\n return (\n <div role=\"row\" aria-busy className={ROW}>\n {columns.map((column, columnIndex) => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('relative flex min-w-0', column.align === 'end' && 'justify-end')}\n >\n {/* A zero-width space gives the cell a real line box, so loading rows match loaded ones. */}\n {'​'}\n <Skeleton\n className={cn('absolute top-1/2 h-3.5 -translate-y-1/2', skeletonBar(column, columnIndex, rowIndex))}\n />\n </div>\n ))}\n </div>\n );\n}\n\n/** One row: its cells, and with `onRowClick` a focusable row that Enter and Space also click. */\nfunction MetricsTableRow<Row>({\n row,\n columns,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n}: RowBehavior<Row> & { row: Row; columns: MetricsTableColumn<Row>[] }) {\n const active = isRowActive?.(row) ?? false;\n const dimmed = isRowDimmed?.(row) ?? false;\n\n const handleClick = (event: MouseEvent) => {\n if (!fromControl(event)) onRowClick?.(row);\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n // Only while the row itself has focus, so a cell's link or input keeps its keys.\n if (event.target !== event.currentTarget) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // Space would also scroll the page.\n event.preventDefault();\n onRowClick?.(row);\n };\n\n return (\n <div\n role=\"row\"\n aria-current={active || undefined}\n tabIndex={onRowClick ? 0 : undefined}\n title={rowTitle?.(row)}\n onClick={onRowClick ? handleClick : undefined}\n onKeyDown={onRowClick ? handleKeyDown : undefined}\n onMouseEnter={onRowHover ? () => onRowHover(row) : undefined}\n onMouseLeave={onRowHover ? () => onRowHover(undefined) : undefined}\n className={cn(\n ROW,\n 'rounded text-foreground transition-opacity duration-150',\n onRowClick && cn('cursor-pointer', FOCUS),\n active && 'before:bg-fill-subtle',\n dimmed && 'opacity-40',\n )}\n >\n {columns.map(column => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('flex min-w-0 items-center', column.align === 'end' && 'justify-end text-right')}\n >\n {column.cell(row)}\n </div>\n ))}\n </div>\n );\n}\n","import { useState } from 'react';\nimport { MetricsTableHeaderLabel } from './metrics-table-header';\nimport { MetricsTableBody, MetricsTableFiller } from './metrics-table-rows';\nimport type { MetricsTableColumn, MetricsTableProps, MetricsTableSort } from './metrics-table-types';\nimport { ScrollArea } from '@/ds/components/ScrollArea/scroll-area';\nimport { TablePagination } from '@/ds/components/Table/table-pagination';\nimport { cn } from '@/lib/utils';\n\n/**\n * A full-width line that fades over its last 6px; over 24px when the first row is hovered, so it\n * reads as part of the hover. Written out in full so Tailwind finds every class.\n */\nconst HEADER_LINE =\n 'after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\nconst ARIA_SORT = { asc: 'ascending', desc: 'descending' } as const;\n\n/**\n * Clicks on a column cycle its first direction, the other one, then off: off goes back to the\n * table's default order. Another column starts at its own first direction.\n */\nfunction nextSort<Row>(\n current: MetricsTableSort | undefined,\n column: MetricsTableColumn<Row>,\n): MetricsTableSort | undefined {\n const first = column.firstDirection ?? 'desc';\n if (current?.column !== column.id) return { column: column.id, direction: first };\n if (current.direction !== first) return undefined;\n return { column: column.id, direction: first === 'desc' ? 'asc' : 'desc' };\n}\n\n/** Ascending order of two present sort values. */\nfunction compareAscending(x: number | string, y: number | string) {\n if (typeof x === 'number' && typeof y === 'number') return x - y;\n return String(x).localeCompare(String(y));\n}\n\nfunction sortRows<Row>(rows: Row[], columns: MetricsTableColumn<Row>[], sort: MetricsTableSort | undefined) {\n const by = columns.find(c => c.id === sort?.column)?.sortValue;\n if (!sort || !by) return rows;\n const sign = sort.direction === 'desc' ? -1 : 1;\n // A row without a value goes last whichever way the column sorts.\n return rows.toSorted((a, b) => {\n const x = by(a);\n const y = by(b);\n if (x === undefined && y === undefined) return 0;\n if (x === undefined) return 1;\n if (y === undefined) return -1;\n return sign * compareAscending(x, y);\n });\n}\n\n/**\n * A column's grid track. Figures take a share of the spare width, like an HTML table's auto\n * layout: never narrower than their values, wider when the card has room.\n */\nconst columnWidth = <Row,>(column: MetricsTableColumn<Row>) =>\n column.width ?? (column.align === 'end' ? 'minmax(max-content,1fr)' : 'max-content');\n\n/**\n * A table for the numbers behind a chart: one row per series or group, columns for its figures,\n * separated by lines that fade at the ends. With `SeriesMark` and `Sparkline` cells and the row\n * hover and click hooks it doubles as the chart's legend; without them it's a plain data table.\n * With `pageSize` it pages long lists, and is always a full page tall. For a share of a total, a compact `ShareBar` fits better.\n */\nexport function MetricsTable<Row>({\n columns,\n rows,\n getRowKey,\n sort,\n defaultSort,\n onSortChange,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n empty,\n pageSize,\n isLoading = false,\n 'aria-label': ariaLabel,\n className,\n}: MetricsTableProps<Row>) {\n const [ownSort, setOwnSort] = useState(defaultSort);\n const [page, setPage] = useState(0);\n const current = sort ?? ownSort;\n const sorted = sortRows(rows, columns, current);\n const pageCount = pageSize ? Math.ceil(sorted.length / pageSize) : 1;\n // Fewer rows than before (a narrower filter) keeps the last page rather than an empty one.\n const safePage = Math.min(page, Math.max(0, pageCount - 1));\n const shown = pageSize ? sorted.slice(safePage * pageSize, (safePage + 1) * pageSize) : sorted;\n const template = { gridTemplateColumns: columns.map(columnWidth).join(' ') };\n const showsPagination = !isLoading && pageCount > 1;\n\n const sortBy = (column: MetricsTableColumn<Row>) => {\n const next = nextSort(current, column) ?? defaultSort;\n setOwnSort(next);\n setPage(0);\n onSortChange?.(next);\n };\n\n return (\n <div className={cn('grid min-w-0 gap-3', className)}>\n {/* Narrower than its content (a phone), the table scrolls sideways instead of squeezing columns or the page. */}\n <ScrollArea orientation=\"horizontal\">\n {/* One set of column tracks for the header and every row (each row is a subgrid), so a column's\n width follows its widest cell in the whole table and headers sit over their cells. */}\n <div\n role=\"table\"\n aria-label={ariaLabel}\n // min-content, not max-content: a long name would otherwise grow every `fr` column with it.\n className=\"grid min-w-min gap-x-4\"\n style={template}\n >\n <div\n role=\"row\"\n className={cn(\n 'relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-body-sm font-medium text-placeholder',\n HEADER_LINE,\n )}\n >\n {columns.map(column => {\n const direction = current?.column === column.id ? current.direction : undefined;\n return (\n <div\n key={column.id}\n role=\"columnheader\"\n aria-sort={direction && ARIA_SORT[direction]}\n className={cn('flex min-w-0 items-center gap-1', column.align === 'end' && 'justify-end text-right')}\n >\n <MetricsTableHeaderLabel\n header={column.header}\n description={column.description}\n sorted={direction}\n onSort={column.sortValue ? () => sortBy(column) : undefined}\n />\n </div>\n );\n })}\n </div>\n <MetricsTableBody\n columns={columns}\n rows={shown}\n getRowKey={getRowKey}\n onRowClick={onRowClick}\n onRowHover={onRowHover}\n isRowDimmed={isRowDimmed}\n isRowActive={isRowActive}\n rowTitle={rowTitle}\n empty={empty}\n pageSize={pageSize}\n isLoading={isLoading}\n />\n </div>\n {/* Always a full page tall, so loading, paging and switching data don't move what's below. */}\n {pageSize !== undefined && !isLoading && shown.length > 0 && (\n <MetricsTableFiller count={pageSize - shown.length} />\n )}\n </ScrollArea>\n {showsPagination && <TablePagination page={safePage} pageCount={pageCount} onPageChange={setPage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,YAAY;CAAE,KAAKA,aAAAA;CAAa,MAAMC,aAAAA;AAAc;AAE1D,IAAa,QACX;;;;;AAMF,IAAM,YACJ;;AASF,SAAS,WAAW,EAClB,QACA,WACA,QACA,WACA,GAAG,SACmF;CACtF,MAAM,WAAW,UAAU,UAAU;CACrC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,UAAD;EACE,MAAK;EACL,GAAI;EACJ,WAAWC,cAAAA,GACT,8FACA,OACA,SACF;EAPF,UAAA,CASE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;GAAM,WAAWA,cAAAA,GAAG,aAAa,SAAS;GAAI,UAAA;EAAa,CAAA,GAC1D,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GAAU,eAAA;GAAY,WAAU;EAAU,CAAA,CACjD;;AAEZ;;AAGA,SAAS,WAAW,EAAE,QAAQ,WAAW,WAAW,GAAG,SAAmD;CACxG,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EACE,UA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ip","TooltipTrigger","TooltipContent","cn","Skeleton","useState","cn","ScrollArea","TablePagination"],"sources":["../src/ds/components/MetricsTable/metrics-table-header.tsx","../src/ds/components/MetricsTable/metrics-table-rows.tsx","../src/ds/components/MetricsTable/metrics-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from 'lucide-react';\nimport { useId } from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport type { MetricsTableSortDirection } from './metrics-table-types';\nimport { Tooltip, TooltipContent, TooltipTrigger } from '@/ds/components/Tooltip';\nimport { cn } from '@/lib/utils';\n\nconst SORT_ICON = { asc: ArrowUpIcon, desc: ArrowDownIcon };\n\nexport const FOCUS =\n 'focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:-outline-offset-1';\n\n/**\n * A faint dotted underline under the label: the header explains itself on hover or focus. It\n * brightens while the header is hovered or focused, so it hints without pulling the eye at rest.\n */\nconst EXPLAINED =\n 'cursor-help underline decoration-dotted decoration-placeholder/45 underline-offset-4 transition-[text-decoration-color] duration-150 group-hover/header:decoration-placeholder group-focus-visible/header:decoration-placeholder';\n\ntype HeaderTextProps = {\n header: string;\n /** Underlines the label: the header has a tooltip. */\n explained: boolean;\n};\n\n/** The header's label, as a sort button with the sorted direction's arrow. Takes a tooltip's trigger props. */\nfunction SortButton({\n header,\n explained,\n sorted,\n className,\n ...props\n}: HeaderTextProps & { sorted?: MetricsTableSortDirection } & ComponentProps<'button'>) {\n const SortIcon = sorted && SORT_ICON[sorted];\n return (\n <button\n type=\"button\"\n {...props}\n className={cn(\n 'group/header flex items-center gap-1 rounded whitespace-nowrap hover:text-muted-foreground',\n FOCUS,\n className,\n )}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n {SortIcon && <SortIcon aria-hidden className=\"size-3\" />}\n </button>\n );\n}\n\n/** The header's label as text; focusable when it has a tooltip, so the keyboard reaches it. */\nfunction HeaderText({ header, explained, className, ...props }: HeaderTextProps & ComponentProps<'span'>) {\n return (\n <span\n tabIndex={explained ? 0 : undefined}\n {...props}\n className={cn('group/header rounded whitespace-nowrap', FOCUS, className)}\n >\n <span className={cn(explained && EXPLAINED)}>{header}</span>\n </span>\n );\n}\n\n/**\n * A column's header: a sort button when the column sorts, plain text otherwise. With a\n * `description`, the label itself shows it in a tooltip (no separate info icon), marked by a\n * dotted underline, and screen readers get it as the header's description.\n */\nexport function MetricsTableHeaderLabel({\n header,\n description,\n sorted,\n onSort,\n}: {\n header: string;\n description?: ReactNode;\n sorted?: MetricsTableSortDirection;\n /** Makes the header a sort button. */\n onSort?: () => void;\n}) {\n const descriptionId = useId();\n const explained = Boolean(description);\n const describedBy = explained ? descriptionId : undefined;\n const trigger = onSort ? (\n <SortButton header={header} explained={explained} sorted={sorted} onClick={onSort} aria-describedby={describedBy} />\n ) : (\n <HeaderText header={header} explained={explained} aria-describedby={describedBy} />\n );\n\n if (!explained) return trigger;\n return (\n <Tooltip>\n <TooltipTrigger render={trigger} />\n {/* Kept mounted (hidden) while closed, so screen readers always get the text. */}\n <TooltipContent id={descriptionId} keepMounted side=\"top\" className=\"max-w-72\">\n {description}\n </TooltipContent>\n </Tooltip>\n );\n}\n","import type { KeyboardEvent, MouseEvent } from 'react';\nimport { FOCUS } from './metrics-table-header';\nimport type { MetricsTableColumn, MetricsTableProps } from './metrics-table-types';\nimport { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * Full-width lines that fade over their last 6px. A hovered row covers the lines above and below\n * it, which then fade over 24px so they read as part of the hover. Written out in full so Tailwind\n * finds every class.\n */\nconst ROW_LINE =\n 'isolate before:absolute before:inset-x-0 before:-top-px before:bottom-0 before:-z-10 before:rounded hover:before:bg-fill-subtle after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border last:after:hidden after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] hover:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\n/**\n * Rows are 34.5px: 7px above 13px text (a 19.5px line) and 8px below, one more pixel for the\n * separator drawn in the row's last pixel, so text sits centered between the lines.\n */\nconst ROW_BOX = 'pt-1.75 pb-2 text-body-sm';\n\nconst ROW = cn('relative col-span-full grid grid-cols-subgrid items-center px-3', ROW_BOX, ROW_LINE);\n\n/** Skeleton widths for the first column's names, so loading rows don't look stamped. */\nconst SKELETON_NAMES = ['w-32', 'w-24', 'w-36', 'w-20', 'w-28'];\n\n/** Controls a cell can hold; their own clicks and keys don't count as the row's. */\nconst CONTROLS = 'a, button, input, select, textarea, label, [role=\"button\"], [role=\"link\"], [contenteditable]';\n\n/** Whether an event started on a control inside the row rather than on the row itself. */\nfunction fromControl(event: MouseEvent | KeyboardEvent) {\n if (!(event.target instanceof Element)) return false;\n const control = event.target.closest(CONTROLS);\n return Boolean(control && event.currentTarget.contains(control));\n}\n\n/** Where a loading cell's bar sits and how wide it is: figures right, the name in varied widths. */\nfunction skeletonBar<Row>(column: MetricsTableColumn<Row>, columnIndex: number, rowIndex: number) {\n if (column.align === 'end') return 'right-0 w-10';\n if (columnIndex > 0) return 'left-0 w-16';\n return cn('left-0', SKELETON_NAMES[rowIndex % SKELETON_NAMES.length]);\n}\n\ntype RowBehavior<Row> = Pick<\n MetricsTableProps<Row>,\n 'onRowClick' | 'onRowHover' | 'isRowDimmed' | 'isRowActive' | 'rowTitle'\n>;\n\nexport type MetricsTableBodyProps<Row> = RowBehavior<Row> & {\n columns: MetricsTableColumn<Row>[];\n /** The rows on the current page, sorted. */\n rows: Row[];\n getRowKey: (row: Row) => string;\n empty: MetricsTableProps<Row>['empty'];\n /** A paged table's rows per page: drawn while loading, and kept as the empty table's height. */\n pageSize: number | undefined;\n isLoading: boolean;\n};\n\n/** Skeleton rows while loading, the empty message without rows, else the page's rows. */\nexport function MetricsTableBody<Row>({\n columns,\n rows,\n getRowKey,\n empty,\n pageSize,\n isLoading,\n ...behavior\n}: MetricsTableBodyProps<Row>) {\n if (isLoading) {\n return Array.from({ length: pageSize ?? 5 }, (_, i) => (\n <MetricsTableSkeletonRow key={i} columns={columns} rowIndex={i} />\n ));\n }\n if (rows.length === 0) {\n if (pageSize) {\n if (empty === undefined) return <MetricsTableFiller count={pageSize} />;\n // Empty, a paged table keeps at least a full page's height, with the message in its middle.\n // Both share one grid cell, so a message taller than the page still grows the row.\n return (\n <div role=\"row\" className=\"col-span-full grid *:col-start-1 *:row-start-1\">\n <MetricsTableFiller count={pageSize} />\n <p\n role=\"cell\"\n className=\"flex items-center justify-center px-3 py-4 text-center text-body-sm text-muted-foreground\"\n >\n {empty}\n </p>\n </div>\n );\n }\n if (empty === undefined) return null;\n return (\n <div role=\"row\" className=\"col-span-full\">\n <p role=\"cell\" className=\"py-8 text-center text-body-sm text-muted-foreground\">\n {empty}\n </p>\n </div>\n );\n }\n return rows.map(row => <MetricsTableRow key={getRowKey(row)} row={row} columns={columns} {...behavior} />);\n}\n\n/**\n * Blank space as tall as `count` rows, so a paged table is a full page tall however many rows it\n * shows. Rows of the same box, not a fixed height, so it follows the row's text size.\n */\nexport function MetricsTableFiller({ count }: { count: number }) {\n if (count <= 0) return null;\n return (\n <div aria-hidden data-slot=\"metrics-table-filler\" className=\"col-span-full\">\n {Array.from({ length: count }, (_, i) => (\n <div key={i} className={ROW_BOX}>\n {'\\u200b'}\n </div>\n ))}\n </div>\n );\n}\n\n/** A loading row: the real row's markup with a bar in each cell, so it has the same height. */\nfunction MetricsTableSkeletonRow<Row>({ columns, rowIndex }: { columns: MetricsTableColumn<Row>[]; rowIndex: number }) {\n return (\n <div role=\"row\" aria-busy className={ROW}>\n {columns.map((column, columnIndex) => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('relative flex min-w-0', column.align === 'end' && 'justify-end')}\n >\n {/* A zero-width space gives the cell a real line box, so loading rows match loaded ones. */}\n {'​'}\n <Skeleton\n className={cn('absolute top-1/2 h-3.5 -translate-y-1/2', skeletonBar(column, columnIndex, rowIndex))}\n />\n </div>\n ))}\n </div>\n );\n}\n\n/** One row: its cells, and with `onRowClick` a focusable row that Enter and Space also click. */\nfunction MetricsTableRow<Row>({\n row,\n columns,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n}: RowBehavior<Row> & { row: Row; columns: MetricsTableColumn<Row>[] }) {\n const active = isRowActive?.(row) ?? false;\n const dimmed = isRowDimmed?.(row) ?? false;\n\n const handleClick = (event: MouseEvent) => {\n if (!fromControl(event)) onRowClick?.(row);\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n // Only while the row itself has focus, so a cell's link or input keeps its keys.\n if (event.target !== event.currentTarget) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // Space would also scroll the page.\n event.preventDefault();\n onRowClick?.(row);\n };\n\n return (\n <div\n role=\"row\"\n aria-current={active || undefined}\n tabIndex={onRowClick ? 0 : undefined}\n title={rowTitle?.(row)}\n onClick={onRowClick ? handleClick : undefined}\n onKeyDown={onRowClick ? handleKeyDown : undefined}\n onMouseEnter={onRowHover ? () => onRowHover(row) : undefined}\n onMouseLeave={onRowHover ? () => onRowHover(undefined) : undefined}\n className={cn(\n ROW,\n 'rounded text-foreground transition-opacity duration-150',\n onRowClick && cn('cursor-pointer', FOCUS),\n active && 'before:bg-fill-subtle',\n dimmed && 'opacity-40',\n )}\n >\n {columns.map(column => (\n <div\n key={column.id}\n role=\"cell\"\n className={cn('flex min-w-0 items-center', column.align === 'end' && 'justify-end text-right')}\n >\n {column.cell(row)}\n </div>\n ))}\n </div>\n );\n}\n","import { useState } from 'react';\nimport { MetricsTableHeaderLabel } from './metrics-table-header';\nimport { MetricsTableBody, MetricsTableFiller } from './metrics-table-rows';\nimport type { MetricsTableColumn, MetricsTableProps, MetricsTableSort } from './metrics-table-types';\nimport { ScrollArea } from '@/ds/components/ScrollArea/scroll-area';\nimport { TablePagination } from '@/ds/components/Table/table-pagination';\nimport { cn } from '@/lib/utils';\n\n/**\n * A full-width line that fades over its last 6px; over 24px when the first row is hovered, so it\n * reads as part of the hover. Written out in full so Tailwind finds every class.\n */\nconst HEADER_LINE =\n 'after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:[mask-image:linear-gradient(to_right,transparent,black_6px,black_calc(100%-6px),transparent)] [&:has(+:hover)]:after:[mask-image:linear-gradient(to_right,transparent,black_24px,black_calc(100%-24px),transparent)]';\n\nconst ARIA_SORT = { asc: 'ascending', desc: 'descending' } as const;\n\n/**\n * Clicks on a column cycle its first direction, the other one, then off: off goes back to the\n * table's default order. Another column starts at its own first direction.\n */\nfunction nextSort<Row>(\n current: MetricsTableSort | undefined,\n column: MetricsTableColumn<Row>,\n): MetricsTableSort | undefined {\n const first = column.firstDirection ?? 'desc';\n if (current?.column !== column.id) return { column: column.id, direction: first };\n if (current.direction !== first) return undefined;\n return { column: column.id, direction: first === 'desc' ? 'asc' : 'desc' };\n}\n\n/** Ascending order of two present sort values. */\nfunction compareAscending(x: number | string, y: number | string) {\n if (typeof x === 'number' && typeof y === 'number') return x - y;\n return String(x).localeCompare(String(y));\n}\n\nfunction sortRows<Row>(rows: Row[], columns: MetricsTableColumn<Row>[], sort: MetricsTableSort | undefined) {\n const by = columns.find(c => c.id === sort?.column)?.sortValue;\n if (!sort || !by) return rows;\n const sign = sort.direction === 'desc' ? -1 : 1;\n // A row without a value goes last whichever way the column sorts.\n return rows.toSorted((a, b) => {\n const x = by(a);\n const y = by(b);\n if (x === undefined && y === undefined) return 0;\n if (x === undefined) return 1;\n if (y === undefined) return -1;\n return sign * compareAscending(x, y);\n });\n}\n\n/**\n * A column's grid track. Figures take a share of the spare width, like an HTML table's auto\n * layout: never narrower than their values, wider when the card has room.\n */\nconst columnWidth = <Row,>(column: MetricsTableColumn<Row>) =>\n column.width ?? (column.align === 'end' ? 'minmax(max-content,1fr)' : 'max-content');\n\n/**\n * A table for the numbers behind a chart: one row per series or group, columns for its figures,\n * separated by lines that fade at the ends. With `SeriesMark` and `Sparkline` cells and the row\n * hover and click hooks it doubles as the chart's legend; without them it's a plain data table.\n * With `pageSize` it pages long lists, and is always a full page tall. For a share of a total, a compact `ShareBar` fits better.\n */\nexport function MetricsTable<Row>({\n columns,\n rows,\n getRowKey,\n sort,\n defaultSort,\n onSortChange,\n onRowClick,\n onRowHover,\n isRowDimmed,\n isRowActive,\n rowTitle,\n empty,\n pageSize,\n isLoading = false,\n 'aria-label': ariaLabel,\n className,\n}: MetricsTableProps<Row>) {\n const [ownSort, setOwnSort] = useState(defaultSort);\n const [page, setPage] = useState(0);\n const current = sort ?? ownSort;\n const sorted = sortRows(rows, columns, current);\n const pageCount = pageSize ? Math.ceil(sorted.length / pageSize) : 1;\n // Fewer rows than before (a narrower filter) keeps the last page rather than an empty one.\n const safePage = Math.min(page, Math.max(0, pageCount - 1));\n const shown = pageSize ? sorted.slice(safePage * pageSize, (safePage + 1) * pageSize) : sorted;\n const template = { gridTemplateColumns: columns.map(columnWidth).join(' ') };\n const showsPagination = !isLoading && pageCount > 1;\n\n const sortBy = (column: MetricsTableColumn<Row>) => {\n const next = nextSort(current, column) ?? defaultSort;\n setOwnSort(next);\n setPage(0);\n onSortChange?.(next);\n };\n\n return (\n <div className={cn('grid min-w-0 gap-3', className)}>\n {/* Narrower than its content (a phone), the table scrolls sideways instead of squeezing columns or the page. */}\n <ScrollArea orientation=\"horizontal\">\n {/* One set of column tracks for the header and every row (each row is a subgrid), so a column's\n width follows its widest cell in the whole table and headers sit over their cells. */}\n <div\n role=\"table\"\n aria-label={ariaLabel}\n // min-content, not max-content: a long name would otherwise grow every `fr` column with it.\n className=\"grid min-w-min gap-x-4\"\n style={template}\n >\n <div\n role=\"row\"\n className={cn(\n 'relative col-span-full grid grid-cols-subgrid items-end px-3 pb-1.5 text-label text-placeholder',\n HEADER_LINE,\n )}\n >\n {columns.map(column => {\n const direction = current?.column === column.id ? current.direction : undefined;\n return (\n <div\n key={column.id}\n role=\"columnheader\"\n aria-sort={direction && ARIA_SORT[direction]}\n className={cn('flex min-w-0 items-center gap-1', column.align === 'end' && 'justify-end text-right')}\n >\n <MetricsTableHeaderLabel\n header={column.header}\n description={column.description}\n sorted={direction}\n onSort={column.sortValue ? () => sortBy(column) : undefined}\n />\n </div>\n );\n })}\n </div>\n <MetricsTableBody\n columns={columns}\n rows={shown}\n getRowKey={getRowKey}\n onRowClick={onRowClick}\n onRowHover={onRowHover}\n isRowDimmed={isRowDimmed}\n isRowActive={isRowActive}\n rowTitle={rowTitle}\n empty={empty}\n pageSize={pageSize}\n isLoading={isLoading}\n />\n </div>\n {/* Always a full page tall, so loading, paging and switching data don't move what's below. */}\n {pageSize !== undefined && !isLoading && shown.length > 0 && (\n <MetricsTableFiller count={pageSize - shown.length} />\n )}\n </ScrollArea>\n {showsPagination && <TablePagination page={safePage} pageCount={pageCount} onPageChange={setPage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,YAAY;CAAE,KAAKA,aAAAA;CAAa,MAAMC,aAAAA;AAAc;AAE1D,IAAa,QACX;;;;;AAMF,IAAM,YACJ;;AASF,SAAS,WAAW,EAClB,QACA,WACA,QACA,WACA,GAAG,SACmF;CACtF,MAAM,WAAW,UAAU,UAAU;CACrC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,UAAD;EACE,MAAK;EACL,GAAI;EACJ,WAAWC,cAAAA,GACT,8FACA,OACA,SACF;EAPF,UAAA,CASE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;GAAM,WAAWA,cAAAA,GAAG,aAAa,SAAS;GAAI,UAAA;EAAa,CAAA,GAC1D,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GAAU,eAAA;GAAY,WAAU;EAAU,CAAA,CACjD;;AAEZ;;AAGA,SAAS,WAAW,EAAE,QAAQ,WAAW,WAAW,GAAG,SAAmD;CACxG,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EACE,UAAU,YAAY,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