derive-dashboards 0.6.0 → 0.7.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 (134) hide show
  1. package/dist/charts/kinds/area-marks.mjs +2 -1
  2. package/dist/charts/kinds/funnel-words.mjs +1 -1
  3. package/dist/charts/kinds/grid-marks.mjs +9 -4
  4. package/dist/charts/theme.d.mts +13 -13
  5. package/dist/charts/theme.mjs +17 -14
  6. package/dist/charts-react/Overlay.mjs +1 -0
  7. package/dist/charts-react/chart-unlayered.css +1 -107
  8. package/dist/charts-react/chart.css +1 -121
  9. package/dist/charts-react/tip-place.mjs +30 -15
  10. package/dist/core/document/display-comparisons.mjs +49 -0
  11. package/dist/core/document/display-validation.d.mts +12 -0
  12. package/dist/core/document/display-validation.mjs +56 -0
  13. package/dist/core/document/display.d.mts +6 -12
  14. package/dist/core/document/display.mjs +23 -48
  15. package/dist/core/engine/dialect.d.mts +2 -0
  16. package/dist/core/engine/index.mjs +1 -1
  17. package/dist/core/engine/levels.mjs +33 -1
  18. package/dist/core/engine/postgres.mjs +1 -0
  19. package/dist/core/engine/rank.mjs +1 -1
  20. package/dist/core/engine/reader.d.mts +4 -0
  21. package/dist/core/engine/sql-partition.mjs +45 -0
  22. package/dist/core/engine/sql-reads.mjs +4 -1
  23. package/dist/core/engine/statement.mjs +4 -4
  24. package/dist/core/engine/version.d.mts +1 -1
  25. package/dist/core/engine/version.mjs +1 -1
  26. package/dist/core/error/codes.d.mts +1 -1
  27. package/dist/core/error/codes.mjs +1 -1
  28. package/dist/core/index.d.mts +6 -5
  29. package/dist/core/index.mjs +8 -7
  30. package/dist/core/model/validate/fields.mjs +1 -1
  31. package/dist/core/query/drill/compose.d.mts +2 -0
  32. package/dist/core/query/drill/compose.mjs +1 -1
  33. package/dist/core/query/drill/synthetic.mjs +1 -1
  34. package/dist/core/query/drill/types.d.mts +7 -0
  35. package/dist/core/query/drill/types.mjs +3 -1
  36. package/dist/core/schema/answers.d.mts +1176 -362
  37. package/dist/core/schema/drill-answers.mjs +19 -1
  38. package/dist/core/schema/drill.d.mts +21 -6
  39. package/dist/core/schema/drill.mjs +7 -1
  40. package/dist/core/schema/tools.mjs +13 -0
  41. package/dist/core/time/index.d.mts +2 -2
  42. package/dist/core/time/text-time.d.mts +9 -2
  43. package/dist/core/time/text-time.mjs +18 -3
  44. package/dist/core/types/api.d.mts +1 -1
  45. package/dist/core/types/api.mjs +1 -1
  46. package/dist/core/types/drill-api.d.mts +22 -2
  47. package/dist/dashboard-documents.d.mts +8 -0
  48. package/dist/dashboard-documents.mjs +52 -0
  49. package/dist/drill-access.mjs +40 -3
  50. package/dist/drill-comparison.mjs +71 -0
  51. package/dist/drill-crumbs.mjs +21 -2
  52. package/dist/drill-group-seal.mjs +13 -0
  53. package/dist/drill-open.mjs +7 -1
  54. package/dist/drill-seal.mjs +4 -6
  55. package/dist/drill-views.mjs +5 -13
  56. package/dist/drill.mjs +28 -58
  57. package/dist/editing.mjs +1 -1
  58. package/dist/endpoints/drill.mjs +2 -3
  59. package/dist/endpoints/index.d.mts +20 -0
  60. package/dist/index.d.mts +2 -1
  61. package/dist/index.mjs +6 -27
  62. package/dist/llms.txt +1 -1
  63. package/dist/react/Cell.mjs +2 -2
  64. package/dist/react/DashboardList.mjs +3 -3
  65. package/dist/react/Editing.mjs +3 -3
  66. package/dist/react/Header.mjs +2 -2
  67. package/dist/react/History.mjs +3 -3
  68. package/dist/react/Parts.mjs +2 -2
  69. package/dist/react/RowBody.d.mts +2 -4
  70. package/dist/react/RowBody.mjs +14 -39
  71. package/dist/react/Tile.mjs +4 -5
  72. package/dist/react/builder/FilterEditor.mjs +2 -2
  73. package/dist/react/builder/Picker.mjs +3 -3
  74. package/dist/react/builder/RangeEditor.mjs +3 -3
  75. package/dist/react/builder/Time.mjs +3 -3
  76. package/dist/react/builder/Values.mjs +2 -2
  77. package/dist/react/builder/WidgetBuilder.mjs +2 -2
  78. package/dist/react/drill/Bars.mjs +34 -38
  79. package/dist/react/drill/Comparison.mjs +204 -0
  80. package/dist/react/drill/Controls.mjs +8 -12
  81. package/dist/react/drill/DrillDrawer.mjs +42 -0
  82. package/dist/react/drill/DrillPanel.mjs +61 -41
  83. package/dist/react/drill/Header.mjs +65 -35
  84. package/dist/react/drill/ItemLink.mjs +40 -0
  85. package/dist/react/drill/Items.d.mts +2 -1
  86. package/dist/react/drill/Items.mjs +126 -99
  87. package/dist/react/drill/ItemsBody.mjs +38 -0
  88. package/dist/react/drill/ItemsFoot.mjs +24 -19
  89. package/dist/react/drill/Notes.mjs +23 -13
  90. package/dist/react/drill/PanelBody.mjs +7 -25
  91. package/dist/react/drill/RecordRow.mjs +47 -0
  92. package/dist/react/drill/Trend.mjs +186 -0
  93. package/dist/react/drill/board.mjs +21 -11
  94. package/dist/react/drill/drawer-context.mjs +5 -0
  95. package/dist/react/drill/item-parts.mjs +53 -35
  96. package/dist/react/drill/item-type.d.mts +2 -2
  97. package/dist/react/drill/lazy.d.mts +1 -4
  98. package/dist/react/drill/lazy.mjs +29 -11
  99. package/dist/react/drill/panel-focus.mjs +18 -7
  100. package/dist/react/drill/props.d.mts +7 -1
  101. package/dist/react/drill/props.mjs +39 -8
  102. package/dist/react/drill/record-page.mjs +61 -0
  103. package/dist/react/drill/state.mjs +17 -2
  104. package/dist/react/drill/trend-touch.mjs +33 -0
  105. package/dist/react/drill/useDrill.d.mts +3 -3
  106. package/dist/react/drill/useDrill.mjs +35 -15
  107. package/dist/react/drill/words.d.mts +14 -0
  108. package/dist/react/drill/words.mjs +19 -7
  109. package/dist/react/english.d.mts +1 -0
  110. package/dist/react/english.mjs +1 -0
  111. package/dist/react/filters/chip.mjs +2 -2
  112. package/dist/react/filters/menu-search.mjs +5 -5
  113. package/dist/react/filters/menu.mjs +2 -2
  114. package/dist/react/filters/number.mjs +2 -2
  115. package/dist/react/filters/operator.mjs +2 -2
  116. package/dist/react/filters/phone.mjs +2 -2
  117. package/dist/react/filters/values.mjs +4 -4
  118. package/dist/react/format-time.d.mts +1 -0
  119. package/dist/react/format-time.mjs +39 -33
  120. package/dist/react/format.mjs +10 -1
  121. package/dist/react/renderers/list.mjs +8 -10
  122. package/dist/react/renderers/table-cells.mjs +38 -9
  123. package/dist/react/renderers/table-measure.mjs +2 -0
  124. package/dist/react/renderers/table-row.mjs +64 -7
  125. package/dist/react/renderers/table-sort.mjs +2 -8
  126. package/dist/react/renderers/table.mjs +16 -15
  127. package/dist/react/theme-unlayered.css +1 -3148
  128. package/dist/react/theme.css +1 -3150
  129. package/dist/recharts/parts.mjs +1 -1
  130. package/dist/skills/derive-dashboards/SKILL.md +4 -2
  131. package/dist/store/apply.mjs +2 -2
  132. package/dist/store/editor.mjs +2 -2
  133. package/dist/store/writer.mjs +2 -2
  134. package/package.json +1 -1
package/dist/drill.mjs CHANGED
@@ -1,13 +1,14 @@
1
- import { clockOf, mayRead, readableFor } from "./drill-access.mjs";
2
- import { crumbs, forOpener } from "./drill-crumbs.mjs";
1
+ import { clockOf, mayRead, offeredFields, readableFor } from "./drill-access.mjs";
2
+ import { crumbs, forOpener, normalizedDrillState } from "./drill-crumbs.mjs";
3
3
  import { explanationView } from "./drill-explain.mjs";
4
4
  import { drillItems } from "./drill-items.mjs";
5
- import { cutTo, openDrill } from "./drill-open.mjs";
5
+ import { cutTo, openDrill, visibleSelection } from "./drill-open.mjs";
6
6
  import { abilities, holdsNoRows, summarize } from "./drill-summary.mjs";
7
7
  import { chosenView, groupedView } from "./drill-views.mjs";
8
+ import { compareGroups } from "./drill-comparison.mjs";
8
9
  import { wire } from "./execute.mjs";
9
10
  import { resultColumns } from "derive-dashboards/core";
10
- import { composeDrill, drillMeasure, lineFilter, lineSemantics, offeredMembers, pathFields, stepMembers } from "derive-dashboards/core/engine";
11
+ import { composeDrill, drillMeasure, lineSemantics, stepMembers } from "derive-dashboards/core/engine";
11
12
  // src/drill.ts
12
13
  /** The drill's query and its line, for the path as it stands. */
13
14
  function composed(o) {
@@ -25,34 +26,6 @@ function composed(o) {
25
26
  };
26
27
  }
27
28
  /**
28
- * The fields Breakdown offers this viewer at this step, each labelled as a column of the tile
29
- * would read it: the model's preferred and small-valued fields the tile, the path and the line's
30
- * own measure do not fix, the field an Other was cut on first, each one the viewer may read.
31
- */
32
- async function offeredFields(o, set) {
33
- const { model } = o.x.rt.options;
34
- const where = lineFilter(model, set, o.drill, { operand: false });
35
- const path = {
36
- ...pathFields(o.drill.steps),
37
- where
38
- };
39
- const ids = offeredMembers(model, o.x.query, path, readableFor(o.x));
40
- const allowed = await Promise.all(ids.map((id) => mayRead(o, id)));
41
- const kept = ids.filter((_id, i) => allowed[i] === true);
42
- const dimensions = kept.map((member, i) => ({
43
- id: `d${i + 1}`,
44
- member
45
- }));
46
- const columns = resultColumns(model, {
47
- ...o.x.query,
48
- dimensions
49
- });
50
- return kept.map((id, i) => ({
51
- id,
52
- label: columns.find((c) => c.id === `d${i + 1}`)?.label ?? id
53
- }));
54
- }
55
- /**
56
29
  * The path cut at its first step on a field this viewer may not read: a link opened with less
57
30
  * access opens at the deepest step it can, and says part of it was left out.
58
31
  */
@@ -68,18 +41,23 @@ const needsSummary = (body) => body.summary !== false || body.state.view.by ===
68
41
  * holds no row this viewer can see, so nothing about rows they cannot see is shown, not even
69
42
  * that there are some.
70
43
  */
71
- async function ready(o, body) {
72
- const { set, line } = composed(o);
73
- const offered = await offeredFields(o, set);
74
- const summed = o.foreign || needsSummary(body) ? await summarize(o, set, line, offered) : void 0;
75
- const empty = summed !== void 0 && holdsNoRows(summed.summary);
76
- return o.foreign && empty && o.selections.length > 0 ? ready(cutTo(o, o.selections.length - 1), body) : {
77
- o,
78
- set,
79
- line,
80
- offered,
81
- ...summed === void 0 ? {} : { summed }
82
- };
44
+ function ready(scope, body) {
45
+ return visibleSelection(scope, async (o) => {
46
+ const { set, line } = composed(o);
47
+ const offered = await offeredFields(o, set);
48
+ const summed = o.foreign || needsSummary(body) ? await summarize(o, set, line, offered) : void 0;
49
+ const empty = summed !== void 0 && holdsNoRows(summed.summary);
50
+ return {
51
+ value: {
52
+ o,
53
+ set,
54
+ line,
55
+ offered,
56
+ ...summed === void 0 ? {} : { summed }
57
+ },
58
+ empty
59
+ };
60
+ });
83
61
  }
84
62
  /** The view as the drill shows it, and what it shows. */
85
63
  async function shownView(r, view, page) {
@@ -94,10 +72,7 @@ async function shownView(r, view, page) {
94
72
  column,
95
73
  only: view.numerator === true
96
74
  }, page ?? {}),
97
- view: view.numerator === true ? {
98
- by: "items",
99
- numerator: true
100
- } : { by: "items" }
75
+ view
101
76
  };
102
77
  }
103
78
  if (view.by === "explanation") {
@@ -126,12 +101,14 @@ async function shownView(r, view, page) {
126
101
  * numbers kept apart, its path as breadcrumbs, its state normalized, and the view it shows.
127
102
  */
128
103
  async function runDrill(rt, principal, request, body) {
129
- const r = await ready(await permitted(await openDrill({
104
+ const opened = await permitted(await openDrill({
130
105
  rt,
131
106
  principal,
132
107
  request,
133
108
  state: body.state
134
- })), body);
109
+ }));
110
+ if (body.state.view.by === "comparison") return compareGroups(opened, body.state, body.state.view);
111
+ const r = await ready(opened, body);
135
112
  const can = r.summed?.summary.can ?? await abilities(r.o, r.line, r.offered);
136
113
  const choice = r.summed?.summary ?? {
137
114
  can,
@@ -139,14 +116,7 @@ async function runDrill(rt, principal, request, body) {
139
116
  };
140
117
  const { shown, view } = await shownView(r, chosenView(body.state.view, choice), body.page);
141
118
  const { first: _first, ...plain } = view;
142
- const views = body.state.views?.slice(0, Math.max(0, r.o.path.length - 1));
143
- const { views: _v, ...rest } = body.state;
144
- const state = {
145
- ...rest,
146
- path: r.o.path,
147
- view: plain,
148
- ...views === void 0 || views.length === 0 ? {} : { views }
149
- };
119
+ const state = normalizedDrillState(body.state, r.o.path, plain);
150
120
  return forOpener({
151
121
  ...r.summed === void 0 ? {} : { summary: r.summed.summary },
152
122
  path: crumbs(r.o),
package/dist/editing.mjs CHANGED
@@ -11,7 +11,7 @@ import { principalTenant } from "derive-dashboards/core";
11
11
  function storeFor(rt, request) {
12
12
  const adapter = adapterFor(rt.options, request);
13
13
  if (adapter === void 0) throw new HttpError(400, "STORE_REQUIRED", "Editing dashboards needs a store: pass `database` to deriveDashboards.");
14
- return createStore(adapter);
14
+ return createStore(adapter, rt.drillModel);
15
15
  }
16
16
  /**
17
17
  * What a draft of `id` starts from: a built-in by its key, or a stored dashboard by the one id
@@ -5,9 +5,8 @@ import { createDashEndpoint } from "derive-dashboards/core";
5
5
  // src/endpoints/drill.ts
6
6
  /** The dashboard a drill body starts from, before its schema checks it. */
7
7
  function dashboardOf(body) {
8
- const parsed = bodies.drill.safeParse(body);
9
- const origin = parsed.success ? parsed.data.state.origin : void 0;
10
- if (origin?.kind !== "dashboard") throw new HttpError(400, "BODY_INVALID", "state.origin: a dashboard's tile is required here.");
8
+ const { origin } = parseWith(bodies.drill, body).state;
9
+ if (origin.kind !== "dashboard") throw new HttpError(400, "BODY_INVALID", "state.origin: a dashboard's tile is required here.");
11
10
  return {
12
11
  kind: "dashboard",
13
12
  id: origin.dashboardId
@@ -113,11 +113,16 @@ export declare function coreEndpoints(rt: Runtime): {
113
113
  by: "breakdown";
114
114
  member?: string;
115
115
  search?: string;
116
+ } | {
117
+ by: "comparison";
118
+ member: string;
119
+ thenBy?: string;
116
120
  } | {
117
121
  by: "trend";
118
122
  grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
119
123
  } | {
120
124
  by: "items";
125
+ fields?: true;
121
126
  numerator?: true;
122
127
  } | {
123
128
  by: "explanation";
@@ -127,11 +132,16 @@ export declare function coreEndpoints(rt: Runtime): {
127
132
  by: "breakdown";
128
133
  member?: string;
129
134
  search?: string;
135
+ } | {
136
+ by: "comparison";
137
+ member: string;
138
+ thenBy?: string;
130
139
  } | {
131
140
  by: "trend";
132
141
  grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
133
142
  } | {
134
143
  by: "items";
144
+ fields?: true;
135
145
  numerator?: true;
136
146
  } | {
137
147
  by: "explanation";
@@ -223,11 +233,16 @@ export declare function coreEndpoints(rt: Runtime): {
223
233
  by: "breakdown";
224
234
  member?: string;
225
235
  search?: string;
236
+ } | {
237
+ by: "comparison";
238
+ member: string;
239
+ thenBy?: string;
226
240
  } | {
227
241
  by: "trend";
228
242
  grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
229
243
  } | {
230
244
  by: "items";
245
+ fields?: true;
231
246
  numerator?: true;
232
247
  } | {
233
248
  by: "explanation";
@@ -237,11 +252,16 @@ export declare function coreEndpoints(rt: Runtime): {
237
252
  by: "breakdown";
238
253
  member?: string;
239
254
  search?: string;
255
+ } | {
256
+ by: "comparison";
257
+ member: string;
258
+ thenBy?: string;
240
259
  } | {
241
260
  by: "trend";
242
261
  grain?: "hour" | "day" | "week" | "month" | "quarter" | "year";
243
262
  } | {
244
263
  by: "items";
264
+ fields?: true;
245
265
  numerator?: true;
246
266
  } | {
247
267
  by: "explanation";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { coreEndpoints } from "./endpoints/index.mjs";
2
+ import { DashboardDocumentError } from "./dashboard-documents.mjs";
2
3
  import { CustomSourceOptions, customSource } from "./custom-source.mjs";
3
4
  import { HttpError } from "./http.mjs";
4
5
  import { PgPool, PgQueryable, nodePostgres } from "./node-postgres.mjs";
@@ -23,4 +24,4 @@ export declare function deriveDashboards<const O extends DashOptions>(options: O
23
24
  /** Typed from the model: a template per source, and no source the model lacks. */
24
25
  itemLinks?: ItemLinksFor<O["model"], O["itemLinks"]>;
25
26
  }): DashServer<O>;
26
- export { type CustomSourceOptions, HttpError, type PgPool, type PgQueryable, type PostgresConnectionOptions, type PostgresStoreOptions, type RunRows, type RunSql, type SchemaDiff, SchemaMismatchError, createTables, customSource, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
27
+ export { type CustomSourceOptions, DashboardDocumentError, HttpError, type PgPool, type PgQueryable, type PostgresConnectionOptions, type PostgresStoreOptions, type RunRows, type RunSql, type SchemaDiff, SchemaMismatchError, createTables, customSource, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createCache } from "./cache.mjs";
2
2
  import { cursorKey, macKey } from "./cursor-seal.mjs";
3
+ import { DashboardDocumentError, checkedDashboards } from "./dashboard-documents.mjs";
3
4
  import { warnSecretAtStart } from "./drill-secret.mjs";
4
5
  import { coreEndpoints } from "./endpoints/index.mjs";
5
6
  import { createHandler, serverCall } from "./handler.mjs";
@@ -11,33 +12,10 @@ import { postgresConnection } from "./postgres-connection.mjs";
11
12
  import { postgresStore } from "./postgres-store.mjs";
12
13
  import { memoryStorage } from "./storage.mjs";
13
14
  import { SchemaMismatchError, createTables, schemaDiff } from "./store/create-tables.mjs";
14
- import { BASE_ERROR_CODES, defineModel, documentDisplayIssues, linkTemplateIssues } from "derive-dashboards/core";
15
+ import { BASE_ERROR_CODES, defineModel, linkTemplateIssues } from "derive-dashboards/core";
15
16
  import { drillModel } from "derive-dashboards/core/engine";
16
- import { loadDocument } from "derive-dashboards/core/schema";
17
17
  // src/index.ts
18
18
  /**
19
- * Code-defined dashboards are checked when the handler is made, not when a viewer opens one: an
20
- * invalid document stops the server with every problem named, and a layout is repaired once.
21
- */
22
- function checkedDashboards(options) {
23
- return (options.dashboards ?? []).map((d) => {
24
- const loaded = loadDocument(d.document);
25
- if (!loaded.ok) {
26
- const problems = loaded.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
27
- throw new Error(`The dashboard "${d.key}" is not a valid document: ${problems}`);
28
- }
29
- const wrong = documentDisplayIssues(loaded.doc);
30
- if (wrong.length > 0) {
31
- const problems = wrong.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
32
- throw new Error(`The dashboard "${d.key}" has display options to fix: ${problems}`);
33
- }
34
- return {
35
- key: d.key,
36
- document: loaded.doc
37
- };
38
- });
39
- }
40
- /**
41
19
  * Every connection the model's sources read is given, and each one given as it is (not per
42
20
  * request) is a connection, or the server does not start.
43
21
  */
@@ -101,16 +79,17 @@ function deriveDashboards(options) {
101
79
  defineModel(options.model);
102
80
  checkConnections(options);
103
81
  checkItemLinks(options);
82
+ const model = drillModel(options.model);
104
83
  const checked = {
105
84
  ...options,
106
- dashboards: checkedDashboards(options)
85
+ dashboards: checkedDashboards(options, model)
107
86
  };
108
87
  const rt = {
109
88
  options: checked,
110
89
  cache: createCache(checked),
111
90
  cursorKey: cursorKey(options.secret),
112
91
  macKey: macKey(options.secret),
113
- drillModel: drillModel(checked.model),
92
+ drillModel: model,
114
93
  warned: { secret: false }
115
94
  };
116
95
  warnSecretAtStart(rt);
@@ -144,4 +123,4 @@ function deriveDashboards(options) {
144
123
  options
145
124
  };
146
125
  }
147
- export { HttpError, SchemaMismatchError, createTables, customSource, deriveDashboards, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
126
+ export { DashboardDocumentError, HttpError, SchemaMismatchError, createTables, customSource, deriveDashboards, memoryStorage, nodePostgres, postgresConnection, postgresStore, schemaDiff };
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` and `compact`, 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, heat grid, 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).
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, heat grid, 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.
@@ -3,12 +3,12 @@ import { TileActions } from "./Editing.mjs";
3
3
  import { placeOf, useBringIntoView } from "./place.mjs";
4
4
  import { Tile } from "./Tile.mjs";
5
5
  import { memo, useEffect, useMemo } from "react";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/Cell.tsx
8
8
  /** The grip that moves a tile, and the corner that resizes it, while the dashboard is a draft. */
9
9
  function Handles(props) {
10
10
  const { messages } = useDashboards();
11
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
11
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
12
12
  type: "button",
13
13
  className: "dd-move",
14
14
  "aria-label": messages.moveWidget(props.title),
@@ -2,7 +2,7 @@ import { useDashboards } from "./context.mjs";
2
2
  import { Row } from "./DashboardListRow.mjs";
3
3
  import { useId, useState } from "react";
4
4
  import useSWR from "swr";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  // src/DashboardList.tsx
7
7
  /** The SWR key of the dashboard list, refreshed whenever a dashboard is made, published or discarded. */
8
8
  const LIST_KEY = "dd-list";
@@ -59,7 +59,7 @@ function CopyLink(props) {
59
59
  function Search(props) {
60
60
  const { messages } = useDashboards();
61
61
  const { all, search, setSearch } = props;
62
- return /* @__PURE__ */ jsxs(Fragment, { children: [all.length > 6 ? /* @__PURE__ */ jsx("input", {
62
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [all.length > 6 ? /* @__PURE__ */ jsx("input", {
63
63
  type: "search",
64
64
  className: "dd-list-search",
65
65
  "aria-label": messages.searchDashboards,
@@ -109,7 +109,7 @@ function Groups(props) {
109
109
  const builtIn = props.items.filter((d) => d.id.startsWith("default:"));
110
110
  const made = props.items.filter((d) => !d.id.startsWith("default:"));
111
111
  if (builtIn.length === 0 || made.length === 0) return /* @__PURE__ */ jsx(Items, { ...props });
112
- return /* @__PURE__ */ jsxs(Fragment, { children: [
112
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
113
113
  /* @__PURE__ */ jsx("h3", {
114
114
  className: "dd-list-group",
115
115
  children: messages.builtIn
@@ -2,7 +2,7 @@ import { WidgetBuilder } from "./builder/WidgetBuilder.mjs";
2
2
  import { useDashboards } from "./context.mjs";
3
3
  import { useState } from "react";
4
4
  import { freeSpot } from "derive-dashboards/core";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  // src/Editing.tsx
7
7
  /** Edit for those who may change the dashboard; while editing, + Add widget instead. */
8
8
  function EditButton({ edit, canEdit, waiting, onAdd }) {
@@ -35,7 +35,7 @@ function StepButtons(props) {
35
35
  onClick: props.busy ? void 0 : run,
36
36
  children: arrow
37
37
  });
38
- return /* @__PURE__ */ jsxs(Fragment, { children: [step("up", messages.moveUp(props.title), props.onUp, "↑"), step("down", messages.moveDown(props.title), props.onDown, "↓")] });
38
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [step("up", messages.moveUp(props.title), props.onUp, "↑"), step("down", messages.moveDown(props.title), props.onDown, "↓")] });
39
39
  }
40
40
  /**
41
41
  * A tile's own Edit and Remove while the dashboard is a draft, named for the tile; at phone
@@ -43,7 +43,7 @@ function StepButtons(props) {
43
43
  */
44
44
  function TileActions(props) {
45
45
  const { messages } = useDashboards();
46
- return /* @__PURE__ */ jsxs(Fragment, { children: [
46
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
47
47
  /* @__PURE__ */ jsx(StepButtons, { ...props }),
48
48
  /* @__PURE__ */ jsx("button", {
49
49
  type: "button",
@@ -3,7 +3,7 @@ import { LIST_KEY } from "./DashboardList.mjs";
3
3
  import { EditButton } from "./Editing.mjs";
4
4
  import { useEffect, useRef, useState } from "react";
5
5
  import { useSWRConfig } from "swr";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/Header.tsx
8
8
  /** The title: words to read, or while editing a field to rename the dashboard in place. */
9
9
  function Title({ doc, edit, isNew }) {
@@ -65,7 +65,7 @@ function ShareButton({ link }) {
65
65
  setSaid(url);
66
66
  }
67
67
  };
68
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
68
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
69
69
  type: "button",
70
70
  className: "dd-button dd-quiet",
71
71
  onClick: () => void share(),
@@ -6,7 +6,7 @@ import { Panel } from "./Panel.mjs";
6
6
  import { ReadFailed } from "./ReadFailed.mjs";
7
7
  import { useState } from "react";
8
8
  import { useSWRConfig } from "swr";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  import useSWRInfinite from "swr/infinite";
11
11
  // src/History.tsx
12
12
  /** One version in the timeline: when, by whom (for editors, when the host names people), what it restored. */
@@ -16,7 +16,7 @@ function Entry(props) {
16
16
  const name = entry.author === void 0 ? void 0 : authorName?.(entry.author);
17
17
  const agent = entry.author?.kind === "agent";
18
18
  const when = formatInstant(entry.createdAt, locale);
19
- const body = /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ const body = /* @__PURE__ */ jsxs(Fragment$1, { children: [
20
20
  /* @__PURE__ */ jsx("strong", { children: messages.version(entry.version) }),
21
21
  props.current ? /* @__PURE__ */ jsx("em", { children: messages.current }) : null,
22
22
  /* @__PURE__ */ jsx("span", { children: [when, name].filter((part) => part !== void 0).join(" · ") }),
@@ -157,7 +157,7 @@ function VersionActions(props) {
157
157
  onClick,
158
158
  children: label
159
159
  });
160
- return /* @__PURE__ */ jsxs(Fragment, { children: [
160
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
161
161
  asking ? /* @__PURE__ */ jsx(CancelRestore, {
162
162
  busy: actions.busy,
163
163
  onCancel: () => {
@@ -5,7 +5,7 @@ import { HistoryPanel, VersionBar } from "./History.mjs";
5
5
  import { PublishedNotice } from "./Notice.mjs";
6
6
  import { ReviewPanel } from "./ReviewPanel.mjs";
7
7
  import { useState } from "react";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  // src/Parts.tsx
10
10
  /** The notice after a publish; its Undo restores the version before as the next one. */
11
11
  function Published({ board, props }) {
@@ -45,7 +45,7 @@ function Published({ board, props }) {
45
45
  /** The bars over the canvas: the publish notice, the edit bar, an earlier version's bar. */
46
46
  function Bars({ board, props }) {
47
47
  const { edit, panels } = board;
48
- return /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
49
49
  /* @__PURE__ */ jsx(Published, {
50
50
  board,
51
51
  props
@@ -1,7 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  /**
3
- * What one row of a list shows, for a drill's Items and the list widget alike: a title, a meta
4
- * line, an optional lead (an avatar), badge and trailing value, and a chevron when it opens.
3
+ * Display values for list tiles and drill records.
5
4
  */
6
5
  export type RowContent = {
7
6
  title: string;
@@ -14,6 +13,5 @@ export type RowContent = {
14
13
  lead?: string | undefined;
15
14
  /** After the text: one number. */
16
15
  value?: string | undefined;
17
- /** The row opens something: a chevron says so. */
18
- opens?: boolean;
16
+ valueLabel?: string | undefined;
19
17
  };
@@ -1,55 +1,30 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  // src/RowBody.tsx
3
- /** The class names of one family of rows: `dd-item-*` (Items) or `dd-lines-*` (the list widget). */
4
- const CLASSES = {
5
- item: {
6
- lead: "dd-item-lead",
7
- text: "dd-item-text",
8
- title: "dd-item-title",
9
- meta: "dd-item-meta",
10
- value: "dd-item-value"
11
- },
12
- lines: {
13
- lead: "dd-lines-avatar",
14
- text: "dd-lines-text",
15
- title: "dd-lines-title",
16
- meta: "dd-lines-sub",
17
- value: "dd-lines-meta"
18
- }
19
- };
20
- /** One row's parts, the one markup every list of rows shares. */
21
- function RowBody({ row, family }) {
22
- const c = CLASSES[family];
3
+ /** A list tile can carry a leading avatar and a trailing measure beside its title. */
4
+ function RowBody({ row }) {
23
5
  return /* @__PURE__ */ jsxs(Fragment, { children: [
24
6
  row.lead === void 0 ? null : /* @__PURE__ */ jsx("span", {
25
- className: c.lead,
7
+ className: "dd-lines-avatar",
26
8
  "aria-hidden": "true",
27
9
  children: row.lead
28
10
  }),
29
11
  /* @__PURE__ */ jsxs("span", {
30
- className: c.text,
12
+ className: "dd-lines-text",
31
13
  children: [/* @__PURE__ */ jsx("strong", {
32
- className: c.title,
14
+ className: "dd-lines-title",
33
15
  children: row.title
34
- }), family === "item" && row.meta.length === 0 ? null : /* @__PURE__ */ jsx("span", {
35
- className: c.meta,
16
+ }), /* @__PURE__ */ jsx("span", {
17
+ className: "dd-lines-sub",
36
18
  children: row.meta.join(" · ")
37
19
  })]
38
20
  }),
39
- row.badge === void 0 ? null : /* @__PURE__ */ jsx("span", {
40
- className: "dd-item-badge",
41
- "data-tone": row.badge.tone ?? "neutral",
42
- children: row.badge.text
43
- }),
44
- row.value === void 0 ? null : /* @__PURE__ */ jsx("span", {
45
- className: c.value,
46
- children: row.value
47
- }),
48
- row.opens === true ? /* @__PURE__ */ jsx("span", {
49
- className: "dd-item-go",
50
- "aria-hidden": "true",
51
- children: "›"
52
- }) : null
21
+ row.value === void 0 ? null : /* @__PURE__ */ jsxs("span", {
22
+ className: "dd-lines-meta",
23
+ children: [row.valueLabel !== void 0 && /* @__PURE__ */ jsxs("span", {
24
+ className: "dd-sr-only",
25
+ children: [row.valueLabel, " "]
26
+ }), row.value]
27
+ })
53
28
  ] });
54
29
  }
55
30
  export { RowBody };
@@ -1,12 +1,12 @@
1
1
  import { useDashboards } from "./context.mjs";
2
2
  import { useTileDrill } from "./drill/host.mjs";
3
3
  import { ExportButton } from "./export/ExportButton.mjs";
4
- import { formatInstantAt } from "./format-time.mjs";
4
+ import { formatPeriod } from "./format-time.mjs";
5
5
  import { SeriesSlotsContext } from "./scope.mjs";
6
6
  import { seriesSlots } from "./series-slots.mjs";
7
7
  import { memo, useContext, useState } from "react";
8
8
  import { sharedDisplay } from "derive-dashboards/core";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  // src/Tile.tsx
11
11
  /** Refusals that last only until the dashboard is read again, never shown as errors. */
12
12
  const PASSING = /* @__PURE__ */ new Set(["VERSION_CONFLICT", "TILE_UNKNOWN"]);
@@ -71,7 +71,7 @@ function Notes({ result, controlLabels }) {
71
71
  const { messages } = useDashboards();
72
72
  if (result === void 0 || "error" in result) return null;
73
73
  const dropped = result.receipt.coverage.dropped.map((id) => controlLabels?.get(id) ?? id);
74
- return /* @__PURE__ */ jsxs(Fragment, { children: [
74
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
75
75
  dropped.length === 0 ? null : /* @__PURE__ */ jsx("p", {
76
76
  className: "dd-tile-note",
77
77
  children: messages.notFilteredBy(dropped)
@@ -104,10 +104,9 @@ function Span({ result, shared }) {
104
104
  const range = result.receipt.range;
105
105
  if (range === void 0 || shared !== void 0 && spanKey(result) === shared) return null;
106
106
  const zone = result.receipt.calendar.timezone;
107
- const day = (at) => formatInstantAt(at, "day", format.locale, zone);
108
107
  return /* @__PURE__ */ jsx("p", {
109
108
  className: "dd-tile-span",
110
- children: format.messages.drillRange(day(range.from), day(range.to))
109
+ children: formatPeriod(range, format, zone)
111
110
  });
112
111
  }
113
112
  /**
@@ -4,7 +4,7 @@ import { fieldOptions } from "./options.mjs";
4
4
  import { Chip } from "./Sections.mjs";
5
5
  import { ValuePicker } from "./Values.mjs";
6
6
  import { useState } from "react";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
8
  // src/builder/FilterEditor.tsx
9
9
  /** The operators a field's type has, in the order the editor offers them. */
10
10
  const OPS = {
@@ -94,7 +94,7 @@ function Inputs(props) {
94
94
  className: "dd-range-row",
95
95
  children: box(0, "number")
96
96
  });
97
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
97
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
98
98
  className: "dd-range-row",
99
99
  children: [
100
100
  box(0, "number"),
@@ -1,6 +1,6 @@
1
1
  import { useDashboards } from "../context.mjs";
2
2
  import { useEffect, useId, useRef, useState } from "react";
3
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
4
4
  // src/builder/Picker.tsx
5
5
  /** The options whose group and label hold every word typed, in their groups' order. */
6
6
  function matching(options, search) {
@@ -13,8 +13,8 @@ function matching(options, search) {
13
13
  /** A label with the typed text in bold, so the match is easy to see. */
14
14
  function Marked({ label, search }) {
15
15
  const at = search === "" ? -1 : label.toLowerCase().indexOf(search.toLowerCase());
16
- if (at === -1) return /* @__PURE__ */ jsx(Fragment, { children: label });
17
- return /* @__PURE__ */ jsxs(Fragment, { children: [
16
+ if (at === -1) return /* @__PURE__ */ jsx(Fragment$1, { children: label });
17
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
18
18
  label.slice(0, at),
19
19
  /* @__PURE__ */ jsx("b", { children: label.slice(at, at + search.length) }),
20
20
  label.slice(at + search.length)
@@ -1,7 +1,7 @@
1
1
  import { useDashboards } from "../context.mjs";
2
2
  import { DAY_ONLY, addDays, fromIsoDay, isoDay } from "../filters/days.mjs";
3
3
  import { useState } from "react";
4
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
5
  // src/builder/RangeEditor.tsx
6
6
  const UNITS = [
7
7
  "day",
@@ -55,7 +55,7 @@ function Rolling(props) {
55
55
  ...change
56
56
  });
57
57
  };
58
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
58
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
59
59
  className: "dd-custom-row",
60
60
  children: [
61
61
  messages.last,
@@ -100,7 +100,7 @@ function Between(props) {
100
100
  to: isoDay(addDays(fromIsoDay(next.last), 1))
101
101
  });
102
102
  };
103
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
103
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
104
104
  className: "dd-custom-dates",
105
105
  children: [
106
106
  /* @__PURE__ */ jsx("span", {