derive-dashboards 0.7.1 → 0.8.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 (39) hide show
  1. package/dist/charts/kinds/area-marks.mjs +20 -19
  2. package/dist/charts/kinds/grid-marks.mjs +8 -10
  3. package/dist/charts/kinds/grid.mjs +2 -1
  4. package/dist/charts/marks/axes.mjs +2 -1
  5. package/dist/charts/marks/x-axis.mjs +3 -2
  6. package/dist/charts/theme.d.mts +25 -25
  7. package/dist/charts/theme.mjs +35 -27
  8. package/dist/core/document/display.d.mts +1 -0
  9. package/dist/core/document/display.mjs +3 -1
  10. package/dist/core/engine/version.d.mts +1 -1
  11. package/dist/core/engine/version.mjs +1 -1
  12. package/dist/core/time/bucket.d.mts +2 -1
  13. package/dist/core/time/bucket.mjs +6 -2
  14. package/dist/core/time/zone.d.mts +6 -1
  15. package/dist/core/time/zone.mjs +11 -2
  16. package/dist/llms.txt +1 -1
  17. package/dist/react/Canvas.mjs +7 -7
  18. package/dist/react/Dashboard.d.mts +6 -0
  19. package/dist/react/Dashboard.mjs +1 -0
  20. package/dist/react/Header.mjs +21 -17
  21. package/dist/react/columns.mjs +9 -1
  22. package/dist/react/drill/board.mjs +1 -0
  23. package/dist/react/drill/props.d.mts +2 -1
  24. package/dist/react/drill/props.mjs +8 -5
  25. package/dist/react/format.d.mts +1 -1
  26. package/dist/react/format.mjs +25 -6
  27. package/dist/react/headline.d.mts +9 -0
  28. package/dist/react/headline.mjs +51 -0
  29. package/dist/react/index.d.mts +3 -2
  30. package/dist/react/index.mjs +4 -3
  31. package/dist/react/place.mjs +4 -2
  32. package/dist/react/renderers/index.mjs +31 -8
  33. package/dist/react/theme-unlayered.css +1 -1
  34. package/dist/react/theme.css +1 -1
  35. package/dist/recharts/bar.mjs +2 -2
  36. package/dist/recharts/line.mjs +2 -2
  37. package/dist/recharts/parts.mjs +3 -1
  38. package/dist/skills/derive-dashboards/SKILL.md +2 -1
  39. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { running, starting } from "../data/buckets.mjs";
2
2
  import { stacked } from "../layout/stack.mjs";
3
- import { MUTED, SURFACE } from "../scene/paint.mjs";
3
+ import { MUTED } from "../scene/paint.mjs";
4
4
  import { bandPath, broken, linePath } from "../marks/lines.mjs";
5
5
  import { thinnedBand } from "../marks/thin.mjs";
6
6
  import { MARK, paintAt } from "../theme.mjs";
@@ -16,26 +16,27 @@ function bandsOf(spans, frame) {
16
16
  bottoms: edge((span) => span.from)
17
17
  };
18
18
  }
19
- /** The bands, each with a hair of surface along its upper edge to part it from the next. */
19
+ /**
20
+ * The bands, each a tint, then their upper edges over all of them, each in its band's own
21
+ * colour: drawn last, no edge lies under the tint of the band above it.
22
+ */
20
23
  function bandNodes(bands, look) {
21
24
  const gapped = (points) => broken(points, look.buckets);
22
- return bands.tops.flatMap((top, s) => {
23
- const edges = thinnedBand(gapped(top), gapped(bands.bottoms[s] ?? []));
24
- return [{
25
- kind: "path",
26
- part: "band",
27
- ...look.keys[s] === void 0 ? {} : { key: look.keys[s] },
28
- d: bandPath(edges.top, edges.bottom, look.curve),
29
- fill: paintAt(look.paints, s),
30
- opacity: MARK.areaFill
31
- }, {
32
- kind: "path",
33
- part: "edge",
34
- d: linePath(edges.top, look.curve),
35
- stroke: look.dense ? paintAt(look.paints, s) : SURFACE,
36
- strokeWidth: MARK.hair
37
- }];
38
- });
25
+ const drawn = bands.tops.map((top, s) => thinnedBand(gapped(top), gapped(bands.bottoms[s] ?? [])));
26
+ return [...drawn.map((edges, s) => ({
27
+ kind: "path",
28
+ part: "band",
29
+ ...look.keys[s] === void 0 ? {} : { key: look.keys[s] },
30
+ d: bandPath(edges.top, edges.bottom, look.curve),
31
+ fill: paintAt(look.paints, s),
32
+ opacity: MARK.areaFill
33
+ })), ...drawn.map((edges, s) => ({
34
+ kind: "path",
35
+ part: "edge",
36
+ d: linePath(edges.top, look.curve),
37
+ stroke: paintAt(look.paints, s),
38
+ strokeWidth: look.dense ? MARK.hair : MARK.context
39
+ }))];
39
40
  }
40
41
  /**
41
42
  * How far past the plot a clip of the bands reaches, across (twice that up and down): past the
@@ -7,13 +7,6 @@ import { rowName } from "./row-marks.mjs";
7
7
  /** How far over the cells the middle of their columns' names sits: half a line of them. */
8
8
  const OVER = LINE.tick / 2;
9
9
  /**
10
- * How strong the hue is in the palest and the deepest cell. The deepest stops short of the full
11
- * hue, so the ink a cell's number is written in reads on every cell, in a light and a dark theme.
12
- */
13
- const PALEST = .08;
14
- const DEEPEST_WITH_TEXT = .51;
15
- const DEEPEST_WITHOUT_TEXT = .85;
16
- /**
17
10
  * The columns' names over the cells: every one when they fit side by side, else the first at
18
11
  * the left and the last at the right, each cut to its half, so no two ever touch.
19
12
  */
@@ -104,12 +97,17 @@ const emptyNodes = (layout) => layout.empty.map(({ key, box }) => ({
104
97
  }));
105
98
  /** A cell's colour: the grid's one hue, whatever its value. What its stop's swatch wears too. */
106
99
  const colorOf = (cell, at) => at.mixed && cell.value < 0 ? at.negative : at.own;
107
- /** How a cell is filled: its colour, as strong as its value is high. */
100
+ /**
101
+ * How a cell is filled: its colour, as strong as its value is high. A cell with its number on
102
+ * it stops short of the full hue, so the ink reads on every cell in a light and a dark theme,
103
+ * which the palette law holds it to.
104
+ */
108
105
  function shadeOf(cell, at) {
109
- const deepest = at.layout.numbers ? DEEPEST_WITH_TEXT : DEEPEST_WITHOUT_TEXT;
106
+ const deepest = at.layout.numbers ? at.deepest : MARK.deepestBare;
107
+ const opacity = MARK.palest + (deepest - MARK.palest) * at.shade(cell.value);
110
108
  return {
111
109
  fill: colorOf(cell, at),
112
- opacity: PALEST + (deepest - PALEST) * at.shade(cell.value)
110
+ opacity
113
111
  };
114
112
  }
115
113
  /**
@@ -1,5 +1,5 @@
1
1
  import { bare, headerNodes } from "../layout/frame.mjs";
2
- import { seriesPaint } from "../theme.mjs";
2
+ import { MARK, seriesPaint } from "../theme.mjs";
3
3
  import { rowsMore } from "./row-marks.mjs";
4
4
  import { cleaned, colorsOf } from "./grid-data.mjs";
5
5
  import { layoutOf } from "./grid-layout.mjs";
@@ -27,6 +27,7 @@ function gridChart(given, options, env) {
27
27
  ...colorsOf(data, options.range, options.diverging),
28
28
  negative: seriesPaint((options.slot ?? 0) + 1),
29
29
  own: seriesPaint(options.slot ?? 0),
30
+ deepest: (options.slot ?? 0) === 0 ? MARK.deepest : MARK.deepestAny,
30
31
  env
31
32
  };
32
33
  return {
@@ -44,7 +44,8 @@ function valueGrid(axis, at) {
44
44
  x2: plot.x + plot.width,
45
45
  y1: place(one.value),
46
46
  y2: place(one.value),
47
- stroke: RULE
47
+ stroke: RULE,
48
+ opacity: MARK.grid
48
49
  }, ...written.has(one) ? [{
49
50
  kind: "text",
50
51
  part: "tick",
@@ -1,5 +1,5 @@
1
1
  import { RULE } from "../scene/paint.mjs";
2
- import { TEXT } from "../theme.mjs";
2
+ import { MARK, TEXT } from "../theme.mjs";
3
3
  import { tickTexts, tickUnder, writtenOf } from "./axes.mjs";
4
4
  // src/marks/x-axis.ts
5
5
  /** The ticks whose numbers are written, left to right, by the rule of every value axis (`writtenOf`). */
@@ -26,7 +26,8 @@ function xGrid(axis, at) {
26
26
  x2: place(value),
27
27
  y1: plot.y,
28
28
  y2: plot.y + plot.height,
29
- stroke: RULE
29
+ stroke: RULE,
30
+ opacity: MARK.grid
30
31
  })), ...writtenTicks(axis, at).map((tick) => tickUnder(tick, plot))];
31
32
  }
32
33
  export { xGrid };
@@ -16,32 +16,32 @@ export declare function paintsOf(things: readonly Toned[], own?: Paint): Paint[]
16
16
  export declare const THEMES: {
17
17
  readonly light: {
18
18
  readonly "--dd-surface": "#ffffff";
19
- readonly "--dd-ink": "#18181b";
20
- readonly "--dd-muted": "#626571";
21
- readonly "--dd-line": "#e4e4e7";
22
- readonly "--dd-other": "#737380";
23
- readonly "--dd-good": "#15803d";
24
- readonly "--dd-danger": "#b91c1c";
25
- readonly "--dd-series-1": "#4c6ba7";
26
- readonly "--dd-series-2": "#a3664c";
27
- readonly "--dd-series-3": "#2d5b51";
28
- readonly "--dd-series-4": "#675522";
29
- readonly "--dd-series-5": "#946379";
30
- readonly "--dd-series-6": "#6e5b86";
19
+ readonly "--dd-ink": "#111620";
20
+ readonly "--dd-muted": "#646974";
21
+ readonly "--dd-line": "#e2e4e8";
22
+ readonly "--dd-other": "#737984";
23
+ readonly "--dd-good": "#19793f";
24
+ readonly "--dd-danger": "#c0282d";
25
+ readonly "--dd-series-1": "#1d5fd3";
26
+ readonly "--dd-series-2": "#eb6834";
27
+ readonly "--dd-series-3": "#1da766";
28
+ readonly "--dd-series-4": "#8986fa";
29
+ readonly "--dd-series-5": "#ee58c0";
30
+ readonly "--dd-series-6": "#33477f";
31
31
  };
32
32
  readonly dark: {
33
- readonly "--dd-surface": "#18181b";
34
- readonly "--dd-ink": "#fafafa";
35
- readonly "--dd-muted": "#a1a1aa";
36
- readonly "--dd-line": "#27272a";
37
- readonly "--dd-other": "#93939e";
38
- readonly "--dd-good": "#4ade80";
39
- readonly "--dd-danger": "#f87171";
40
- readonly "--dd-series-1": "#91bcf5";
41
- readonly "--dd-series-2": "#d0947b";
42
- readonly "--dd-series-3": "#6ea59b";
43
- readonly "--dd-series-4": "#d9c68e";
44
- readonly "--dd-series-5": "#e8aeca";
45
- readonly "--dd-series-6": "#ae9dc9";
33
+ readonly "--dd-surface": "#13151b";
34
+ readonly "--dd-ink": "#eef0f4";
35
+ readonly "--dd-muted": "#969ba6";
36
+ readonly "--dd-line": "#262a32";
37
+ readonly "--dd-other": "#7b818d";
38
+ readonly "--dd-good": "#4fd487";
39
+ readonly "--dd-danger": "#f47c7c";
40
+ readonly "--dd-series-1": "#5589f2";
41
+ readonly "--dd-series-2": "#eb6834";
42
+ readonly "--dd-series-3": "#1baf7a";
43
+ readonly "--dd-series-4": "#b7a1f7";
44
+ readonly "--dd-series-5": "#ea8dcc";
45
+ readonly "--dd-series-6": "#d5dcf7";
46
46
  };
47
47
  };
@@ -61,7 +61,10 @@ const LINE = {
61
61
  * value is drawn at (a column's height, a cell's side), so a value is never drawn as nothing; the surface ring that parts a
62
62
  * dot from what is under it, and a hollow dot's own stroke; how strong the zero line is; how
63
63
  * faint a mark that is not the point is drawn (a period still running, a comparison), and how
64
- * strong a partial fill and a background wash are; and the dashes: of a line the data is read against, of a
64
+ * strong a band's tint, a partial fill and a background wash are; how strong the hue is in a
65
+ * gridline is beside a border in the same colour, so a host's heavy border leaves a plot quiet; how strong the hue is in a
66
+ * heat grid's palest cell and its deepest (with its number on it, in the palette's first two
67
+ * colours and in any of them, and with no number); and the dashes: of a line the data is read against, of a
65
68
  * marked moment (finer, since it marks a time and not a value), of the comparison period's
66
69
  * line, and of a step into or out of a period that is not whole.
67
70
  */
@@ -75,7 +78,12 @@ const MARK = {
75
78
  hollow: 2,
76
79
  zero: .4,
77
80
  faint: .88,
78
- areaFill: .85,
81
+ areaFill: .3,
82
+ grid: .6,
83
+ palest: .08,
84
+ deepest: .72,
85
+ deepestAny: .44,
86
+ deepestBare: .9,
79
87
  partialFill: .55,
80
88
  wash: .2,
81
89
  dash: "4 4",
@@ -207,33 +215,33 @@ function placesOf(things, all) {
207
215
  const THEMES = {
208
216
  light: {
209
217
  "--dd-surface": "#ffffff",
210
- "--dd-ink": "#18181b",
211
- "--dd-muted": "#626571",
212
- "--dd-line": "#e4e4e7",
213
- "--dd-other": "#737380",
214
- "--dd-good": "#15803d",
215
- "--dd-danger": "#b91c1c",
216
- "--dd-series-1": "#4c6ba7",
217
- "--dd-series-2": "#a3664c",
218
- "--dd-series-3": "#2d5b51",
219
- "--dd-series-4": "#675522",
220
- "--dd-series-5": "#946379",
221
- "--dd-series-6": "#6e5b86"
218
+ "--dd-ink": "#111620",
219
+ "--dd-muted": "#646974",
220
+ "--dd-line": "#e2e4e8",
221
+ "--dd-other": "#737984",
222
+ "--dd-good": "#19793f",
223
+ "--dd-danger": "#c0282d",
224
+ "--dd-series-1": "#1d5fd3",
225
+ "--dd-series-2": "#eb6834",
226
+ "--dd-series-3": "#1da766",
227
+ "--dd-series-4": "#8986fa",
228
+ "--dd-series-5": "#ee58c0",
229
+ "--dd-series-6": "#33477f"
222
230
  },
223
231
  dark: {
224
- "--dd-surface": "#18181b",
225
- "--dd-ink": "#fafafa",
226
- "--dd-muted": "#a1a1aa",
227
- "--dd-line": "#27272a",
228
- "--dd-other": "#93939e",
229
- "--dd-good": "#4ade80",
230
- "--dd-danger": "#f87171",
231
- "--dd-series-1": "#91bcf5",
232
- "--dd-series-2": "#d0947b",
233
- "--dd-series-3": "#6ea59b",
234
- "--dd-series-4": "#d9c68e",
235
- "--dd-series-5": "#e8aeca",
236
- "--dd-series-6": "#ae9dc9"
232
+ "--dd-surface": "#13151b",
233
+ "--dd-ink": "#eef0f4",
234
+ "--dd-muted": "#969ba6",
235
+ "--dd-line": "#262a32",
236
+ "--dd-other": "#7b818d",
237
+ "--dd-good": "#4fd487",
238
+ "--dd-danger": "#f47c7c",
239
+ "--dd-series-1": "#5589f2",
240
+ "--dd-series-2": "#eb6834",
241
+ "--dd-series-3": "#1baf7a",
242
+ "--dd-series-4": "#b7a1f7",
243
+ "--dd-series-5": "#ea8dcc",
244
+ "--dd-series-6": "#d5dcf7"
237
245
  }
238
246
  };
239
247
  export { INK, LINE, MARK, MUTED, OTHER, PALETTE, RULE, SPACE, SURFACE, TEXT, THEMES, ownPaint, paintAt, paintsOf, roundedEnd, seriesPaint, signPaint };
@@ -13,6 +13,7 @@ export declare const DISPLAY_OPTIONS: {
13
13
  readonly number: {
14
14
  readonly value: "text";
15
15
  readonly secondary: "text";
16
+ readonly full: "boolean";
16
17
  readonly keepDateRange: "boolean";
17
18
  readonly empty: "text";
18
19
  };
@@ -13,7 +13,8 @@ const DISPLAY_OPTIONS = {
13
13
  number: {
14
14
  ...SHARED,
15
15
  value: "text",
16
- secondary: "text"
16
+ secondary: "text",
17
+ full: "boolean"
17
18
  },
18
19
  table: {
19
20
  ...SHARED,
@@ -52,6 +53,7 @@ const DISPLAY_HELP = {
52
53
  empty: "What the tile says when its answer has no rows.",
53
54
  value: "The query entry a number tile shows large. Without it: a calc when the query has one, else its first value.",
54
55
  secondary: "A query entry a number tile shows as a second, smaller figure under the number, beside its label.",
56
+ full: "Write a number tile's large value in full, where an amount of a thousand or more is otherwise rounded to whole units.",
55
57
  bars: "Query entries drawn with a bar in each cell, as long as the value is beside the column's largest.",
56
58
  heat: "Query entries whose cells are shaded by their value, darker for more.",
57
59
  comparisons: "For a value of the first grouping column, name the drill field for its comparison table and optionally the field to expand each group by.",
@@ -5,4 +5,4 @@
5
5
  * older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
6
6
  * against the files and prints the new value when they change.
7
7
  */
8
- export declare const ENGINE_VERSION = "f390ec5ebe464f91";
8
+ export declare const ENGINE_VERSION = "200e411586e1bf61";
@@ -6,5 +6,5 @@
6
6
  * older code, or in an older shape, is never read. `test/engine-version.test.ts` checks it
7
7
  * against the files and prints the new value when they change.
8
8
  */
9
- const ENGINE_VERSION = "f390ec5ebe464f91";
9
+ const ENGINE_VERSION = "200e411586e1bf61";
10
10
  export { ENGINE_VERSION };
@@ -2,7 +2,8 @@ import { Calendar, Grain } from "../query/types.mjs";
2
2
  import { Micros } from "./instant.mjs";
3
3
  /**
4
4
  * The first instant of the bucket an instant falls in, in the calendar's zone. A day bucket
5
- * starts at the day's first instant, so it lasts 23 or 25 hours across a clock change.
5
+ * starts at the day's first instant (`startOfDate`), so it lasts 23 or 25 hours across a clock
6
+ * change, and every instant is in exactly one.
6
7
  */
7
8
  export declare function bucketStart(instant: Micros, grain: Grain, calendar: Calendar): Micros;
8
9
  /**
@@ -53,12 +53,16 @@ function nextHour(start, zone) {
53
53
  }
54
54
  /**
55
55
  * The first instant of the bucket an instant falls in, in the calendar's zone. A day bucket
56
- * starts at the day's first instant, so it lasts 23 or 25 hours across a clock change.
56
+ * starts at the day's first instant (`startOfDate`), so it lasts 23 or 25 hours across a clock
57
+ * change, and every instant is in exactly one.
57
58
  */
58
59
  function bucketStart(instant, grain, calendar) {
59
60
  const zone = calendar.timezone;
60
61
  if (grain === "hour") return hourStart(instant, zone);
61
- return startOfDate(startDate(zonedAt(instant, zone).toPlainDate(), grain, calendar), zone);
62
+ const date = zonedAt(instant, zone).toPlainDate();
63
+ const start = startOfDate(startDate(date, grain, calendar), zone);
64
+ if (start <= instant) return start;
65
+ return startOfDate(startDate(date.subtract({ days: 1 }), grain, calendar), zone);
62
66
  }
63
67
  /**
64
68
  * The first instant after a bucket start that begins another bucket. An hour is a real hour,
@@ -12,7 +12,12 @@ export type NaiveRule = {
12
12
  * rule excludes it. In a gap, shift_forward moves it later by the gap's length, as Postgres does.
13
13
  */
14
14
  export declare function resolveNaive(time: Temporal.PlainDateTime, rule: NaiveRule): Micros | null;
15
- /** The first instant of a calendar day in a zone: usually midnight, later on a day that skips it. */
15
+ /**
16
+ * The first instant of a calendar day in a zone: usually midnight, later on a day that skips
17
+ * it. Where the clocks fall back across midnight, midnight comes twice with the end of the day
18
+ * before in between: the day starts at the later one, so no two days overlap. Where both
19
+ * midnights are the day's own (clocks set back from 01:00), it starts at the first.
20
+ */
16
21
  export declare function startOfDate(date: Temporal.PlainDate, zone: string): Micros;
17
22
  /** One stretch of time with a single UTC offset, in minutes east of UTC. */
18
23
  export type OffsetSegment = {
@@ -11,9 +11,18 @@ function resolveNaive(time, rule) {
11
11
  if (earlier.toPlainDateTime().equals(time)) return rule.ambiguous === "exclude" ? null : microsOf(rule.ambiguous === "earlier" ? earlier : later);
12
12
  return rule.nonexistent === "exclude" ? null : microsOf(later);
13
13
  }
14
- /** The first instant of a calendar day in a zone: usually midnight, later on a day that skips it. */
14
+ /**
15
+ * The first instant of a calendar day in a zone: usually midnight, later on a day that skips
16
+ * it. Where the clocks fall back across midnight, midnight comes twice with the end of the day
17
+ * before in between: the day starts at the later one, so no two days overlap. Where both
18
+ * midnights are the day's own (clocks set back from 01:00), it starts at the first.
19
+ */
15
20
  function startOfDate(date, zone) {
16
- return microsOf(date.toZonedDateTime(zone));
21
+ const first = date.toZonedDateTime(zone);
22
+ const again = date.toPlainDateTime().toZonedDateTime(zone, { disambiguation: "later" });
23
+ if (again.epochNanoseconds <= first.epochNanoseconds) return microsOf(first);
24
+ const before = again.subtract({ microseconds: 1 }).toPlainDate();
25
+ return microsOf(before.equals(date) ? first : again);
17
26
  }
18
27
  function offsetMinutes(at) {
19
28
  return at.offsetNanoseconds / 6e10;
package/dist/llms.txt CHANGED
@@ -9,7 +9,7 @@ Install skill for coding agents: `npx skills add derive-to/dashboards --skill de
9
9
  - [Quick start](https://github.com/derive-to/dashboards/blob/main/docs/quick-start.md): install, describe your data, mount the handler, show a dashboard, drill in.
10
10
  - [Concepts](https://github.com/derive-to/dashboards/blob/main/docs/concepts.md): the model, measures, joins, tenancy and row policies, access, documents, drill-in.
11
11
  - [Filters](https://github.com/derive-to/dashboards/blob/main/docs/filters.md): the built-in filter bar, theming, options, words, the shadcn copy, custom bars.
12
- - [React](https://github.com/derive-to/dashboards/blob/main/docs/react.md): provider, Dashboard, editing UI, URL state, drill parts, widget builder; the tiles and their `display` options (a number's `value` and `secondary`, a table's `bars`, `heat`, `compact` and `comparisons` for grouped drill-down, a list's lines); plain SVG functions in `derive-dashboards/charts`, the two chart kits and what each kind draws (`CHARTS_RENDERERS` from `derive-dashboards/charts-react`: line, bar, area, small multiples, heatmap, funnel; a bar's `against`, an area's `share`, small multiples' `ownScales`); a table a viewer sorts; a tile's answer as CSV (`csv={false}` turns the button off, `downloadCsv` and `csvOf` for your own). Use `drill.compare` on a row in a custom renderer. Catch `DashboardDocumentError` for invalid code dashboards. Translate drill labels with `messages.drillMetricTotal`, `drillCompareGroup`, `drillGroupedBy`, `drillRecordPages` and `drillTrendWindow`.
12
+ - [React](https://github.com/derive-to/dashboards/blob/main/docs/react.md): provider, Dashboard (`tiles="sheet"` or `"cards"`), editing UI, URL state, drill parts, widget builder; the tiles and their `display` options (a number's `value`, `secondary` and `full`, with `formatHeadline` for a tile of your own, a table's `bars`, `heat`, `compact` and `comparisons` for grouped drill-down, a list's lines); plain SVG functions in `derive-dashboards/charts`, the two chart kits and what each kind draws (`CHARTS_RENDERERS` from `derive-dashboards/charts-react`: line, bar, area, small multiples, heatmap, funnel; a bar's `against`, an area's `share`, small multiples' `ownScales`); a table a viewer sorts; a tile's answer as CSV (`csv={false}` turns the button off, `downloadCsv` and `csvOf` for your own). Use `drill.compare` on a row in a custom renderer. Catch `DashboardDocumentError` for invalid code dashboards. Translate drill labels with `messages.drillMetricTotal`, `drillCompareGroup`, `drillGroupedBy`, `drillRecordPages` and `drillTrendWindow`.
13
13
  - [CLI](https://github.com/derive-to/dashboards/blob/main/docs/cli.md): init, check, generate, create-tables, add, importing from dbt or Cube.
14
14
  - [Endpoints](https://github.com/derive-to/dashboards/blob/main/docs/endpoints.md): every handler endpoint, its body and answer.
15
15
  - [MCP](https://github.com/derive-to/dashboards/blob/main/docs/mcp.md): tools that let agents query and edit dashboards as themselves.
@@ -59,7 +59,7 @@ function Filters({ board, doc }) {
59
59
  timezone: doc.scope.timezone ?? answeredZone(board.tiles.results)
60
60
  });
61
61
  }
62
- /** The span most tiles cover, said once under the filters; the tiles that cover it leave it out. */
62
+ /** The span most tiles cover, said once over the grid; the tiles that cover it leave it out. */
63
63
  function DashboardSpan({ results }) {
64
64
  const shared = sharedSpan(results);
65
65
  const one = [...results.values()].find((result) => spanKey(result) === shared);
@@ -68,7 +68,7 @@ function DashboardSpan({ results }) {
68
68
  children: /* @__PURE__ */ jsx(Span, { result: one })
69
69
  });
70
70
  }
71
- /** The canvas: header, tabs, filters, and the grid with its marks. */
71
+ /** The canvas: the header with the filters in it, the tabs, and the grid with its marks. */
72
72
  function Canvas(props) {
73
73
  const { board, shown } = props;
74
74
  const { edit, panels, view } = board;
@@ -86,7 +86,11 @@ function Canvas(props) {
86
86
  historyOpen: panels.panel === "history",
87
87
  onAdd: add,
88
88
  onHistory: panels.toggleHistory,
89
- link: () => linkTo(view.current, props.dashboard.linkFor)
89
+ link: () => linkTo(view.current, props.dashboard.linkFor),
90
+ filters: /* @__PURE__ */ jsx(Filters, {
91
+ board,
92
+ doc: shown.doc
93
+ })
90
94
  }),
91
95
  /* @__PURE__ */ jsx(Dropped, { names: view.dropped }),
92
96
  /* @__PURE__ */ jsx(Tabs, {
@@ -94,10 +98,6 @@ function Canvas(props) {
94
98
  current: shown.tab,
95
99
  onSelect: view.setTab
96
100
  }),
97
- /* @__PURE__ */ jsx(Filters, {
98
- board,
99
- doc: shown.doc
100
- }),
101
101
  /* @__PURE__ */ jsx(DashboardSpan, { results: board.tiles.results }),
102
102
  edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
103
103
  /* @__PURE__ */ jsx(Grid, {
@@ -28,6 +28,12 @@ export type DashboardProps = {
28
28
  linkDropped?: readonly string[];
29
29
  /** The link Share copies for a view; by default, this page's address with the view in it. */
30
30
  linkFor?: (view: ViewState) => string;
31
+ /**
32
+ * How tiles sit when the dashboard is read: "sheet" (the default) joins them as one ruled
33
+ * sheet, sharing hairline rules; "cards" keeps each a card of its own, with room between.
34
+ * While editing they are always cards, with room to drag into.
35
+ */
36
+ tiles?: "sheet" | "cards";
31
37
  } & DashboardEvents & DashboardDrillProps;
32
38
  /**
33
39
  * One dashboard. Everything drawn in it, the builder's preview too, shares one book of series
@@ -102,6 +102,7 @@ function Board(props) {
102
102
  id: props.id,
103
103
  board,
104
104
  drill: props,
105
+ tiles: props.tiles ?? "sheet",
105
106
  children: [/* @__PURE__ */ jsxs("div", {
106
107
  className: "dd-board",
107
108
  children: [
@@ -17,6 +17,7 @@ function Title({ doc, edit, isNew }) {
17
17
  }, [isNew, editing]);
18
18
  if (!editing) return /* @__PURE__ */ jsx("h2", {
19
19
  className: "dd-title",
20
+ title: doc.meta.title,
20
21
  children: doc.meta.title
21
22
  });
22
23
  const save = () => {
@@ -89,23 +90,26 @@ function Header(props) {
89
90
  edit,
90
91
  isNew: props.unpublished === true
91
92
  }), /* @__PURE__ */ jsxs("div", {
92
- className: "dd-header-actions",
93
- children: [
94
- props.unpublished === true || editing ? null : /* @__PURE__ */ jsx(ShareButton, { link: props.link }),
95
- editing || version === 0 ? null : /* @__PURE__ */ jsx("button", {
96
- type: "button",
97
- className: "dd-button dd-quiet",
98
- "aria-expanded": props.historyOpen,
99
- onClick: props.onHistory,
100
- children: messages.history
101
- }),
102
- /* @__PURE__ */ jsx(EditButton, {
103
- edit,
104
- canEdit,
105
- waiting,
106
- onAdd: props.onAdd
107
- })
108
- ]
93
+ className: "dd-header-controls",
94
+ children: [props.filters, /* @__PURE__ */ jsxs("div", {
95
+ className: "dd-header-actions",
96
+ children: [
97
+ props.unpublished === true || editing ? null : /* @__PURE__ */ jsx(ShareButton, { link: props.link }),
98
+ editing || version === 0 ? null : /* @__PURE__ */ jsx("button", {
99
+ type: "button",
100
+ className: "dd-button dd-quiet",
101
+ "aria-expanded": props.historyOpen,
102
+ onClick: props.onHistory,
103
+ children: messages.history
104
+ }),
105
+ /* @__PURE__ */ jsx(EditButton, {
106
+ edit,
107
+ canEdit,
108
+ waiting,
109
+ onAdd: props.onAdd
110
+ })
111
+ ]
112
+ })]
109
113
  })]
110
114
  }), doc.meta.description === void 0 ? null : /* @__PURE__ */ jsx("p", {
111
115
  className: "dd-description",
@@ -10,6 +10,14 @@ const NUMBER_TYPES = /* @__PURE__ */ new Set([
10
10
  ]);
11
11
  /** Whether a column's cells are numbers: a value, or a group that is a number. They are set to the right and never cut. */
12
12
  const isNumeric = (column) => isValue(column) || NUMBER_TYPES.has(column.type);
13
+ /**
14
+ * Whether a column is a measure or a calc of numbers, asked of what a formatter is given: its
15
+ * role and type alone. A group that is a number (a year, an id) is not one: its text is a name.
16
+ */
17
+ function isNumberValue(column) {
18
+ const role = column?.role ?? (column?.id === void 0 ? void 0 : roleOf({ id: column.id }));
19
+ return (role === "measure" || role === "calc") && NUMBER_TYPES.has(column?.type ?? "");
20
+ }
13
21
  /** Whether a column's type holds numbers. */
14
22
  const isNumberType = (type) => NUMBER_TYPES.has(type);
15
- export { isNumberType, isNumeric, isValue };
23
+ export { isNumberType, isNumberValue, isNumeric, isValue };
@@ -92,6 +92,7 @@ function DrillScope(props) {
92
92
  children: /* @__PURE__ */ jsx("div", {
93
93
  className: "dd-dashboard",
94
94
  "data-editing": board.edit.draft !== void 0,
95
+ "data-tiles": props.tiles,
95
96
  "data-panel": panel !== void 0,
96
97
  "data-drill": panel === void 0 && drilling,
97
98
  children: props.children
@@ -18,7 +18,8 @@ export type DrillMarkProps = {
18
18
  * (`m1`), needed when the answer has more than one.
19
19
  */
20
20
  export type TileDrill = {
21
- props: (row: number | readonly ResultCell[], entry?: string) => DrillMarkProps | undefined;
21
+ /** `written` is how the tile writes the entry's value, when not as `formatCell` does: the mark is named by what is seen. */
22
+ props: (row: number | readonly ResultCell[], entry?: string, written?: string) => DrillMarkProps | undefined;
22
23
  /** Open every measure of a group together, if the server sealed the row. */
23
24
  compare?: (row: Row, view: Extract<DrillView, {
24
25
  by: "comparison";
@@ -3,15 +3,15 @@ import { drillFrom } from "./state.mjs";
3
3
  import { roleOf } from "derive-dashboards/core";
4
4
  // src/drill/props.ts
5
5
  const isLine = (c) => roleOf(c) === "measure" || roleOf(c) === "calc";
6
- /** A mark's name for a screen reader: its groups, then its value. */
7
- function markLabel(answer, row, format, entry) {
6
+ /** A mark's name for a screen reader: its groups, then its value, as the tile writes it. */
7
+ function markLabel(answer, row, format, { entry, written } = {}) {
8
8
  const named = answer.columns.length > 1 ? entry : void 0;
9
9
  const text = answer.columns.map((c, i) => ({
10
10
  c,
11
11
  cell: row[i] ?? null
12
12
  })).filter(({ c }) => named === void 0 || !isLine(c) || c.id === named).map(({ c, cell }) => {
13
13
  if (!isLine(c)) return groupText(cell, c, format);
14
- const value = formatCell(cell, c, format);
14
+ const value = c.id === entry && written !== void 0 ? written : formatCell(cell, c, format);
15
15
  return named !== void 0 && isLine(c) ? `${c.label} ${value}` : value;
16
16
  }).join(", ");
17
17
  return format.messages.drillMark(text);
@@ -78,10 +78,13 @@ function tileDrill(a) {
78
78
  openAll: (entry, view) => {
79
79
  open(void 0, entry ?? (single ? void 0 : firstLine), view ?? ITEMS);
80
80
  },
81
- props: (row, entry) => {
81
+ props: (row, entry, written) => {
82
82
  const cells = typeof row === "number" ? answer.rows[row] : row;
83
83
  if (cells === void 0 || stateOf(row, entry) === void 0) return;
84
- return markProps(markLabel(answer, cells, a.format, entry), () => {
84
+ return markProps(markLabel(answer, cells, a.format, {
85
+ entry,
86
+ written
87
+ }), () => {
85
88
  open(row, entry);
86
89
  });
87
90
  }
@@ -7,7 +7,7 @@ import { ResultCell, ResultColumn } from "derive-dashboards/core";
7
7
  */
8
8
  export declare function plotValue(cell: ResultCell): number | null;
9
9
  /** What formatting reads of a column: its type, and a time bucket's grain or a money unit. */
10
- type Shape = Pick<ResultColumn, "type" | "grain" | "unit" | "format" | "signed" | "fraction">;
10
+ export type Shape = Pick<ResultColumn, "id" | "role" | "type" | "grain" | "unit" | "format" | "signed" | "fraction">;
11
11
  /**
12
12
  * A cell as text for a person, in their locale and words. A renderer can pass its own props as
13
13
  * `format`: they carry both.