oneslash-design-system 2.23.0 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +13 -2
  3. package/dist/cases/activity-timeline/activity.d.ts +1 -0
  4. package/dist/cases/activity-timeline/activity.jsx +43 -0
  5. package/dist/cases/activity-timeline/versions.d.ts +1 -0
  6. package/dist/cases/activity-timeline/versions.jsx +130 -0
  7. package/dist/cases/activity-timeline.md +315 -0
  8. package/dist/cases/agent-plan-proposal.md +1 -0
  9. package/dist/cases/ask-page/answered.d.ts +1 -0
  10. package/dist/cases/ask-page/answered.jsx +240 -0
  11. package/dist/cases/ask-page/first-visit.d.ts +1 -0
  12. package/dist/cases/ask-page/first-visit.jsx +118 -0
  13. package/dist/cases/ask-page.md +542 -0
  14. package/dist/cases/chart/bars.d.ts +1 -0
  15. package/dist/cases/chart/bars.jsx +83 -0
  16. package/dist/cases/chart/lines.d.ts +1 -0
  17. package/dist/cases/chart/lines.jsx +71 -0
  18. package/dist/cases/chart.md +258 -0
  19. package/dist/cases/comment-thread/card.d.ts +1 -0
  20. package/dist/cases/comment-thread/card.jsx +141 -0
  21. package/dist/cases/comment-thread/thread.d.ts +1 -0
  22. package/dist/cases/comment-thread/thread.jsx +87 -0
  23. package/dist/cases/comment-thread.md +349 -0
  24. package/dist/cases/dashboard/numbers-first.jsx +62 -1
  25. package/dist/cases/dashboard.md +75 -3
  26. package/dist/cases/leaderboard/ranked.d.ts +1 -0
  27. package/dist/cases/leaderboard/ranked.jsx +44 -0
  28. package/dist/cases/leaderboard/table.d.ts +1 -0
  29. package/dist/cases/leaderboard/table.jsx +87 -0
  30. package/dist/cases/leaderboard.md +177 -0
  31. package/dist/cases/number-format.md +4 -2
  32. package/dist/cases/onboarding/checklist.d.ts +1 -0
  33. package/dist/cases/onboarding/checklist.jsx +92 -0
  34. package/dist/cases/onboarding/steps.d.ts +3 -0
  35. package/dist/cases/onboarding/steps.jsx +177 -0
  36. package/dist/cases/onboarding.md +368 -0
  37. package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
  38. package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
  39. package/dist/cases/plan-sign-off/team.d.ts +1 -0
  40. package/dist/cases/plan-sign-off/team.jsx +213 -0
  41. package/dist/cases/plan-sign-off.md +541 -0
  42. package/dist/cases/stat-row.md +1 -1
  43. package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
  44. package/dist/cases/task-header/agent-sets-status.jsx +164 -0
  45. package/dist/cases/task-header/people-change-status.d.ts +1 -0
  46. package/dist/cases/task-header/people-change-status.jsx +175 -0
  47. package/dist/cases/task-header.md +576 -0
  48. package/dist/cases.json +645 -7
  49. package/dist/components/barChart.d.ts +35 -0
  50. package/dist/components/barChart.jsx +90 -0
  51. package/dist/components/heading.d.ts +2 -2
  52. package/dist/components/heading.jsx +5 -3
  53. package/dist/components/lineChart.d.ts +39 -0
  54. package/dist/components/lineChart.jsx +128 -0
  55. package/dist/components/popover.jsx +7 -2
  56. package/dist/components/timeline.d.ts +32 -0
  57. package/dist/components/timeline.jsx +54 -0
  58. package/dist/components/titleBar.d.ts +3 -1
  59. package/dist/components/titleBar.jsx +9 -4
  60. package/dist/internal/chart.d.ts +39 -0
  61. package/dist/internal/chart.js +110 -0
  62. package/dist/internal/chartFrame.d.ts +29 -0
  63. package/dist/internal/chartFrame.jsx +57 -0
  64. package/dist/native-mapping.json +19 -1
  65. package/dist/stories/BarChart.stories.d.ts +10 -0
  66. package/dist/stories/BarChart.stories.jsx +104 -0
  67. package/dist/stories/Cases.generated.stories.d.ts +16 -0
  68. package/dist/stories/Cases.generated.stories.jsx +32 -0
  69. package/dist/stories/Heading.stories.d.ts +1 -0
  70. package/dist/stories/Heading.stories.jsx +17 -0
  71. package/dist/stories/LineChart.stories.d.ts +9 -0
  72. package/dist/stories/LineChart.stories.jsx +34 -0
  73. package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
  74. package/dist/stories/Onboarding.probe.stories.jsx +12 -0
  75. package/dist/stories/Popover.stories.d.ts +1 -0
  76. package/dist/stories/Popover.stories.jsx +17 -0
  77. package/dist/stories/Timeline.stories.d.ts +8 -0
  78. package/dist/stories/Timeline.stories.jsx +49 -0
  79. package/dist/stories/TitleBar.stories.d.ts +1 -0
  80. package/dist/stories/TitleBar.stories.jsx +13 -0
  81. package/package.json +1 -1
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { type ChartFormat } from '../internal/chart';
3
+ export interface BarChartPoint {
4
+ /** The x label as the caller wrote it: 'Nov 14' */
5
+ label: string;
6
+ /** `null` is no data: no bar, and 'No data' in the readout and the table. Never drawn as 0. */
7
+ value: number | null;
8
+ }
9
+ export interface BarChartProps {
10
+ id?: string;
11
+ title: string;
12
+ /** One sentence written from the data: 'Comments rose from 40 on Nov 10 to 72 on Nov 16.' */
13
+ summary: string;
14
+ data: BarChartPoint[];
15
+ /** What is counted, after the number in the readout ('58 comments') and as the table's value column */
16
+ unit?: string;
17
+ /** The table's first column, naming the labels. 'Date' fits days and weeks; name it for anything else ('Team'). */
18
+ labelHeader?: string;
19
+ format?: ChartFormat;
20
+ /** The plot's height in px */
21
+ height?: number;
22
+ loading?: boolean;
23
+ /** Shown in the plot's place when no point has a value */
24
+ emptyText?: string;
25
+ /** Names the plot in place of the title */
26
+ 'aria-label'?: string;
27
+ }
28
+ /**
29
+ * A column chart of one count per day or week, drawn by ODS: HTML columns sized in percent, so the server
30
+ * and the browser render the same markup. The y axis starts at 0 with round ticks, short on the axis and
31
+ * exact in the readout and the table. The plot is one tab stop: Left, Right, Home and End move the
32
+ * highlighted bar, and the readout line under the title says its value. 'Show Table' gives the exact values.
33
+ * A 0 or a value below 0 draws no bar (the axis starts at 0); its readout and table row give the value.
34
+ */
35
+ export default function BarChart({ id, title, summary, data, unit, labelHeader, format, height, loading, emptyText, 'aria-label': ariaLabel, }: BarChartProps): React.JSX.Element;
@@ -0,0 +1,90 @@
1
+ 'use client';
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ import React, { useId, useRef, useState } from 'react';
12
+ import ChartFrame, { labelRow, plotTop } from '../internal/chartFrame';
13
+ import { axisText, exactText, labelEvery, nextPoint, niceTicks } from '../internal/chart';
14
+ import { focusRing } from './sharedStyles';
15
+ var pct = function (n) { return "".concat(Math.round(n * 10000) / 100, "%"); };
16
+ /**
17
+ * A column chart of one count per day or week, drawn by ODS: HTML columns sized in percent, so the server
18
+ * and the browser render the same markup. The y axis starts at 0 with round ticks, short on the axis and
19
+ * exact in the readout and the table. The plot is one tab stop: Left, Right, Home and End move the
20
+ * highlighted bar, and the readout line under the title says its value. 'Show Table' gives the exact values.
21
+ * A 0 or a value below 0 draws no bar (the axis starts at 0); its readout and table row give the value.
22
+ */
23
+ export default function BarChart(_a) {
24
+ var id = _a.id, title = _a.title, summary = _a.summary, data = _a.data, unit = _a.unit, _b = _a.labelHeader, labelHeader = _b === void 0 ? 'Date' : _b, _c = _a.format, format = _c === void 0 ? 'count' : _c, _d = _a.height, height = _d === void 0 ? 200 : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.emptyText, emptyText = _f === void 0 ? 'No data for this range yet' : _f, ariaLabel = _a["aria-label"];
25
+ var autoId = useId();
26
+ var base = id !== null && id !== void 0 ? id : "bar-chart-".concat(autoId.replace(/:/g, ''));
27
+ var _g = useState(-1), active = _g[0], setActive = _g[1];
28
+ var plotRef = useRef(null);
29
+ var values = data.map(function (d) { return d.value; }).filter(function (v) { return v !== null && Number.isFinite(v); });
30
+ var empty = values.length === 0;
31
+ // A count never gets a fractional tick
32
+ var ticks = niceTicks(Math.max.apply(Math, __spreadArray([0], values, false)), 4, { integer: format === 'count' });
33
+ var top = ticks[ticks.length - 1];
34
+ var labels = new Set(labelEvery(data.length));
35
+ var step = data.length > 0 ? Math.ceil(data.length / 6) : 1;
36
+ var point = data[active];
37
+ var readout = point ? "".concat(point.label, ": ").concat(exactText(point.value, format, unit)) : '';
38
+ var table = {
39
+ columns: [labelHeader, unit ? unit.charAt(0).toUpperCase() + unit.slice(1) : 'Value'],
40
+ rows: data.map(function (d) { return [d.label, exactText(d.value, format)]; }),
41
+ };
42
+ var onKeyDown = function (e) {
43
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key))
44
+ return;
45
+ // The keys move the bar, not the page
46
+ e.preventDefault();
47
+ setActive(nextPoint(e.key, active, data.length));
48
+ };
49
+ // Pointer leave keeps the bar a keyboard user chose
50
+ var onPointerLeave = function () {
51
+ if (typeof document !== 'undefined' && document.activeElement === plotRef.current)
52
+ return;
53
+ setActive(-1);
54
+ };
55
+ var plot = (<div ref={plotRef} role="group" tabIndex={0} aria-label={ariaLabel} aria-labelledby={ariaLabel ? undefined : "".concat(base, "-title")} aria-describedby={"".concat(base, "-summary")} onKeyDown={onKeyDown} onPointerLeave={onPointerLeave} onBlur={function () { return setActive(-1); }} className={"rounded-control ".concat(focusRing)}>
56
+ <div aria-hidden="true" className={"flex ".concat(plotTop)}>
57
+ {/* Each tick is a line of no height, so justify-between puts it on its gridline */}
58
+ <div className="flex min-w-[16px] flex-col justify-between pr-medium text-caption text-fg-secondary" style={{ height: height }}>
59
+ {__spreadArray([], ticks, true).reverse().map(function (t) { return (<span key={t} className="flex h-0 items-center justify-end whitespace-nowrap">{axisText(t, format)}</span>); })}
60
+ </div>
61
+ <div className="flex min-w-0 flex-1 flex-col">
62
+ <div className="relative" style={{ height: height }}>
63
+ {ticks.map(function (t) { return (<div key={t} className="absolute inset-x-0 border-t border-misc-divider" style={{ bottom: pct(t / top) }}/>); })}
64
+ <div className="absolute inset-0 flex items-end gap-0.5">
65
+ {data.map(function (d, i) { return (<div key={i} className="flex h-full min-w-0 flex-1 items-end justify-center" onPointerEnter={function () { return setActive(i); }}>
66
+ {d.value !== null && d.value > 0 && Number.isFinite(d.value) && (<div className={"w-full max-w-[64px] rounded-t border-2 border-transparent ".concat(i === active ? 'bg-fg-primary outline outline-2 outline-offset-1 outline-fg-primary' : 'bg-primary-main')} style={{ height: pct(d.value / top) }}/>)}
67
+ </div>); })}
68
+ </div>
69
+ </div>
70
+ <div className={"".concat(labelRow, " text-caption text-fg-secondary")}>
71
+ {data.map(function (d, i) {
72
+ if (!labels.has(i))
73
+ return null;
74
+ var slot = 1 / data.length;
75
+ // A label may take the room up to the next label. The last keeps to the plot's right edge; the first may
76
+ // reach 16px into the tick column, which is never narrower, so nothing scrolls sideways
77
+ var room = pct(step * slot);
78
+ var style = step > 1 && i === data.length - 1
79
+ ? { right: 0, maxWidth: room }
80
+ : { left: pct((i + 0.5) * slot), maxWidth: i === 0 ? "min(".concat(room, ", calc(").concat(pct(slot), " + 32px))") : room, transform: 'translateX(-50%)' };
81
+ return (<span key={i} title={d.label} className="absolute top-0 truncate text-center" style={style}>
82
+ {d.label}
83
+ </span>);
84
+ })}
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>);
89
+ return (<ChartFrame id={base} title={title} summary={summary} readout={readout} loading={loading} empty={empty} emptyText={emptyText} table={table} plot={plot} height={height}/>);
90
+ }
@@ -12,5 +12,5 @@ interface HeadingProps {
12
12
  /** -1 lets a page move focus to the heading (a pane's title on open) without putting it in the tab order. */
13
13
  tabIndex?: number;
14
14
  }
15
- export default function Heading({ children, level, size, color, id, className, tabIndex }: HeadingProps): React.JSX.Element;
16
- export {};
15
+ declare const Heading: React.ForwardRefExoticComponent<HeadingProps & React.RefAttributes<HTMLHeadingElement>>;
16
+ export default Heading;
@@ -5,10 +5,12 @@ var sizes = {
5
5
  h6: 'text-h6',
6
6
  subtitle1: 'text-subtitle1',
7
7
  };
8
- export default function Heading(_a) {
8
+ // The ref lands on the heading element, so a screen can move focus to a step's heading (with tabIndex -1).
9
+ var Heading = React.forwardRef(function Heading(_a, ref) {
9
10
  var children = _a.children, _b = _a.level, level = _b === void 0 ? 3 : _b, _c = _a.size, size = _c === void 0 ? 'h6' : _c, _d = _a.color, color = _d === void 0 ? 'default' : _d, id = _a.id, _e = _a.className, className = _e === void 0 ? '' : _e, tabIndex = _a.tabIndex;
10
11
  var Tag = "h".concat(level);
11
- return (<Tag id={id} tabIndex={tabIndex} className={"".concat(sizes[size], " ").concat(color === 'danger' ? 'text-error-text' : 'text-fg-primary', " ").concat(className)}>
12
+ return (<Tag ref={ref} id={id} tabIndex={tabIndex} className={"".concat(sizes[size], " ").concat(color === 'danger' ? 'text-error-text' : 'text-fg-primary', " ").concat(className)}>
12
13
  {children}
13
14
  </Tag>);
14
- }
15
+ });
16
+ export default Heading;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { type ChartFormat } from '../internal/chart';
3
+ export interface LineSeries {
4
+ /** Read after each value, so a lower-case word fits: 'opened' reads '58 opened'. The legend and the table capitalize it. */
5
+ name: string;
6
+ /**
7
+ * One value per label. `null` is no data: the line breaks there, and the readout and the table say 'No data'.
8
+ * The y axis starts at 0, so a value below 0 is drawn at 0; the readout and the table keep the value.
9
+ */
10
+ values: (number | null)[];
11
+ }
12
+ export interface LineChartProps {
13
+ id?: string;
14
+ title: string;
15
+ /** One sentence written from the data: 'More tasks were opened than done on every day but Nov 12.' */
16
+ summary: string;
17
+ /** The x labels as the caller wrote them: 'Nov 14' */
18
+ labels: string[];
19
+ /** One or two series. The first is a solid `primary.main` line, the second a dashed `text.secondary` one. */
20
+ series: [LineSeries] | [LineSeries, LineSeries];
21
+ /** What is counted, after each number in the readout and the table: unit 'tasks' reads '58 tasks opened' */
22
+ unit?: string;
23
+ /** The table's first column, naming the labels */
24
+ labelHeader?: string;
25
+ format?: ChartFormat;
26
+ /** The plot's height in px */
27
+ height?: number;
28
+ loading?: boolean;
29
+ /** Shown in the plot's place when no point has a value */
30
+ emptyText?: string;
31
+ }
32
+ /**
33
+ * A line chart of one or two trends, drawn by ODS: one SVG path per series stretched over the plot with a
34
+ * stroke that does not scale, and every label in HTML, so the server and the browser render the same markup.
35
+ * A `null` breaks the line; a point with no neighbour on either side shows as a dot. The plot is one tab stop:
36
+ * Left, Right, Home and End move the highlighted day, and the readout line under the title names every series.
37
+ * 'Show Table' gives the exact values.
38
+ */
39
+ export default function LineChart({ id, title, summary, labels, series, unit, labelHeader, format, height, loading, emptyText, }: LineChartProps): React.JSX.Element;
@@ -0,0 +1,128 @@
1
+ 'use client';
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ import React, { useId, useRef, useState } from 'react';
12
+ import ChartFrame, { labelRow, plotTop } from '../internal/chartFrame';
13
+ import { axisText, exactText, labelEvery, linePath, nextPoint, niceTicks, pointX, seriesReadout } from '../internal/chart';
14
+ import { focusRing } from './sharedStyles';
15
+ var pct = function (n) { return "".concat(Math.round(n * 10000) / 100, "%"); };
16
+ var has = function (v) { return typeof v === 'number' && Number.isFinite(v); };
17
+ var capitalize = function (s) { return s.charAt(0).toUpperCase() + s.slice(1); };
18
+ // Series 1 solid in primary.main, series 2 dashed in text.secondary, so they never rely on hue. In forced colors
19
+ // the stroke is CanvasText: the system keeps an SVG's own colour, which can be dark grey on a black Canvas
20
+ var forced = '[@media(forced-colors:active)]:[stroke:CanvasText]';
21
+ var looks = [
22
+ { stroke: "stroke-current text-primary-main ".concat(forced), dot: 'bg-primary-main', dash: undefined },
23
+ { stroke: "stroke-current text-fg-secondary ".concat(forced), dot: 'bg-fg-secondary', dash: '6 4' },
24
+ ];
25
+ /**
26
+ * A line chart of one or two trends, drawn by ODS: one SVG path per series stretched over the plot with a
27
+ * stroke that does not scale, and every label in HTML, so the server and the browser render the same markup.
28
+ * A `null` breaks the line; a point with no neighbour on either side shows as a dot. The plot is one tab stop:
29
+ * Left, Right, Home and End move the highlighted day, and the readout line under the title names every series.
30
+ * 'Show Table' gives the exact values.
31
+ */
32
+ export default function LineChart(_a) {
33
+ var id = _a.id, title = _a.title, summary = _a.summary, labels = _a.labels, series = _a.series, unit = _a.unit, _b = _a.labelHeader, labelHeader = _b === void 0 ? 'Date' : _b, _c = _a.format, format = _c === void 0 ? 'count' : _c, _d = _a.height, height = _d === void 0 ? 200 : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.emptyText, emptyText = _f === void 0 ? 'No data for this range yet' : _f;
34
+ var autoId = useId();
35
+ var base = id !== null && id !== void 0 ? id : "line-chart-".concat(autoId.replace(/:/g, ''));
36
+ var _g = useState(-1), active = _g[0], setActive = _g[1];
37
+ var plotRef = useRef(null);
38
+ var n = labels.length;
39
+ var values = series.flatMap(function (s) { return s.values.slice(0, n); }).filter(has);
40
+ var empty = n === 0 || values.length === 0;
41
+ var ticks = niceTicks(Math.max.apply(Math, __spreadArray([0], values, false)), 4, { integer: format === 'count' });
42
+ var top = ticks[ticks.length - 1];
43
+ // Past 24 points six labels leave too little room for 'Oct 18' on a phone, so a month gets four
44
+ var most = n > 24 ? 4 : 6;
45
+ var shown = labelEvery(n, most);
46
+ // Labels sit a step apart or more: each may take two thirds of a step, so a centered one and its neighbour never touch
47
+ var room = n > 1 ? (Math.ceil(n / most) / (n - 1)) * (2 / 3) : 1;
48
+ var readout = active >= 0 && active < n
49
+ ? seriesReadout(labels[active], series.map(function (s) { var _a; return ({ name: s.name, value: (_a = s.values[active]) !== null && _a !== void 0 ? _a : null }); }), format, unit)
50
+ : '';
51
+ var table = {
52
+ columns: __spreadArray([labelHeader], series.map(function (s) { return capitalize(s.name); }), true),
53
+ rows: labels.map(function (label, i) { return __spreadArray([label], series.map(function (s) { var _a; return exactText((_a = s.values[i]) !== null && _a !== void 0 ? _a : null, format, unit); }), true); }),
54
+ };
55
+ var onKeyDown = function (e) {
56
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key))
57
+ return;
58
+ // The keys move the day, not the page
59
+ e.preventDefault();
60
+ setActive(nextPoint(e.key, active, n));
61
+ };
62
+ // Pointer leave keeps the day a keyboard user chose
63
+ var onPointerLeave = function () {
64
+ if (typeof document !== 'undefined' && document.activeElement === plotRef.current)
65
+ return;
66
+ setActive(-1);
67
+ };
68
+ // Shown while loading too, so the plot does not move down when the data arrives
69
+ var legend = series.length > 1 && (loading || !empty) ? (<ul className="flex flex-wrap gap-x-large gap-y-small">
70
+ {series.map(function (s, k) { return (<li key={k} className="flex items-center gap-small">
71
+ <svg width="24" height="8" viewBox="0 0 24 8" aria-hidden="true">
72
+ <line x1="0" y1="4" x2="24" y2="4" className={looks[k].stroke} strokeDasharray={looks[k].dash} strokeWidth={2}/>
73
+ </svg>
74
+ <span className="text-body2 text-fg-primary">{capitalize(s.name)}</span>
75
+ </li>); })}
76
+ </ul>) : undefined;
77
+ var plot = (<div ref={plotRef} role="group" tabIndex={0} aria-labelledby={"".concat(base, "-title")} aria-describedby={"".concat(base, "-summary")} onKeyDown={onKeyDown} onPointerLeave={onPointerLeave} onBlur={function () { return setActive(-1); }} className={"rounded-control ".concat(focusRing)}>
78
+ {/* Room on the right for the last point's dot, so it never reaches past the figure */}
79
+ <div aria-hidden="true" className={"flex pr-1.5 ".concat(plotTop)}>
80
+ {/* Each tick is a line of no height, so justify-between puts it on its gridline */}
81
+ <div className="flex min-w-[16px] flex-col justify-between pr-medium text-caption text-fg-secondary" style={{ height: height }}>
82
+ {__spreadArray([], ticks, true).reverse().map(function (t) { return (<span key={t} className="flex h-0 items-center justify-end whitespace-nowrap">{axisText(t, format)}</span>); })}
83
+ </div>
84
+ <div className="flex min-w-0 flex-1 flex-col">
85
+ <div className="relative" style={{ height: height }}>
86
+ {ticks.map(function (t) { return (<div key={t} className="absolute inset-x-0 border-t border-misc-divider" style={{ bottom: pct(t / top) }}/>); })}
87
+ {active >= 0 && active < n && (<div className="absolute inset-y-0 border-l border-misc-divider" style={{ left: pct(pointX(active, n) / 100) }}/>)}
88
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true" className="absolute inset-0 h-full w-full overflow-visible">
89
+ {series.map(function (s, k) { return (<path key={k} d={linePath(s.values.slice(0, n), top)} fill="none" vectorEffect="non-scaling-stroke" strokeWidth={2} strokeLinejoin="round" strokeLinecap="round" className={looks[k].stroke} strokeDasharray={looks[k].dash}/>); })}
90
+ </svg>
91
+ {series.map(function (s, k) {
92
+ return labels.map(function (_, i) {
93
+ var v = s.values[i];
94
+ if (!has(v))
95
+ return null;
96
+ // A point with no neighbour draws no line, so it shows as a dot; the chosen day shows one per series
97
+ var lone = !has(s.values[i - 1]) && !has(s.values[i + 1]);
98
+ if (!lone && i !== active)
99
+ return null;
100
+ return (<span key={"".concat(k, "-").concat(i)} className={"absolute h-3 w-3 rounded-full border-2 border-background-default ".concat(looks[k].dot)} style={{ left: pct(pointX(i, n) / 100), bottom: pct(Math.max(0, v) / top), transform: 'translate(-50%, 50%)' }}/>);
101
+ });
102
+ })}
103
+ {/* One hit area per day, reaching halfway to its neighbours */}
104
+ <div className="absolute inset-0 flex">
105
+ {labels.map(function (_, i) { return (<div key={i} className="h-full" style={{ flexGrow: n > 1 && (i === 0 || i === n - 1) ? 1 : 2, flexBasis: 0 }} onPointerEnter={function () { return setActive(i); }}/>); })}
106
+ </div>
107
+ </div>
108
+ <div className={"".concat(labelRow, " text-caption text-fg-secondary")}>
109
+ {shown.map(function (i) {
110
+ var x = pointX(i, n) / 100;
111
+ // The first and the last keep to the plot's edges; the rest are centered on their point
112
+ var style = n === 1
113
+ ? { left: '50%', maxWidth: '100%', transform: 'translateX(-50%)' }
114
+ : i === 0
115
+ ? { left: 0, maxWidth: pct(room) }
116
+ : i === n - 1
117
+ ? { right: 0, maxWidth: pct(room) }
118
+ : { left: pct(x), maxWidth: pct(room), transform: 'translateX(-50%)' };
119
+ return (<span key={i} title={labels[i]} className="absolute top-0 truncate text-center" style={style}>
120
+ {labels[i]}
121
+ </span>);
122
+ })}
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </div>);
127
+ return (<ChartFrame id={base} title={title} summary={summary} readout={readout} loading={loading} empty={empty} emptyText={emptyText} table={table} plot={plot} height={height} legend={legend}/>);
128
+ }
@@ -56,16 +56,21 @@ export default function Popover(_a) {
56
56
  }, [open, anchorEl, popoverElement, onClose, returnFocus]);
57
57
  // On close, wait one task so a click outside has moved focus first: a click on something
58
58
  // focusable keeps it there; a click on nothing leaves it on the body, and then the anchor takes it.
59
+ // A caller may clear `anchorEl` in the same render that closes it, so the last one set is kept.
59
60
  var wasOpen = useRef(open);
61
+ var lastAnchor = useRef(anchorEl);
62
+ if (anchorEl)
63
+ lastAnchor.current = anchorEl;
60
64
  useEffect(function () {
61
65
  var closed = wasOpen.current && !open;
62
66
  wasOpen.current = open;
63
- if (!closed || !returnFocus || !anchorEl)
67
+ var target = lastAnchor.current;
68
+ if (!closed || !returnFocus || !target)
64
69
  return;
65
70
  var timer = setTimeout(function () {
66
71
  var active = document.activeElement;
67
72
  if (!active || active === document.body || (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(active)))
68
- anchorEl.focus();
73
+ target.focus();
69
74
  }, 0);
70
75
  return function () { return clearTimeout(timer); };
71
76
  }, [open]); // eslint-disable-line react-hooks/exhaustive-deps
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ export interface TimelineItem {
3
+ id: string;
4
+ title: string;
5
+ /** The time as the caller wrote it ('Nov 16, 2026, 2:40 PM'), so the server and the browser print the same */
6
+ when: string;
7
+ /** The ISO value for `<time dateTime>` */
8
+ dateTime: string;
9
+ /** Who did it. `agent` shows the agent face and no picture. */
10
+ actor?: {
11
+ name: string;
12
+ imageUrl?: string;
13
+ agent?: boolean;
14
+ };
15
+ detail?: string;
16
+ /** Makes the title a link. Ignored with `onSelect`: the row is a button then, and a link cannot sit in a button. */
17
+ href?: string;
18
+ tag?: {
19
+ label: string;
20
+ color?: 'info' | 'warning' | 'error' | 'success';
21
+ };
22
+ }
23
+ export interface TimelineProps {
24
+ items: TimelineItem[];
25
+ 'aria-label'?: string;
26
+ /** The row marked `aria-current="true"`, with the selected fill. Only with `onSelect`. */
27
+ selectedId?: string;
28
+ /** Makes each row one button that calls this with the row's id */
29
+ onSelect?: (id: string) => void;
30
+ id?: string;
31
+ }
32
+ export default function Timeline({ items, 'aria-label': ariaLabel, selectedId, onSelect, id }: TimelineProps): React.JSX.Element | null;
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import { Bot } from 'lucide-react';
4
+ import UserImage from './userImage';
5
+ import Tag from './tag';
6
+ import Link from './link';
7
+ import { focusRing, stateTransition } from './sharedStyles';
8
+ // A history or an activity feed: who did what, and when. An ordered list in the caller's order
9
+ // (newest first). Each row has a dot level with the title's first line and a line down to the next
10
+ // row; the last row has no line. The dot is the same for every row, so color carries nothing.
11
+ // With `onSelect` each row is one button and every row is a tab stop: a history is read top to
12
+ // bottom, not moved through, so there is no roving focus. Empty `items` renders nothing; the caller
13
+ // shows `EmptyBox`. Not a `StepList`: a step list is a plan's status, a timeline has actors and times.
14
+ export default function Timeline(_a) {
15
+ var items = _a.items, ariaLabel = _a["aria-label"], selectedId = _a.selectedId, onSelect = _a.onSelect, id = _a.id;
16
+ if (items.length === 0)
17
+ return null;
18
+ var selectable = !!onSelect;
19
+ return (<ol role="list" id={id} aria-label={ariaLabel} className="flex flex-col">
20
+ {items.map(function (item, i) {
21
+ var last = i === items.length - 1;
22
+ var selected = selectable && item.id === selectedId;
23
+ var title = (<span className="break-words text-body1 text-fg-primary">
24
+ {item.href && !selectable ? <Link href={item.href}>{item.title}</Link> : item.title}
25
+ </span>);
26
+ var body = (<>
27
+ {title}
28
+ <span className="flex flex-wrap items-center gap-small text-body2 text-fg-secondary">
29
+ {item.actor && (<>
30
+ <UserImage decorative size={20} userHandle={item.actor.name} userImgUrl={item.actor.agent ? undefined : item.actor.imageUrl} icon={item.actor.agent ? Bot : undefined}/>
31
+ <span>{item.actor.name}</span>
32
+ <span aria-hidden="true"> · </span>
33
+ </>)}
34
+ <time dateTime={item.dateTime}>{item.when}</time>
35
+ </span>
36
+ {item.detail && <span className="break-words text-body2 text-fg-secondary">{item.detail}</span>}
37
+ {item.tag && (<span className="flex pt-small">
38
+ <Tag variant="dot" size="small" color={item.tag.color} label={item.tag.label}/>
39
+ </span>)}
40
+ </>);
41
+ return (<li key={item.id} className={"flex gap-small ".concat(last ? '' : 'pb-medium')}>
42
+ <span aria-hidden="true" className={"flex w-6 flex-shrink-0 flex-col items-center ".concat(selectable ? 'pt-small' : '', " ").concat(last ? '' : '-mb-medium')}>
43
+ <span className="flex h-6 items-center justify-center">
44
+ <span className="w-2.5 h-2.5 rounded-full bg-fg-secondary"/>
45
+ </span>
46
+ {!last && <span className="w-px flex-1 bg-misc-divider"/>}
47
+ </span>
48
+ {selectable ? (<button type="button" aria-current={selected ? 'true' : undefined} onClick={function () { return onSelect(item.id); }} className={"flex min-w-0 flex-1 w-full flex-col text-left px-medium py-small rounded-control cursor-pointer ".concat(selected ? 'bg-background-accent200' : 'hover:bg-background-accent100', " ").concat(stateTransition, " ").concat(focusRing)}>
49
+ {body}
50
+ </button>) : (<span className="flex min-w-0 flex-1 flex-col">{body}</span>)}
51
+ </li>);
52
+ })}
53
+ </ol>);
54
+ }
@@ -12,8 +12,10 @@ interface TitleBarProps {
12
12
  actionsBelow?: boolean;
13
13
  /** Below md these replace `actions`: the main action and a More menu holding the rest */
14
14
  phoneActions?: React.ReactNode;
15
+ /** One line under the title: a status Tag, an AvatarStack, short facts. It wraps at every width and is not part of the heading. */
16
+ meta?: React.ReactNode;
15
17
  /** The heading's id */
16
18
  id?: string;
17
19
  }
18
- export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, id }: TitleBarProps): React.JSX.Element;
20
+ export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, meta, id }: TitleBarProps): React.JSX.Element;
19
21
  export { TitleBar };
@@ -4,13 +4,18 @@ import Heading from './heading';
4
4
  // A row without Back is one row at every width. The heading takes tabIndex -1 so a page or a pane can
5
5
  // move focus to it (a pane does on open) without adding it to the tab order.
6
6
  export default function TitleBar(_a) {
7
- var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, phoneActions = _a.phoneActions, id = _a.id;
7
+ var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, phoneActions = _a.phoneActions, meta = _a.meta, id = _a.id;
8
8
  var below = actionsBelow && !phoneActions;
9
9
  return (<div className={"flex min-w-0 items-center gap-2".concat(back || below ? ' flex-wrap md:flex-nowrap' : '')}>
10
10
  {back && <div className="flex shrink-0 basis-full items-center md:basis-auto">{back}</div>}
11
- <Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 flex-1 break-words outline-none">
12
- {title}
13
- </Heading>
11
+ {meta ? (<div className="flex min-w-0 flex-1 flex-col gap-1">
12
+ <Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 break-words outline-none">
13
+ {title}
14
+ </Heading>
15
+ <div className="flex flex-wrap items-center gap-small text-body2 text-fg-secondary">{meta}</div>
16
+ </div>) : (<Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 flex-1 break-words outline-none">
17
+ {title}
18
+ </Heading>)}
14
19
  {actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " shrink-0 items-center gap-2").concat(below ? ' basis-full md:basis-auto' : '')}>{actions}</div>}
15
20
  {phoneActions && <div className="flex shrink-0 items-center gap-2 md:hidden">{phoneActions}</div>}
16
21
  </div>);
@@ -0,0 +1,39 @@
1
+ export type ChartFormat = 'count' | 'money';
2
+ /**
3
+ * The y ticks from 0: round steps of 1, 2, 2.5 or 5 × 10ⁿ, the last tick at or above `max`, 3 to 5 ticks.
4
+ * `max` 0 (or below, or not a number) gives `[0, 1]`. With `integer` (counts) the step is a whole number of
5
+ * at least 1, so max 1 gives `[0, 1]`, max 2 `[0, 1, 2]` and max 10 `[0, 5, 10]`.
6
+ */
7
+ export declare function niceTicks(max: number, count?: number, { integer }?: {
8
+ integer?: boolean;
9
+ }): number[];
10
+ /**
11
+ * The indexes of the x labels to print: the first, the last and every `ceil(n / most)`th. When the run
12
+ * misses the last, the last replaces the run's final label: it is right-aligned and takes up to a step of
13
+ * room, so beside a label less than a step away it would always overlap.
14
+ */
15
+ export declare function labelEvery(n: number, most?: number): number[];
16
+ /**
17
+ * The point a key moves to: Left and Right by one with no wrap, Home the first, End the last. Any other key
18
+ * keeps `current`. `current` -1 is no point yet: Right and Home start at the first, Left and End at the last.
19
+ */
20
+ export declare function nextPoint(key: string, current: number, count: number): number;
21
+ /** The x of point `i` of `n` in a 0 to 100 box. One point sits in the middle. */
22
+ export declare const pointX: (i: number, n: number) => number;
23
+ /**
24
+ * An SVG `d` in a 0 to 100 box, 0 at the bottom and `top` at the top. Each run of values starts with `M`, so a
25
+ * `null` breaks the line. The axis starts at 0, so a value below 0 is drawn at 0 and never below the plot.
26
+ */
27
+ export declare function linePath(values: (number | null)[], top: number): string;
28
+ /** A tick: compact from 10,000 up ('12.4K', '$12.4K'), else exact. */
29
+ export declare function axisText(n: number, format?: ChartFormat): string;
30
+ /** The exact value with its unit, for the readout and the table: '1,234,567 comments', '$18.40', 'No data'. */
31
+ export declare function exactText(n: number | null, format?: ChartFormat, unit?: string): string;
32
+ /**
33
+ * A point of named series in words, each value's exact text before its name: 'Nov 14: 58 opened, 41 done'.
34
+ * A gap in one series reads 'No data for done'; a point with no value in any series reads 'Nov 14: No data'.
35
+ */
36
+ export declare function seriesReadout(label: string, points: {
37
+ name: string;
38
+ value: number | null;
39
+ }[], format?: ChartFormat, unit?: string): string;
@@ -0,0 +1,110 @@
1
+ // Pure helpers behind BarChart and LineChart: the y ticks, which x labels to print, the keys that move
2
+ // the highlighted point, a line's SVG path and the number text. No DOM: the server and the browser
3
+ // draw the same markup.
4
+ import { formatCount, formatMoney } from '../components/formatNumber';
5
+ var MANTISSAS = [1, 2, 2.5, 5, 10];
6
+ // Float steps (0.1 * 3) would print '0.30000000000000004'
7
+ var clean = function (n) { return Number(n.toPrecision(12)); };
8
+ /**
9
+ * The y ticks from 0: round steps of 1, 2, 2.5 or 5 × 10ⁿ, the last tick at or above `max`, 3 to 5 ticks.
10
+ * `max` 0 (or below, or not a number) gives `[0, 1]`. With `integer` (counts) the step is a whole number of
11
+ * at least 1, so max 1 gives `[0, 1]`, max 2 `[0, 1, 2]` and max 10 `[0, 5, 10]`.
12
+ */
13
+ export function niceTicks(max, count, _a) {
14
+ if (count === void 0) { count = 4; }
15
+ var _b = _a === void 0 ? {} : _a, _c = _b.integer, integer = _c === void 0 ? false : _c;
16
+ if (!Number.isFinite(max) || max <= 0)
17
+ return [0, 1];
18
+ var raw = max / count;
19
+ var power = Math.pow(10, Math.floor(Math.log10(raw)));
20
+ var fits = function (m) { return power * m >= raw - 1e-12 && (!integer || Number.isInteger(clean(power * m))); };
21
+ var step = integer && raw <= 1 ? 1 : clean(power * MANTISSAS.find(fits));
22
+ var last = Math.ceil(clean(max / step));
23
+ return Array.from({ length: last + 1 }, function (_, i) { return clean(i * step); });
24
+ }
25
+ /**
26
+ * The indexes of the x labels to print: the first, the last and every `ceil(n / most)`th. When the run
27
+ * misses the last, the last replaces the run's final label: it is right-aligned and takes up to a step of
28
+ * room, so beside a label less than a step away it would always overlap.
29
+ */
30
+ export function labelEvery(n, most) {
31
+ if (most === void 0) { most = 6; }
32
+ if (n <= 0)
33
+ return [];
34
+ var step = Math.ceil(n / most);
35
+ var out = [];
36
+ for (var i = 0; i < n; i += step)
37
+ out.push(i);
38
+ var last = n - 1;
39
+ // The run starts at 0, so it can only miss the last when it has more than one label
40
+ if (out[out.length - 1] !== last)
41
+ out[out.length - 1] = last;
42
+ return out;
43
+ }
44
+ /**
45
+ * The point a key moves to: Left and Right by one with no wrap, Home the first, End the last. Any other key
46
+ * keeps `current`. `current` -1 is no point yet: Right and Home start at the first, Left and End at the last.
47
+ */
48
+ export function nextPoint(key, current, count) {
49
+ if (count <= 0)
50
+ return current;
51
+ var lastIndex = count - 1;
52
+ switch (key) {
53
+ case 'ArrowRight':
54
+ return current < 0 ? 0 : Math.min(lastIndex, current + 1);
55
+ case 'ArrowLeft':
56
+ return current < 0 ? lastIndex : Math.max(0, current - 1);
57
+ case 'Home':
58
+ return 0;
59
+ case 'End':
60
+ return lastIndex;
61
+ default:
62
+ return current;
63
+ }
64
+ }
65
+ var short = function (n) { return String(Math.round(n * 100) / 100); };
66
+ /** The x of point `i` of `n` in a 0 to 100 box. One point sits in the middle. */
67
+ export var pointX = function (i, n) { return (n <= 1 ? 50 : (i / (n - 1)) * 100); };
68
+ /**
69
+ * An SVG `d` in a 0 to 100 box, 0 at the bottom and `top` at the top. Each run of values starts with `M`, so a
70
+ * `null` breaks the line. The axis starts at 0, so a value below 0 is drawn at 0 and never below the plot.
71
+ */
72
+ export function linePath(values, top) {
73
+ var d = '';
74
+ var drawing = false;
75
+ values.forEach(function (v, i) {
76
+ if (v === null || !Number.isFinite(v)) {
77
+ drawing = false;
78
+ return;
79
+ }
80
+ var y = 100 - (top > 0 ? (Math.max(0, v) / top) * 100 : 0);
81
+ d += "".concat(drawing ? 'L' : 'M').concat(short(pointX(i, values.length)), " ").concat(short(y));
82
+ drawing = true;
83
+ });
84
+ return d;
85
+ }
86
+ /** A tick: compact from 10,000 up ('12.4K', '$12.4K'), else exact. */
87
+ export function axisText(n, format) {
88
+ if (format === void 0) { format = 'count'; }
89
+ return format === 'money' ? formatMoney(n, { compact: true }) : formatCount(n, { compact: true });
90
+ }
91
+ /** The exact value with its unit, for the readout and the table: '1,234,567 comments', '$18.40', 'No data'. */
92
+ export function exactText(n, format, unit) {
93
+ if (format === void 0) { format = 'count'; }
94
+ if (n === null || !Number.isFinite(n))
95
+ return 'No data';
96
+ var text = format === 'money' ? formatMoney(n) : formatCount(n);
97
+ return unit ? "".concat(text, " ").concat(unit) : text;
98
+ }
99
+ /**
100
+ * A point of named series in words, each value's exact text before its name: 'Nov 14: 58 opened, 41 done'.
101
+ * A gap in one series reads 'No data for done'; a point with no value in any series reads 'Nov 14: No data'.
102
+ */
103
+ export function seriesReadout(label, points, format, unit) {
104
+ if (format === void 0) { format = 'count'; }
105
+ var has = function (v) { return v !== null && Number.isFinite(v); };
106
+ if (!points.some(function (p) { return has(p.value); }))
107
+ return "".concat(label, ": No data");
108
+ var parts = points.map(function (p) { return (has(p.value) ? "".concat(exactText(p.value, format, unit), " ").concat(p.name) : "No data for ".concat(p.name)); });
109
+ return "".concat(label, ": ").concat(parts.join(', '));
110
+ }