@flamingo-stack/openframe-frontend-core 0.0.794 → 0.0.796

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 (75) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/{chunk-FYHXMHY6.cjs → chunk-6JCTKXHX.cjs} +13 -13
  3. package/dist/{chunk-HXL7AUPG.cjs → chunk-6WXP5IKR.cjs} +16 -16
  4. package/dist/{chunk-6VP5UWZG.cjs → chunk-7SEY3FDF.cjs} +2 -2
  5. package/dist/{chunk-BFCGOHQG.cjs → chunk-7VU4HHUR.cjs} +32 -32
  6. package/dist/{chunk-43ZVXQJK.cjs → chunk-CC7NRWRF.cjs} +48 -48
  7. package/dist/{chunk-72NE4G63.cjs → chunk-CFXCCQ6T.cjs} +2 -2
  8. package/dist/{chunk-RPC4P7GY.cjs → chunk-F64GLU75.cjs} +33 -33
  9. package/dist/{chunk-PQIWR4Q2.cjs → chunk-G24OX7AC.cjs} +16 -16
  10. package/dist/{chunk-7VXMO4XJ.cjs → chunk-GP7NV6BK.cjs} +3 -1
  11. package/dist/{chunk-6TUI5KQS.cjs → chunk-II4A2RUG.cjs} +41 -41
  12. package/dist/{chunk-ZCMXBX4Z.cjs → chunk-IONS6HDF.cjs} +5 -5
  13. package/dist/{chunk-UAZTXYPC.cjs → chunk-JC43ULIC.cjs} +107 -78
  14. package/dist/{chunk-FYPVCCCV.cjs → chunk-JGURZROB.cjs} +27 -27
  15. package/dist/{chunk-FOWQ4XTB.cjs → chunk-N3J4U7ML.cjs} +2 -2
  16. package/dist/{chunk-IJ23KNYI.cjs → chunk-NAJ24ODA.cjs} +4 -4
  17. package/dist/{chunk-F73DM65J.cjs → chunk-NRAH3M66.cjs} +46 -46
  18. package/dist/{chunk-3XAFK4WH.cjs → chunk-OKAHKZP2.cjs} +8 -8
  19. package/dist/{chunk-2KLYMAHF.cjs → chunk-PALMLL5T.cjs} +4 -4
  20. package/dist/{chunk-CLEZ6TWZ.cjs → chunk-QCN46LDL.cjs} +69 -69
  21. package/dist/{chunk-YPKAMHYA.cjs → chunk-QMDXG3VF.cjs} +574 -457
  22. package/dist/{chunk-BIYLAAFI.cjs → chunk-TUD7BV6O.cjs} +9 -9
  23. package/dist/{chunk-OK467OQJ.cjs → chunk-UYOGZJPE.cjs} +4 -4
  24. package/dist/{chunk-IQTVKPRG.cjs → chunk-VUP7ZGZS.cjs} +20 -20
  25. package/dist/{chunk-YYKXX5NA.cjs → chunk-VYXNGADV.cjs} +24 -24
  26. package/dist/{chunk-A6E5ZNQR.cjs → chunk-W4QITOT7.cjs} +5 -5
  27. package/dist/{chunk-NGGEYE5R.cjs → chunk-XFJ7BZDJ.cjs} +5 -5
  28. package/dist/{chunk-U4D4ABXK.cjs → chunk-XVVQJXOA.cjs} +39 -39
  29. package/dist/{chunk-QDW64E6T.cjs → chunk-Y3IMXLLL.cjs} +143 -143
  30. package/dist/{chunk-NIW4ETGC.cjs → chunk-YFHKBIZT.cjs} +6 -6
  31. package/dist/{chunk-KQPU5N7T.cjs → chunk-ZMWSN2BD.cjs} +11 -11
  32. package/dist/{chunk-ZIMPE7D5.cjs → chunk-ZRME3A2D.cjs} +3 -3
  33. package/dist/{cloud-tenants-Z3AYAXF5.cjs → cloud-tenants-BQUWLMYY.cjs} +12 -12
  34. package/dist/components/case-studies/index.cjs +26 -26
  35. package/dist/components/chat/index.cjs +9 -9
  36. package/dist/components/contact/index.cjs +13 -13
  37. package/dist/components/docs/index.cjs +16 -16
  38. package/dist/components/embeds/index.cjs +13 -13
  39. package/dist/components/faq/index.cjs +14 -14
  40. package/dist/components/features/index.cjs +12 -12
  41. package/dist/components/help-center-pages/index.cjs +98 -98
  42. package/dist/components/index.cjs +82 -68
  43. package/dist/components/meeting-scheduler/index.cjs +72 -72
  44. package/dist/components/navigation/index.cjs +15 -15
  45. package/dist/components/onboarding-guides/index.cjs +15 -15
  46. package/dist/components/product-demo/index.cjs +23 -23
  47. package/dist/components/related-content/index.cjs +7 -7
  48. package/dist/components/shared/roadmap/roadmap-grid.d.ts +6 -1
  49. package/dist/components/shared/roadmap/roadmap-grid.d.ts.map +1 -1
  50. package/dist/components/shared/roadmap/roadmap-grid.js +37 -8
  51. package/dist/components/tickets/index.cjs +19 -19
  52. package/dist/components/ui/floating-tooltip.d.ts.map +1 -1
  53. package/dist/components/ui/floating-tooltip.js +3 -1
  54. package/dist/components/ui/index.cjs +26 -12
  55. package/dist/components/ui/index.d.ts +1 -0
  56. package/dist/components/ui/index.d.ts.map +1 -1
  57. package/dist/components/ui/index.js +9 -1
  58. package/dist/components/ui/trendline.d.ts +60 -0
  59. package/dist/components/ui/trendline.d.ts.map +1 -0
  60. package/dist/components/ui/trendline.js +121 -0
  61. package/dist/{devices-P6XQL23S.cjs → devices-BFQOLI3D.cjs} +13 -13
  62. package/dist/{embeddable-chat-6BNLOSBB.cjs → embeddable-chat-INYF23ST.cjs} +74 -74
  63. package/dist/index.cjs +31 -17
  64. package/dist/{knowledge-IU5ORU7U.cjs → knowledge-GGYWTYTP.cjs} +13 -13
  65. package/dist/{logs-DCFTQVKA.cjs → logs-NO55PTIO.cjs} +20 -20
  66. package/dist/{policies-ESC6XCVH.cjs → policies-AAFYTVOJ.cjs} +16 -16
  67. package/dist/{remote-session-4ZNTOLOQ.cjs → remote-session-2CNWLF3P.cjs} +7 -7
  68. package/dist/{scripts-24PIP2VO.cjs → scripts-H4ECJ65X.cjs} +19 -19
  69. package/dist/{software-update-47GDTKMI.cjs → software-update-NEEGQBK3.cjs} +16 -16
  70. package/dist/{tickets-board-X4GHEKPB.cjs → tickets-board-CXYRAMDL.cjs} +8 -8
  71. package/package.json +1 -1
  72. package/src/components/shared/roadmap/roadmap-grid.tsx +38 -9
  73. package/src/components/ui/floating-tooltip.tsx +4 -1
  74. package/src/components/ui/index.ts +1 -0
  75. package/src/components/ui/trendline.tsx +221 -0
@@ -67,6 +67,8 @@ interface RoadmapGridSkeletonProps {
67
67
  showLeftMargin?: boolean;
68
68
  /** The grid's columns from `content-md` (`RoadmapGrid`'s `columns`). Default `2`. */
69
69
  columns?: 1 | 2;
70
+ /** The cards draw their vote row (`RoadmapGrid`'s `votes`). Default `true`. */
71
+ votes?: boolean;
70
72
  }
71
73
 
72
74
  /** The loading cards' vote handler: they draw the vote row and take no vote. */
@@ -77,13 +79,14 @@ function RoadmapGridSkeleton({
77
79
  count = ROADMAP_GRID_SKELETON_CARDS,
78
80
  showLeftMargin = true,
79
81
  columns = 2,
82
+ votes = true,
80
83
  }: RoadmapGridSkeletonProps) {
81
84
  return (
82
85
  <LoadingRegion label="Loading the roadmap" announce={region} className={roadmapGridClass(columns, showLeftMargin)}>
83
86
  {Array.from({ length: count }).map((_, i) => (
84
87
  <div key={i} className="min-w-0" data-loading-item>
85
- {/* With its vote row, as every card of the loaded grid has (the grid always passes `onVote`). */}
86
- <RoadmapCard loading onVote={NO_VOTE} />
88
+ {/* With its vote row when the loaded grid's cards have one (`votes`). */}
89
+ <RoadmapCard loading onVote={votes ? NO_VOTE : undefined} />
87
90
  </div>
88
91
  ))}
89
92
  </LoadingRegion>
@@ -168,6 +171,11 @@ export interface RoadmapGridProps {
168
171
  buildRefreshUrl?: (taskId: string) => string;
169
172
  /** Voting hook options (vote endpoint + storage key). */
170
173
  votingOptions?: UseRoadmapVotingOptions;
174
+ /**
175
+ * The cards draw their vote buttons. Default `true` (the public roadmap). `false` for a surface that shows the
176
+ * roadmap to the team and must not cast public votes (an internal hub, which may not serve the vote route at all).
177
+ */
178
+ votes?: boolean;
171
179
  /** Group items into collapsible per-quarter accordions. Default `false`
172
180
  * (flat grid) so EXISTING callers — the hub's per-quarter RoadmapGrid calls
173
181
  * and related-content rails — stay unchanged. `RoadmapView` / full-page
@@ -204,7 +212,8 @@ function RoadmapGridSingle({
204
212
  showLeftMargin: boolean;
205
213
  columns?: 1 | 2;
206
214
  getVote: (taskId: string) => 'up' | 'down' | null;
207
- onVote: (taskId: string, voteType: 'up' | 'down') => void;
215
+ /** Absent: the cards draw no vote row (`RoadmapGrid`'s `votes={false}`). */
216
+ onVote?: (taskId: string, voteType: 'up' | 'down') => void;
208
217
  votingTasks: Set<string>;
209
218
  }) {
210
219
  return (
@@ -221,7 +230,7 @@ function RoadmapGridSingle({
221
230
  item={item}
222
231
  id={devSectionAnchorId('roadmap', item.id)}
223
232
  userVote={getVote(item.id)}
224
- onVote={voteType => onVote(item.id, voteType)}
233
+ onVote={onVote ? voteType => onVote(item.id, voteType) : undefined}
225
234
  isVoting={votingTasks.has(item.id)}
226
235
  />
227
236
  </div>
@@ -263,11 +272,13 @@ function RoadmapGridQuarterSkeleton({
263
272
  showLeftMargin = true,
264
273
  columns = 2,
265
274
  count,
275
+ votes = true,
266
276
  }: {
267
277
  showLeftMargin?: boolean;
268
278
  columns?: 1 | 2;
269
279
  /** The quarter's skeleton cards. Default the grid skeleton's own. */
270
280
  count?: number;
281
+ votes?: boolean;
271
282
  }) {
272
283
  return (
273
284
  <div className={QUARTER_LIST_CLASS} aria-hidden>
@@ -283,7 +294,13 @@ function RoadmapGridQuarterSkeleton({
283
294
  {/* The quarter's content box: the `AccordionContent` padding (`pt-4` here, the content's own `pb-4` inside). */}
284
295
  <div className={QUARTER_CONTENT_CLASS}>
285
296
  <div className={QUARTER_CONTENT_INNER_CLASS}>
286
- <RoadmapGridSkeleton region={false} count={count} showLeftMargin={showLeftMargin} columns={columns} />
297
+ <RoadmapGridSkeleton
298
+ region={false}
299
+ count={count}
300
+ showLeftMargin={showLeftMargin}
301
+ columns={columns}
302
+ votes={votes}
303
+ />
287
304
  </div>
288
305
  </div>
289
306
  </div>
@@ -298,6 +315,7 @@ export function RoadmapGrid({
298
315
  columns = 2,
299
316
  buildRefreshUrl = DEFAULT_BUILD_REFRESH_URL,
300
317
  votingOptions,
318
+ votes = true,
301
319
  groupByQuarter = false,
302
320
  hasActiveFilters = false,
303
321
  quartersToKeepClosed = 2,
@@ -398,9 +416,20 @@ export function RoadmapGrid({
398
416
  // empty state. The page's loading region announces a scope's; a host's own read announces itself.
399
417
  if (inScope || isLoading) {
400
418
  return groupByQuarter ? (
401
- <RoadmapGridQuarterSkeleton showLeftMargin={showLeftMargin} columns={columns} count={skeletonCount} />
419
+ <RoadmapGridQuarterSkeleton
420
+ showLeftMargin={showLeftMargin}
421
+ columns={columns}
422
+ count={skeletonCount}
423
+ votes={votes}
424
+ />
402
425
  ) : (
403
- <RoadmapGridSkeleton region={!inScope} count={skeletonCount} showLeftMargin={showLeftMargin} columns={columns} />
426
+ <RoadmapGridSkeleton
427
+ region={!inScope}
428
+ count={skeletonCount}
429
+ showLeftMargin={showLeftMargin}
430
+ columns={columns}
431
+ votes={votes}
432
+ />
404
433
  );
405
434
  }
406
435
 
@@ -422,7 +451,7 @@ export function RoadmapGrid({
422
451
  showLeftMargin={showLeftMargin}
423
452
  columns={columns}
424
453
  getVote={getVote}
425
- onVote={handleVote}
454
+ onVote={votes ? handleVote : undefined}
426
455
  votingTasks={votingTasks}
427
456
  />
428
457
  );
@@ -475,7 +504,7 @@ export function RoadmapGrid({
475
504
  showLeftMargin={showLeftMargin}
476
505
  columns={columns}
477
506
  getVote={getVote}
478
- onVote={handleVote}
507
+ onVote={votes ? handleVote : undefined}
479
508
  votingTasks={votingTasks}
480
509
  />
481
510
  </AccordionContent>
@@ -12,6 +12,7 @@ import {
12
12
  useInteractions,
13
13
  FloatingPortal,
14
14
  useHover,
15
+ useFocus,
15
16
  safePolygon,
16
17
  arrow,
17
18
  } from '@floating-ui/react';
@@ -148,10 +149,12 @@ export function FloatingTooltip({
148
149
  delay: { open: delayDuration, close: 0 },
149
150
  handleClose: safePolygon(),
150
151
  });
152
+ // Keyboard users reach it too: a focusable trigger opens it on focus (keyboard focus only, never a mouse click).
153
+ const focus = useFocus(context, { enabled: !disabled, visibleOnly: true });
151
154
  const dismiss = useDismiss(context);
152
155
  const role = useRole(context, { role: 'tooltip' });
153
156
 
154
- const { getReferenceProps, getFloatingProps } = useInteractions([hover, dismiss, role]);
157
+ const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role]);
155
158
 
156
159
  // Destructured once: reaching for `refs.setFloating` inside the JSX is a
157
160
  // property read on floating-ui's ref bag on every render, which the compiler
@@ -117,6 +117,7 @@ export * from './compliance-badge';
117
117
  export * from './feature-card';
118
118
  export * from './feature-list';
119
119
  export { FloatingTooltip } from './floating-tooltip';
120
+ export { Trendline, TrendHistory, TREND_TONES, formatTrendChange, trendlinePoints, trendTone, trendToneClass, type TrendTone, type TrendlineProps, type TrendHistoryProps, type TrendHistoryColumn } from './trendline';
120
121
  export { SourceTooltip, type SourceTooltipProps, type SourceRef } from './source-tooltip';
121
122
  export { TruncateText, type TruncateTextProps } from './truncate-text';
122
123
  export * from './highlight-card';
@@ -0,0 +1,221 @@
1
+ 'use client';
2
+
3
+ import type { MouseEvent, ReactNode } from 'react';
4
+ import { formatNumber } from '../../utils/format';
5
+ import { TextLineSkeleton, UnifiedSkeleton } from '../loading/unified-skeleton';
6
+ import { FloatingTooltip } from './floating-tooltip';
7
+ import { LoadingWhen, useLoadingScope } from './loading-scope';
8
+
9
+ /**
10
+ * THE trend beside a number: a small trendline of its recent values and its change since the previous value, with
11
+ * the number's full history in a hover card. Built for tables and stat cards (one per cell): an inline SVG, no chart
12
+ * library.
13
+ *
14
+ * - **Lazy history.** `details` is a function, called only while the hover card is open, so a component that reads
15
+ * the full history (a fetch on mount) loads it on hover and never for the rows nobody points at.
16
+ * - **Loading.** In a loading scope (the page's, or the host's read through `LoadingWhen`) the trendline draws its own
17
+ * skeleton at its loaded size; with no values it draws the same box empty. Nothing moves when the data lands.
18
+ * - **Colour is earned, as a TONE** (`TrendTone`): a change for the better is `positive`, for the worse `negative`, none
19
+ * `neutral`. Each tone is an ODS token (`TREND_TONES`: success, error, secondary text) a host may replace for one
20
+ * trendline (`tones`). Whether a rise is good is the host's to say (`higherIsBetter`): most numbers a monitor shows
21
+ * count problems.
22
+ *
23
+ * `TrendHistory` is the hover card's body: a title and a grid of columns, one height loading and loaded.
24
+ */
25
+
26
+ const SPARK_W = 56;
27
+ const SPARK_H = 16;
28
+ const SPARK_CLASS = 'h-4 w-14';
29
+ const CHANGE_CLASS = 'w-8 text-right text-h6 tabular-nums';
30
+ const BOX_CLASS = 'inline-flex shrink-0 items-center gap-[var(--spacing-system-xxs)]';
31
+ /** The focus ring of a trendline a keyboard can open (the lib's focus-visible ring). */
32
+ const FOCUS_CLASS = 'rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-ods-accent';
33
+
34
+ /** The change written with its sign: "+3", "−2", "0". */
35
+ export function formatTrendChange(change: number): string {
36
+ return change === 0 ? '0' : `${change > 0 ? '+' : '−'}${formatNumber(Math.abs(change))}`;
37
+ }
38
+
39
+ /** What a change means: better, worse, or none (or unknown). */
40
+ export type TrendTone = 'positive' | 'negative' | 'neutral';
41
+
42
+ /** THE colour of each tone: the ODS semantic tokens (never a raw palette var). */
43
+ export const TREND_TONES: Readonly<Record<TrendTone, string>> = {
44
+ positive: 'text-ods-success',
45
+ negative: 'text-ods-error',
46
+ neutral: 'text-ods-text-secondary',
47
+ };
48
+
49
+ /** The tone of a change: a rise is positive only when `higherIsBetter`; no change (or an unknown one) is neutral. */
50
+ export function trendTone(change: number | null, higherIsBetter = false): TrendTone {
51
+ if (change === null || change === 0) return 'neutral';
52
+ return change > 0 === higherIsBetter ? 'positive' : 'negative';
53
+ }
54
+
55
+ /** The text colour of a change: its tone's class, from `TREND_TONES` or the host's `tones`. */
56
+ export function trendToneClass(change: number | null, higherIsBetter = false, tones: Partial<Record<TrendTone, string>> = {}): string {
57
+ const tone = trendTone(change, higherIsBetter);
58
+ return tones[tone] ?? TREND_TONES[tone];
59
+ }
60
+
61
+ /**
62
+ * Where each known value sits in the line's 56 × 16 box (oldest left), skipping unknown values. Scaled between the
63
+ * series' own lowest and highest value, so negative values stay inside the box and a small move near a large value is
64
+ * still visible; a flat series sits mid-height, a single value in the middle.
65
+ */
66
+ export function trendlinePoints(values: ReadonlyArray<number | null>): Array<{ x: number; y: number }> {
67
+ const known = values
68
+ .map((v, i) => [i, v] as const)
69
+ .filter((p): p is readonly [number, number] => p[1] !== null);
70
+ if (known.length === 0) return [];
71
+ const min = Math.min(...known.map(([, v]) => v));
72
+ const range = Math.max(...known.map(([, v]) => v)) - min;
73
+ const x = (i: number) => (values.length === 1 ? SPARK_W / 2 : (i / (values.length - 1)) * (SPARK_W - 4) + 2);
74
+ const y = (v: number) => (range === 0 ? SPARK_H / 2 : SPARK_H - 2 - ((v - min) / range) * (SPARK_H - 4));
75
+ return known.map(([i, v]) => ({ x: x(i), y: y(v) }));
76
+ }
77
+
78
+ function Spark({ values, toneClass }: { values: ReadonlyArray<number | null>; toneClass: string }) {
79
+ const points = trendlinePoints(values);
80
+ if (points.length === 0) return <svg className={SPARK_CLASS} aria-hidden="true" />;
81
+ const last = points[points.length - 1];
82
+ return (
83
+ <svg className={`${SPARK_CLASS} ${toneClass}`} viewBox={`0 0 ${SPARK_W} ${SPARK_H}`} aria-hidden="true">
84
+ {points.length > 1 && (
85
+ <polyline
86
+ points={points.map((p) => `${p.x},${p.y}`).join(' ')}
87
+ fill="none"
88
+ stroke="currentColor"
89
+ strokeWidth={1.5}
90
+ strokeLinejoin="round"
91
+ strokeLinecap="round"
92
+ />
93
+ )}
94
+ <circle cx={last.x} cy={last.y} r={2} fill="currentColor" />
95
+ </svg>
96
+ );
97
+ }
98
+
99
+ export interface TrendlineProps {
100
+ /** The values, oldest first; null where a value is unknown. Empty = no history (the box stays, empty). */
101
+ values: ReadonlyArray<number | null>;
102
+ /** What the number is: the accessible name, and what the hover card is about. */
103
+ label: string;
104
+ /** The change shown beside the line. Default: the last value minus the one before (none when either is unknown). */
105
+ change?: number | null;
106
+ /** A rise is good (online devices, revenue). Default: a rise is worse (problems, errors). */
107
+ higherIsBetter?: boolean;
108
+ /** Replace a tone's colour for this trendline (an ODS text class, e.g. `{ positive: 'text-ods-accent' }`). */
109
+ tones?: Partial<Record<TrendTone, string>>;
110
+ /** The hover card's body, called only while it is open (load the full history here). None: no hover card. */
111
+ details?: () => ReactNode;
112
+ side?: 'top' | 'right' | 'bottom' | 'left';
113
+ }
114
+
115
+ export function Trendline({ values, label, change, higherIsBetter = false, tones, details, side = 'top' }: TrendlineProps) {
116
+ // The ONE switch: in a loading scope, the skeleton at the loaded size.
117
+ if (useLoadingScope()) {
118
+ return (
119
+ <span className={BOX_CLASS} aria-hidden="true">
120
+ <UnifiedSkeleton as="span" className={`${SPARK_CLASS} rounded-sm`} />
121
+ <span className={CHANGE_CLASS} />
122
+ </span>
123
+ );
124
+ }
125
+ if (values.length === 0) {
126
+ return (
127
+ <span className={BOX_CLASS} aria-hidden="true">
128
+ <span className={SPARK_CLASS} />
129
+ <span className={CHANGE_CLASS} />
130
+ </span>
131
+ );
132
+ }
133
+ const last = values[values.length - 1] ?? null;
134
+ const before = values.length > 1 ? (values[values.length - 2] ?? null) : null;
135
+ const delta = change !== undefined ? change : last !== null && before !== null ? last - before : null;
136
+ const toneClass = trendToneClass(delta, higherIsBetter, tones);
137
+ const line = (
138
+ <span
139
+ className={details ? `${BOX_CLASS} ${FOCUS_CLASS}` : BOX_CLASS}
140
+ // A trendline sits inside clickable cards and rows: pointing at it must not also click them.
141
+ onClick={(e: MouseEvent) => e.stopPropagation()}
142
+ aria-label={`${label}: last ${values.length} values${delta === null ? '' : `, ${formatTrendChange(delta)}`}`}
143
+ // With a history behind it, a keyboard reaches it too: focusing it opens the card (FloatingTooltip opens on focus).
144
+ role={details ? 'button' : 'img'}
145
+ tabIndex={details ? 0 : undefined}
146
+ aria-haspopup={details ? 'dialog' : undefined}
147
+ >
148
+ <Spark values={values} toneClass={toneClass} />
149
+ <span className={`${CHANGE_CLASS} ${toneClass}`}>{delta === null ? '' : formatTrendChange(delta)}</span>
150
+ </span>
151
+ );
152
+ if (!details) return line;
153
+ return (
154
+ <FloatingTooltip as="span" side={side} triggerClassName={BOX_CLASS} content={<TrendDetails render={details} />}>
155
+ {line}
156
+ </FloatingTooltip>
157
+ );
158
+ }
159
+
160
+ /** Mounted only while the hover card is open, so `render` (and any read it starts) runs on hover. */
161
+ function TrendDetails({ render }: { render: () => ReactNode }) {
162
+ return <>{render()}</>;
163
+ }
164
+
165
+ /* ---------------------------------- history --------------------------------- */
166
+
167
+ export interface TrendHistoryColumn {
168
+ label: string;
169
+ /** Numbers align right. */
170
+ align?: 'left' | 'right';
171
+ }
172
+
173
+ export interface TrendHistoryProps {
174
+ title: string;
175
+ columns: TrendHistoryColumn[];
176
+ /** One row per value, each a cell per column; null while the history loads. */
177
+ rows: ReactNode[][] | null;
178
+ /** Rows drawn while loading (the number of values the trendline already shows). */
179
+ loadingRows: number;
180
+ /** Shown in place of the grid when the history could not be read. */
181
+ error?: string | null;
182
+ /** Anything after the grid (who changed, a link). */
183
+ children?: ReactNode;
184
+ }
185
+
186
+ /**
187
+ * The hover card's body for a `Trendline`: a title, then the history as a grid (the chart tooltips' anatomy: muted
188
+ * headers, primary values). Every row draws its own skeleton cells while `rows` is null, so the card is one height
189
+ * loading and loaded.
190
+ */
191
+ export function TrendHistory({ title, columns, rows, loadingRows, error, children }: TrendHistoryProps) {
192
+ const grid = { gridTemplateColumns: `1fr ${'auto '.repeat(Math.max(0, columns.length - 1)).trim()}` };
193
+ const alignClass = (c: TrendHistoryColumn) => (c.align === 'right' ? 'text-right tabular-nums' : 'text-left');
194
+ return (
195
+ <div className="flex w-72 flex-col gap-[var(--spacing-system-sf)] whitespace-normal text-h6">
196
+ <span className="text-ods-text-primary">{title}</span>
197
+ {error ? (
198
+ <span className="text-ods-text-secondary">{error}</span>
199
+ ) : (
200
+ <LoadingWhen loading={rows === null}>
201
+ <div className="grid gap-x-[var(--spacing-system-mf)] gap-y-[var(--spacing-system-xxs)]" style={grid}>
202
+ {columns.map((c) => (
203
+ <span key={c.label} className={`${alignClass(c)} text-ods-text-secondary`}>
204
+ {c.label}
205
+ </span>
206
+ ))}
207
+ {(rows ?? Array.from({ length: loadingRows }, () => null)).map((row, r) =>
208
+ columns.map((c, i) => <TrendHistoryCell key={`${r}:${c.label}`} column={c} value={row ? row[i] : null} />),
209
+ )}
210
+ </div>
211
+ </LoadingWhen>
212
+ )}
213
+ {children}
214
+ </div>
215
+ );
216
+ }
217
+
218
+ function TrendHistoryCell({ column, value }: { column: TrendHistoryColumn; value: ReactNode }) {
219
+ if (useLoadingScope()) return <TextLineSkeleton type="h6" className={column.align === 'right' ? 'ml-auto w-8' : 'w-12'} />;
220
+ return <span className={`${column.align === 'right' ? 'text-right tabular-nums' : 'text-left'} text-ods-text-primary`}>{value}</span>;
221
+ }