derive-dashboards 0.9.0 → 0.11.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 (80) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/body.mjs +5 -1
  3. package/dist/charts/data/words.d.mts +5 -0
  4. package/dist/charts/data/words.mjs +1 -0
  5. package/dist/charts/kinds/columns-data.mjs +4 -1
  6. package/dist/charts/kinds/grid-layout.mjs +84 -8
  7. package/dist/charts/kinds/grid-legend.mjs +27 -4
  8. package/dist/charts/kinds/grid-marks.mjs +56 -4
  9. package/dist/charts/kinds/grid.mjs +2 -1
  10. package/dist/charts/scale/value.mjs +15 -8
  11. package/dist/charts/scene/types.d.mts +1 -1
  12. package/dist/core/document/display-entries.mjs +9 -2
  13. package/dist/core/document/display.d.mts +7 -3
  14. package/dist/core/document/display.mjs +15 -2
  15. package/dist/core/engine/version.d.mts +1 -1
  16. package/dist/core/engine/version.mjs +1 -1
  17. package/dist/core/error/codes.d.mts +2 -0
  18. package/dist/core/error/codes.mjs +2 -0
  19. package/dist/core/index.d.mts +2 -2
  20. package/dist/core/index.mjs +3 -3
  21. package/dist/core/model/member.d.mts +6 -0
  22. package/dist/core/model/member.mjs +11 -1
  23. package/dist/core/model/types.d.mts +6 -0
  24. package/dist/core/model/validate/known-members.mjs +1 -0
  25. package/dist/core/model/validate/members.mjs +12 -1
  26. package/dist/core/query/closure.mjs +2 -0
  27. package/dist/core/query/drill/links.mjs +16 -4
  28. package/dist/core/result/columns.mjs +15 -2
  29. package/dist/core/result/types.d.mts +2 -0
  30. package/dist/core/schema/answer-parts.mjs +1 -0
  31. package/dist/core/schema/answers.d.mts +14 -0
  32. package/dist/core/schema/answers.mjs +4 -2
  33. package/dist/core/schema/tools.mjs +4 -0
  34. package/dist/core/types/api.d.mts +7 -1
  35. package/dist/core/types/api.mjs +1 -1
  36. package/dist/endpoints/index.d.mts +5 -4
  37. package/dist/endpoints/meta.mjs +30 -12
  38. package/dist/endpoints/query.mjs +11 -5
  39. package/dist/endpoints/values.mjs +38 -24
  40. package/dist/execute.mjs +22 -1
  41. package/dist/labels.mjs +68 -0
  42. package/dist/listing.mjs +13 -0
  43. package/dist/react/Canvas.mjs +28 -2
  44. package/dist/react/Cell.mjs +1 -1
  45. package/dist/react/Dashboard.d.mts +2 -3
  46. package/dist/react/Tile.d.mts +1 -1
  47. package/dist/react/arrange-steps.mjs +99 -11
  48. package/dist/react/arrange.mjs +10 -3
  49. package/dist/react/builder/base.mjs +11 -6
  50. package/dist/react/builder/display.mjs +16 -2
  51. package/dist/react/builder/state.mjs +3 -3
  52. package/dist/react/builder/words.mjs +8 -0
  53. package/dist/react/dates-shown.mjs +27 -9
  54. package/dist/react/filters/bar.d.mts +1 -1
  55. package/dist/react/filters/bar.mjs +17 -7
  56. package/dist/react/filters/chip.mjs +5 -3
  57. package/dist/react/filters/context.mjs +2 -2
  58. package/dist/react/filters/dates-said.mjs +29 -11
  59. package/dist/react/filters/hooks.d.mts +8 -0
  60. package/dist/react/filters/hooks.mjs +39 -2
  61. package/dist/react/filters/menu.mjs +8 -18
  62. package/dist/react/filters/phone.mjs +3 -3
  63. package/dist/react/filters/values.mjs +47 -28
  64. package/dist/react/filters/words.mjs +2 -2
  65. package/dist/react/format.d.mts +1 -1
  66. package/dist/react/format.mjs +8 -2
  67. package/dist/react/renderers/moved.mjs +160 -0
  68. package/dist/react/renderers/number-before.mjs +2 -157
  69. package/dist/react/renderers/props.d.mts +3 -3
  70. package/dist/react/renderers/table-cells.mjs +97 -11
  71. package/dist/react/renderers/table-head.mjs +7 -1
  72. package/dist/react/renderers/table-measure.mjs +147 -25
  73. package/dist/react/renderers/table-over.mjs +72 -0
  74. package/dist/react/renderers/table-scale.mjs +54 -1
  75. package/dist/react/renderers/table-trend.mjs +55 -0
  76. package/dist/react/renderers/table.d.mts +5 -1
  77. package/dist/react/renderers/table.mjs +29 -6
  78. package/dist/react/theme-unlayered.css +1 -1
  79. package/dist/react/theme.css +1 -1
  80. package/package.json +1 -1
@@ -1,46 +1,168 @@
1
1
  import { isValue } from "../columns.mjs";
2
+ import { formatFull } from "../headline.mjs";
2
3
  import { answerIds } from "./entries.mjs";
3
- import { isSummary, measurable, rangeOf, scaleOf } from "./table-scale.mjs";
4
+ import { difference, movedOf, readOf } from "./moved.mjs";
5
+ import { daysBefore } from "./number-period.mjs";
6
+ import { beforeOf, coursesOf } from "./table-over.mjs";
7
+ import { dotScale, isSummary, isTotal, measurable, rangeOf, scaleOf, shareOf as shareOf$1, totalReach, wholeAndPart } from "./table-scale.mjs";
4
8
  import { valueText } from "./table-whole.mjs";
5
9
  import { displayOf, isMark, roleOf } from "derive-dashboards/core";
6
10
  // src/renderers/table-measure.ts
7
- /** One column's measure: its scale over every row, and the values of the rows drawn as written, with the room the longest takes. */
8
- function measure(asked, at, column, draws) {
9
- const { rows } = asked.answer;
10
- const places = asked.drawn ?? rows.map((_, place) => place);
11
+ /** How one row's value moved from its row in the period before; none when it did not, or cannot be said. */
12
+ function movedAt(asked, now, before) {
13
+ const { column } = now;
14
+ const [is, was] = [now.cells[now.at], before?.[now.at]].map((cell) => readOf(cell, column));
15
+ if (was === void 0 || was === null) return void 0;
16
+ const delta = difference(is, was, column);
17
+ const moved = delta && movedOf(delta, was, {
18
+ column,
19
+ props: asked,
20
+ now: is ?? null
21
+ });
22
+ if (moved === void 0) return void 0;
23
+ const { went, ...rest } = moved;
24
+ const from = {
25
+ was: writerOf(asked, column, true)(was),
26
+ days: daysBefore(asked.over ?? asked.answer)
27
+ };
28
+ const exact = moved.size === moved.exact.slice(1) ? void 0 : moved.exact;
29
+ const said = asked.messages.changeSaid({
30
+ ...rest,
31
+ exact,
32
+ ...from,
33
+ ...went === void 0 ? {} : { better: went }
34
+ });
35
+ return {
36
+ ...moved,
37
+ said: `${column.label} ${said}`
38
+ };
39
+ }
40
+ /** How each row drawn moved, by its place, and the room the longest takes. */
41
+ function movedOfRows(asked, at, column, before) {
42
+ const rows = byPlace(asked, asked.drawn ?? asked.answer.rows.map((_, place) => place), (cells) => movedAt(asked, {
43
+ cells,
44
+ at,
45
+ column
46
+ }, before(cells)));
47
+ return {
48
+ rows,
49
+ chars: Math.max(0, ...[...rows.values()].map((moved) => moved.size.length + 2))
50
+ };
51
+ }
52
+ /** By the place of each row given: what `of` makes of the row, where it makes anything. */
53
+ function byPlace(asked, places, of) {
54
+ return new Map(places.flatMap((place) => {
55
+ const made = of(asked.answer.rows[place] ?? []);
56
+ return made === void 0 ? [] : [[place, made]];
57
+ }));
58
+ }
59
+ /**
60
+ * How a column's values are written: as a table writes any cell, but a rate whose change is
61
+ * written beside it keeps the tenth of a point a headline's has (25.2%), since a change of
62
+ * half a point beside "25%" reads as a number that did not move.
63
+ */
64
+ function writerOf(asked, column, moved) {
11
65
  const how = {
12
66
  whole: asked.whole,
13
67
  format: asked
14
68
  };
15
- const texts = new Map(places.map((place) => [place, valueText(rows[place]?.[at] ?? null, column, how)]));
16
- const scale = scaleOf(rows, at, column);
69
+ return moved && column.format === "percent" ? (cell) => formatFull(cell, column, asked) : (cell) => valueText(cell, column, how);
70
+ }
71
+ /** What `of` makes of a row that is no total: a total is drawn with no part of its own and no chart. */
72
+ const unlessTotal = (of) => (cells) => isTotal(cells) ? void 0 : of(cells);
73
+ /** What a column draws beside its numbers and its bar: its dot's tick, the part in each bar, each row's small chart and how each moved. */
74
+ function beyond(asked, places, column, draws) {
75
+ const { rows } = asked.answer;
76
+ const { at, scale } = column;
77
+ const { part, course, before } = draws;
78
+ const share = (cells) => part === void 0 ? void 0 : shareOf$1(cells[at] ?? null, cells[part] ?? null);
79
+ return {
80
+ ...draws.dot ? { dot: { against: totalReach(rows, at, scale) } } : {},
81
+ ...part === void 0 ? {} : { parts: byPlace(asked, places, unlessTotal(share)) },
82
+ ...course === void 0 ? {} : { courses: byPlace(asked, places, unlessTotal(course)) },
83
+ ...before === void 0 ? {} : { moved: movedOfRows(asked, at, column.is, before) }
84
+ };
85
+ }
86
+ /** One column's measure: its scale over every row, and the values of the rows drawn as written, with the room the longest takes. */
87
+ function measure(asked, at, column, draws) {
88
+ const { rows } = asked.answer;
89
+ const places = asked.drawn ?? rows.map((_, place) => place);
90
+ const write = writerOf(asked, column, draws.before !== void 0);
91
+ const texts = new Map(places.map((place) => [place, write(rows[place]?.[at] ?? null)]));
92
+ const scale = draws.dot ? dotScale(rows, at) : scaleOf(rows, at, column);
93
+ const barred = draws.bar || draws.dot || draws.part !== void 0;
17
94
  return {
18
95
  scale,
19
96
  chars: Math.max(0, ...[...texts.values()].map((text) => text.length)),
20
97
  texts,
21
- bar: draws.bar && measurable(scale),
22
- heat: draws.shaded ? rangeOf(rows, at) : void 0
98
+ bar: barred && measurable(scale),
99
+ heat: draws.shaded ? rangeOf(rows, at) : void 0,
100
+ ...beyond(asked, places, {
101
+ at,
102
+ is: column,
103
+ scale
104
+ }, draws)
23
105
  };
24
106
  }
25
107
  const NO_MEASURES = /* @__PURE__ */ new Map();
108
+ /** The ids of the answer's columns a display option names, as the widget's query or the answer names them. */
109
+ function named(widget, entries) {
110
+ const answerId = answerIds(widget);
111
+ return new Set((entries ?? []).map((entry) => answerId(entry)));
112
+ }
26
113
  /**
27
- * The value columns a widget draws beyond their numbers, by column id. `display.bars` and
28
- * `display.heat` name entries as the widget's query does, or as the answer does.
114
+ * The whole and the part `display.parts` names, as places in the answer's columns: none unless
115
+ * it names two value columns of which one is a part of the other on every row.
29
116
  */
30
- function measuredOf(asked) {
117
+ function partsOf(asked) {
118
+ const entries = named(asked.widget, displayOf("table", asked.widget.display).parts);
119
+ const [a, b, ...more] = asked.answer.columns.flatMap((column, at) => isValue(column) && entries.has(column.id) ? [at] : []);
120
+ if (a === void 0 || b === void 0 || more.length > 0) return void 0;
121
+ return wholeAndPart(asked.answer.rows, a, b);
122
+ }
123
+ /** What a widget asks its table's columns be drawn with: the ids of the columns each option names. */
124
+ function wantedOf(asked) {
31
125
  const display = displayOf("table", asked.widget.display);
32
- if ((display.bars?.length ?? 0) === 0 && (display.heat?.length ?? 0) === 0) return NO_MEASURES;
33
- const answerId = answerIds(asked.widget);
34
- const bars = new Set((display.bars ?? []).map((entry) => answerId(entry)));
35
- const heat = new Set((display.heat ?? []).map((entry) => answerId(entry)));
36
- return new Map(asked.answer.columns.flatMap((column, at) => {
37
- const draws = {
38
- bar: bars.has(column.id),
39
- shaded: heat.has(column.id)
40
- };
41
- if (!isValue(column) || !(draws.bar || draws.shaded)) return [];
42
- return [[column.id, measure(asked, at, column, draws)]];
43
- }));
126
+ return {
127
+ bars: named(asked.widget, display.bars),
128
+ heat: named(asked.widget, display.heat),
129
+ dots: named(asked.widget, display.dots),
130
+ trend: named(asked.widget, display.trend),
131
+ change: named(asked.widget, display.change),
132
+ parts: partsOf(asked),
133
+ before: (display.change?.length ?? 0) === 0 ? void 0 : beforeOf(asked.over ?? asked.answer)
134
+ };
135
+ }
136
+ /** What one column is drawn with, of what the widget asks. */
137
+ function drawsOf(asked, wanted, at) {
138
+ const id = asked.answer.columns[at]?.id ?? "";
139
+ const { over } = asked;
140
+ return {
141
+ bar: wanted.bars.has(id),
142
+ shaded: wanted.heat.has(id),
143
+ dot: wanted.dots.has(id),
144
+ part: wanted.parts?.whole === at ? wanted.parts.part : void 0,
145
+ course: over !== void 0 && wanted.trend.has(id) ? coursesOf(over, id) : void 0,
146
+ before: wanted.change.has(id) ? wanted.before : void 0
147
+ };
148
+ }
149
+ const drawsAny = (draws) => draws.bar || draws.shaded || draws.dot || [
150
+ draws.part,
151
+ draws.course,
152
+ draws.before
153
+ ].some((drawn) => drawn !== void 0);
154
+ /**
155
+ * The value columns a widget draws beyond their numbers, by column id. `display.bars`, `heat`,
156
+ * `dots`, `parts` and `trend` name entries as the widget's query does, or as the answer does.
157
+ */
158
+ function measuredOf(asked) {
159
+ const wanted = wantedOf(asked);
160
+ const measured = asked.answer.columns.flatMap((column, at) => {
161
+ if (!isValue(column)) return [];
162
+ const draws = drawsOf(asked, wanted, at);
163
+ return drawsAny(draws) ? [[column.id, measure(asked, at, column, draws)]] : [];
164
+ });
165
+ return measured.length === 0 ? NO_MEASURES : new Map(measured);
44
166
  }
45
167
  /**
46
168
  * Whether a row that folds dimensions (Other, a total) is of the rows drawn: the groups it
@@ -68,4 +190,4 @@ function drawnOf(order, rows, limit, columns) {
68
190
  const drawn = [...first].map((place) => rows[place] ?? []);
69
191
  return order.filter((place) => isSummary(rows[place] ?? []) ? foldsDrawn(rows[place] ?? [], drawn, columns) : first.has(place));
70
192
  }
71
- export { drawnOf, measuredOf };
193
+ export { drawnOf, measuredOf, partsOf };
@@ -0,0 +1,72 @@
1
+ import { plotValue } from "../format.mjs";
2
+ import { roleOf, wholeAnswer } from "derive-dashboards/core";
3
+ // src/renderers/table-over.ts
4
+ /**
5
+ * The answer a table draws: the whole's rows in the whole's columns (the answer's without the
6
+ * time column) when the answer has a whole, else the answer itself. The rows are the answer's
7
+ * own, so a click on one still finds what it opens.
8
+ */
9
+ function tableAnswer(answer) {
10
+ const whole = wholeAnswer(answer);
11
+ return whole === void 0 ? answer : {
12
+ ...answer,
13
+ columns: whole.columns,
14
+ rows: whole.rows
15
+ };
16
+ }
17
+ /** A row's groups as one text, which its buckets are found by: exact values are told by their text. */
18
+ const groupsOf = (cells, places) => JSON.stringify(places.map((at) => cells[at] ?? null));
19
+ /** The places of the columns rows are grouped by. */
20
+ const groupPlaces = (columns) => columns.flatMap((column, at) => roleOf(column) === "dimension" ? [at] : []);
21
+ function bucketsOf(answer, id) {
22
+ const buckets = answer.time?.buckets ?? [];
23
+ const time = answer.columns.findIndex((column) => roleOf(column) === "time");
24
+ const value = answer.columns.findIndex((column) => column.id === id);
25
+ const whole = wholeAnswer(answer);
26
+ if (buckets.length === 0 || time < 0 || value < 0 || whole === void 0) return void 0;
27
+ return {
28
+ buckets,
29
+ time,
30
+ value,
31
+ whole
32
+ };
33
+ }
34
+ /**
35
+ * Each group's values of one column over the answer's time buckets, read by a row of the
36
+ * whole: none for an answer with no buckets or no such column, and none for a row whose groups
37
+ * have no bucket.
38
+ */
39
+ function coursesOf(answer, id) {
40
+ const read = bucketsOf(answer, id);
41
+ if (read === void 0) return void 0;
42
+ const placeOf = new Map(read.buckets.map((bucket, i) => [bucket.label, i]));
43
+ const places = groupPlaces(answer.columns);
44
+ const courses = /* @__PURE__ */ new Map();
45
+ for (const cells of answer.rows) {
46
+ const label = cells[read.time];
47
+ const at = typeof label === "string" ? placeOf.get(label) : void 0;
48
+ if (at === void 0) continue;
49
+ const key = groupsOf(cells, places);
50
+ const course = courses.get(key) ?? read.buckets.map(() => null);
51
+ course[at] = plotValue(cells[read.value] ?? null);
52
+ courses.set(key, course);
53
+ }
54
+ const wholePlaces = groupPlaces(read.whole.columns);
55
+ return (row) => courses.get(groupsOf(row, wholePlaces));
56
+ }
57
+ /**
58
+ * Each row's row in the comparison period, found by its groups: for a table over the whole, in
59
+ * the comparison's whole; for one with no time buckets, in the comparison's rows. None for an
60
+ * answer that compares with no period, and none for rows that are buckets themselves: a bucket
61
+ * of the period before is not found by a bucket's name.
62
+ */
63
+ function beforeOf(answer) {
64
+ const whole = wholeAnswer(answer);
65
+ const bucketed = whole === void 0 && answer.columns.some((c) => roleOf(c) === "time");
66
+ const rows = whole === void 0 ? answer.compare?.rows : answer.compare?.whole?.rows;
67
+ if (rows === void 0 || bucketed) return void 0;
68
+ const places = groupPlaces(whole?.columns ?? answer.columns);
69
+ const before = new Map(rows.map((cells) => [groupsOf(cells, places), cells]));
70
+ return (row) => before.get(groupsOf(row, places));
71
+ }
72
+ export { beforeOf, coursesOf, tableAnswer };
@@ -66,4 +66,57 @@ function depthOf(cell, range) {
66
66
  if (Number.isFinite(span)) return at(span, value - range.least);
67
67
  return at(range.most / 2 - range.least / 2, value / 2 - range.least / 2);
68
68
  }
69
- export { depthOf, isSummary, isTotal, measurable, rangeOf, reachOf, scaleOf };
69
+ /** The round numbers a scale may end on, as multiples of a power of ten. */
70
+ const ROUND = [
71
+ 1,
72
+ 2,
73
+ 2.5,
74
+ 5,
75
+ 10
76
+ ];
77
+ /** The least round number (1, 2, 2.5 or 5 times a power of ten) a size is not past. */
78
+ function roundUp(size) {
79
+ if (!(size > 0) || !Number.isFinite(size)) return size;
80
+ const unit = 10 ** Math.floor(Math.log10(size));
81
+ return (ROUND.find((step) => step * unit >= size) ?? 10) * unit;
82
+ }
83
+ /**
84
+ * The end of the scale a column's dots stand on: the least round number no value of the column
85
+ * is past, the total's among them, since the total stands on the scale too. A rate of 41% at
86
+ * most is read on a scale to 50%, where a scale to the whole would crowd every dot to one end.
87
+ */
88
+ function dotScale(rows, at) {
89
+ return roundUp(rows.reduce((most, cells) => Math.max(most, sizeOf(cells[at] ?? null)), 0));
90
+ }
91
+ /** Where the total row stands on a column's scale, from 0 to 1; none for a table with no total, or a total with no value. */
92
+ function totalReach(rows, at, scale) {
93
+ const total = rows.find((cells) => isTotal(cells))?.[at] ?? null;
94
+ return numberOf(total) === null ? void 0 : reachOf(total, scale);
95
+ }
96
+ /**
97
+ * Of two columns, which is the whole and which a part of it: the part is the one no row has
98
+ * more of than of the other, and never less than nothing. None when neither is, on some row: two
99
+ * values that are not a whole and its part are not drawn as one bar.
100
+ */
101
+ function wholeAndPart(rows, a, b) {
102
+ const pairs = rows.flatMap((cells) => {
103
+ const [one, other] = [numberOf(cells[a] ?? null), numberOf(cells[b] ?? null)];
104
+ return one === null || other === null ? [] : [[one, other]];
105
+ });
106
+ if (pairs.length === 0 || pairs.some(([one, other]) => one < 0 || other < 0)) return void 0;
107
+ if (pairs.every(([one, other]) => other <= one)) return {
108
+ whole: a,
109
+ part: b
110
+ };
111
+ return pairs.every(([one, other]) => one <= other) ? {
112
+ whole: b,
113
+ part: a
114
+ } : void 0;
115
+ }
116
+ /** How much of a row's whole its part is, from 0 to 1; none for a row with no whole or no part. */
117
+ function shareOf$1(whole, part) {
118
+ const [all, some] = [numberOf(whole), numberOf(part)];
119
+ if (all === null || some === null || !(all > 0)) return void 0;
120
+ return Math.min(1, Math.max(0, some / all));
121
+ }
122
+ export { depthOf, dotScale, isSummary, isTotal, measurable, rangeOf, reachOf, scaleOf, shareOf$1 as shareOf, totalReach, wholeAndPart };
@@ -0,0 +1,55 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ // src/renderers/table-trend.tsx
3
+ /** A column fills this much of its bucket's width. */
4
+ const FILL = .72;
5
+ /** The values of a course that are numbers. */
6
+ const numbersOf = (course) => course.filter((value) => value !== null);
7
+ /** One column a bucket whose value is more than nothing, as tall as the value beside the row's largest. */
8
+ function Columns({ course }) {
9
+ const most = Math.max(0, ...numbersOf(course));
10
+ return course.map((value, at) => {
11
+ const tall = value === null || !(most > 0) ? 0 : Math.max(0, value) / most;
12
+ if (!(tall > 0)) return null;
13
+ const key = `c${String(at)}`;
14
+ return /* @__PURE__ */ jsx("rect", {
15
+ x: at + .28 / 2,
16
+ y: 1 - tall,
17
+ width: FILL,
18
+ height: tall
19
+ }, key);
20
+ });
21
+ }
22
+ /** The runs of buckets with a value, each as the points of a line: a bucket with none breaks it. */
23
+ function runsOf(course) {
24
+ const numbers = numbersOf(course);
25
+ const least = Math.min(...numbers);
26
+ const span = Math.max(...numbers) - least;
27
+ const runs = [[]];
28
+ for (const [at, value] of course.entries()) if (value === null) runs.push([]);
29
+ else runs.at(-1)?.push(`${String(at + .5)},${String(span > 0 ? 1 - (value - least) / span : .5)}`);
30
+ return runs.filter((run) => run.length > 0).map((run) => run.join(" "));
31
+ }
32
+ /** A line through the values, from the row's least to its most; a lone value between two gaps is a dot's worth of line. */
33
+ function Line({ course }) {
34
+ return runsOf(course).map((points) => {
35
+ const [only, more] = points.split(" ");
36
+ const drawn = more === void 0 && only !== void 0 ? `${only} ${only}` : points;
37
+ return /* @__PURE__ */ jsx("polyline", { points: drawn }, points);
38
+ });
39
+ }
40
+ /** The small chart of one row's buckets. Nothing for a row with no value in any bucket. */
41
+ function Trend({ course, line }) {
42
+ if (numbersOf(course).length === 0) return null;
43
+ const vars = { "--dd-buckets": String(course.length) };
44
+ return /* @__PURE__ */ jsx("svg", {
45
+ className: "dd-table-trend",
46
+ "data-form": line ? "line" : "columns",
47
+ viewBox: `0 0 ${String(course.length)} 1`,
48
+ preserveAspectRatio: "none",
49
+ "aria-hidden": "true",
50
+ focusable: "false",
51
+ style: vars,
52
+ children: line ? /* @__PURE__ */ jsx(Line, { course }) : /* @__PURE__ */ jsx(Columns, { course })
53
+ });
54
+ }
55
+ export { Trend };
@@ -1,3 +1,7 @@
1
1
  import { TileRendererProps } from "./props.mjs";
2
- /** Every row and column: the groups, then Other and the total under them. */
2
+ /**
3
+ * Every row and column: the groups, then Other and the total under them. Over time and the
4
+ * whole (`time.whole`) its rows are the whole's, each group over the whole range, and the
5
+ * buckets are what a row's small chart draws (`display.trend`).
6
+ */
3
7
  export declare function TableTile(props: TileRendererProps): import("react").JSX.Element;
@@ -2,7 +2,8 @@ import { MoreRows, holdsRows, useRowLimit } from "./more-rows.mjs";
2
2
  import { fitted } from "./props.mjs";
3
3
  import { nameCut, useFit } from "./table-fit.mjs";
4
4
  import { Head } from "./table-head.mjs";
5
- import { drawnOf, measuredOf } from "./table-measure.mjs";
5
+ import { drawnOf, measuredOf, partsOf } from "./table-measure.mjs";
6
+ import { tableAnswer } from "./table-over.mjs";
6
7
  import { Row, useComparisons } from "./table-row.mjs";
7
8
  import { isSummary, isTotal } from "./table-scale.mjs";
8
9
  import { orderOf, sortable } from "./table-sort.mjs";
@@ -17,7 +18,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
18
  * table draws its first rows, and more with each press of its button.
18
19
  */
19
20
  function useRows(tile, sort) {
20
- const { answer, widget, locale, messages } = tile;
21
+ const { answer, widget, locale, messages, over } = tile;
21
22
  const { columns, rows } = answer;
22
23
  const { limit, first, drawMore, drawFirst } = useRowLimit(answer, tile.fit);
23
24
  const order = useMemo(() => orderOf(rows, columns, {
@@ -51,14 +52,16 @@ function useRows(tile, sort) {
51
52
  locale,
52
53
  messages,
53
54
  drawn: written,
54
- whole
55
+ whole,
56
+ over
55
57
  }), [
56
58
  answer,
57
59
  widget,
58
60
  locale,
59
61
  messages,
60
62
  written,
61
- whole
63
+ whole,
64
+ over
62
65
  ]);
63
66
  const plain = useMemo(() => rows.filter((cells) => !isSummary(cells)).length, [rows]);
64
67
  const shown = useMemo(() => drawn.filter((place) => !isSummary(rows[place] ?? [])).length, [drawn, rows]);
@@ -78,8 +81,22 @@ function useRows(tile, sort) {
78
81
  }
79
82
  /** A table's rows that are not folds (Other, a total) nor its button's own: the rows a reader counts. */
80
83
  const PLAIN_ROWS = "tbody > tr:not(.dd-table-summary):not(.dd-table-more-row)";
81
- /** Every row and column: the groups, then Other and the total under them. */
84
+ /**
85
+ * Every row and column: the groups, then Other and the total under them. Over time and the
86
+ * whole (`time.whole`) its rows are the whole's, each group over the whole range, and the
87
+ * buckets are what a row's small chart draws (`display.trend`).
88
+ */
82
89
  function TableTile(props) {
90
+ const answer = useMemo(() => tableAnswer(props.answer), [props.answer]);
91
+ const over = answer === props.answer ? void 0 : props.answer;
92
+ return /* @__PURE__ */ jsx(Rows, {
93
+ ...props,
94
+ answer,
95
+ over
96
+ });
97
+ }
98
+ /** The table of the answer it is given. */
99
+ function Rows(props) {
83
100
  const { columns, rows } = props.answer;
84
101
  const [sort, setSort] = useState();
85
102
  const [table, fit] = useFit(props.answer);
@@ -87,6 +104,11 @@ function TableTile(props) {
87
104
  const { measured, whole, drawn, until, more } = useRows(props, sort);
88
105
  const { compact, comparisons } = displayOf("table", props.widget.display);
89
106
  const comparison = useComparisons(columns, comparisons, props.drill, props);
107
+ const { answer, widget } = props;
108
+ const parts = useMemo(() => partsOf({
109
+ answer,
110
+ widget
111
+ }), [answer, widget]);
90
112
  const row = (place, i) => /* @__PURE__ */ jsx(Row, {
91
113
  cells: rows[place] ?? [],
92
114
  columns,
@@ -114,7 +136,8 @@ function TableTile(props) {
114
136
  sort,
115
137
  onSort: sortable(rows) ? setSort : void 0,
116
138
  cards,
117
- messages: props.messages
139
+ messages: props.messages,
140
+ parts
118
141
  }), /* @__PURE__ */ jsxs("tbody", {
119
142
  role: cards ? "rowgroup" : void 0,
120
143
  children: [