@malloy-publisher/sdk 0.9.10 → 0.9.11

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 (257) hide show
  1. package/dist/RenderedResult-BlNoIiSi.cjs.js +153 -0
  2. package/dist/{RenderedResult-Dp1Qdajz.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
  3. package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
  4. package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
  5. package/dist/builder/index.cjs.js +78 -130
  6. package/dist/builder/index.es.js +7493 -6769
  7. package/dist/builder-entry.d.ts +3 -0
  8. package/dist/client/api.d.ts +26 -22
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +1 -1
  11. package/dist/components/AppDialog.d.ts +9 -1
  12. package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
  13. package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
  14. package/dist/components/Dashboard/DashboardView.d.ts +22 -34
  15. package/dist/components/Dashboard/TileCard.d.ts +10 -3
  16. package/dist/components/Dashboard/useStuck.d.ts +15 -7
  17. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
  18. package/dist/components/Package/PackageProblems.d.ts +14 -0
  19. package/dist/components/RemoveBadge.d.ts +40 -0
  20. package/dist/components/Report/Report.d.ts +13 -4
  21. package/dist/components/Report/ReportPage.d.ts +60 -0
  22. package/dist/components/Report/layoutRules.d.ts +32 -0
  23. package/dist/components/Report/reportQuery.d.ts +30 -0
  24. package/dist/components/Report/telemetry.d.ts +0 -2
  25. package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
  26. package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
  27. package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
  28. package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
  29. package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
  30. package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
  31. package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
  32. package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
  33. package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
  34. package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -8
  35. package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
  36. package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
  37. package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
  38. package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
  39. package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
  40. package/dist/components/ReportBuilder/TileMenu.d.ts +12 -9
  41. package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
  42. package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
  43. package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
  44. package/dist/components/ReportBuilder/catalog.d.ts +2 -4
  45. package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
  46. package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
  47. package/dist/components/ReportBuilder/preview.d.ts +17 -2
  48. package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
  49. package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
  50. package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
  51. package/dist/components/ReportBuilder/sortable.d.ts +4 -3
  52. package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
  53. package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
  54. package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
  55. package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
  56. package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
  57. package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
  58. package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
  59. package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
  60. package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
  61. package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
  62. package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
  63. package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
  64. package/dist/components/ServerProvider.d.ts +9 -0
  65. package/dist/components/controlTokens.d.ts +45 -0
  66. package/dist/components/drill/markDrillableCells.d.ts +1 -1
  67. package/dist/components/given/FilterButton.d.ts +35 -0
  68. package/dist/components/given/GivensPanel.d.ts +2 -1
  69. package/dist/components/given/filterEditing.d.ts +54 -0
  70. package/dist/components/given/filterSummary.d.ts +9 -0
  71. package/dist/components/given/paramCodec.d.ts +11 -0
  72. package/dist/components/given/required.d.ts +25 -0
  73. package/dist/components/index.d.ts +3 -0
  74. package/dist/components/legacy/index.d.ts +1 -1
  75. package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
  76. package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
  77. package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
  78. package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
  79. package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
  80. package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
  81. package/dist/components/styles.d.ts +0 -2
  82. package/dist/hooks/useQueryResult.d.ts +7 -0
  83. package/dist/index.cjs.js +16 -19
  84. package/dist/index.es.js +8324 -7769
  85. package/dist/theme/ThemeContext.d.ts +8 -1
  86. package/dist/theme/classes.d.ts +49 -0
  87. package/dist/theme/index.d.ts +2 -0
  88. package/dist/theme/types.d.ts +7 -0
  89. package/dist/theme/ui.d.ts +75 -0
  90. package/dist/{useCompiledDocument-BMPDvdFx.es.js → useCompiledDocument-7j5cBjQd.es.js} +8669 -7851
  91. package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
  92. package/package.json +2 -2
  93. package/src/builder-entry.ts +9 -0
  94. package/src/components/AppDialog.tsx +23 -0
  95. package/src/components/Dashboard/DashboardGrid.tsx +39 -17
  96. package/src/components/Dashboard/DashboardTile.tsx +19 -2
  97. package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
  98. package/src/components/Dashboard/DashboardView.tsx +137 -155
  99. package/src/components/Dashboard/RowsDialog.tsx +1 -2
  100. package/src/components/Dashboard/TileCard.tsx +28 -10
  101. package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
  102. package/src/components/Dashboard/useStuck.ts +28 -17
  103. package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
  104. package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
  105. package/src/components/Package/NewDocumentDialog.tsx +383 -119
  106. package/src/components/Package/Package.artifacts.spec.tsx +1 -1
  107. package/src/components/Package/Package.create.spec.tsx +7 -6
  108. package/src/components/Package/Package.tsx +10 -7
  109. package/src/components/Package/PackageProblems.spec.tsx +41 -0
  110. package/src/components/Package/PackageProblems.tsx +95 -0
  111. package/src/components/Prose.tsx +12 -7
  112. package/src/components/RemoveBadge.tsx +94 -0
  113. package/src/components/RenderedResult/RenderedResult.tsx +5 -9
  114. package/src/components/RenderedResult/ResultPanel.tsx +59 -3
  115. package/src/components/Report/Report.spec.tsx +50 -32
  116. package/src/components/Report/Report.telemetry.spec.tsx +0 -45
  117. package/src/components/Report/Report.tsx +45 -77
  118. package/src/components/Report/ReportPage.tsx +168 -0
  119. package/src/components/Report/layoutRules.spec.ts +35 -0
  120. package/src/components/Report/layoutRules.ts +55 -0
  121. package/src/components/Report/reportQuery.ts +53 -0
  122. package/src/components/Report/telemetry.ts +0 -2
  123. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
  124. package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
  125. package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
  126. package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -39
  127. package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
  128. package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
  129. package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
  130. package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
  131. package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
  132. package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
  133. package/src/components/ReportBuilder/FilterStrip.tsx +130 -151
  134. package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
  135. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
  136. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
  137. package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
  138. package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -15
  139. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
  140. package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
  141. package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
  142. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +37 -31
  143. package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
  144. package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
  145. package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
  146. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
  147. package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
  148. package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
  149. package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
  150. package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
  151. package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
  152. package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
  153. package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
  154. package/src/components/ReportBuilder/TileFrame.tsx +212 -75
  155. package/src/components/ReportBuilder/TileMenu.tsx +241 -140
  156. package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
  157. package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
  158. package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
  159. package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
  160. package/src/components/ReportBuilder/builderControls.ts +164 -0
  161. package/src/components/ReportBuilder/builderReport.ts +1 -2
  162. package/src/components/ReportBuilder/catalog.ts +10 -26
  163. package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
  164. package/src/components/ReportBuilder/localGiven.ts +56 -0
  165. package/src/components/ReportBuilder/preview.spec.ts +125 -5
  166. package/src/components/ReportBuilder/preview.ts +60 -44
  167. package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
  168. package/src/components/ReportBuilder/readDocument.ts +14 -11
  169. package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
  170. package/src/components/ReportBuilder/readForEditor.ts +4 -26
  171. package/src/components/ReportBuilder/reportTag.ts +28 -7
  172. package/src/components/ReportBuilder/sortable.tsx +15 -7
  173. package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
  174. package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
  175. package/src/components/ReportBuilder/testing/inline.ts +25 -5
  176. package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
  177. package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
  178. package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
  179. package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
  180. package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
  181. package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
  182. package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
  183. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
  184. package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
  185. package/src/components/ReportBuilder/useExitGuard.ts +16 -0
  186. package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
  187. package/src/components/ReportBuilder/useFilterForm.ts +5 -1
  188. package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
  189. package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
  190. package/src/components/ReportBuilder/useReportDraft.ts +292 -0
  191. package/src/components/ReportBuilder/useReportEditor.ts +3 -12
  192. package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
  193. package/src/components/ReportBuilder/useTileEditing.ts +43 -12
  194. package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
  195. package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
  196. package/src/components/ReportBuilder/widthLabel.ts +26 -0
  197. package/src/components/ServerProvider.tsx +11 -0
  198. package/src/components/controlTokens.ts +47 -0
  199. package/src/components/drill/markDrillableCells.ts +2 -1
  200. package/src/components/given/FilterButton.spec.tsx +143 -0
  201. package/src/components/given/FilterButton.tsx +478 -0
  202. package/src/components/given/GivenInput.spec.tsx +47 -0
  203. package/src/components/given/GivenInput.tsx +20 -2
  204. package/src/components/given/GivensPanel.spec.tsx +11 -3
  205. package/src/components/given/GivensPanel.tsx +45 -44
  206. package/src/components/given/filterEditing.ts +60 -0
  207. package/src/components/given/filterSummary.spec.ts +108 -0
  208. package/src/components/given/filterSummary.ts +109 -0
  209. package/src/components/given/paramCodec.ts +1 -1
  210. package/src/components/given/required.spec.ts +60 -0
  211. package/src/components/given/required.ts +78 -0
  212. package/src/components/index.ts +9 -0
  213. package/src/components/legacy/Dashboard.spec.tsx +3 -1
  214. package/src/components/legacy/index.ts +1 -1
  215. package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
  216. package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
  217. package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
  218. package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
  219. package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
  220. package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
  221. package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
  222. package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
  223. package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
  224. package/src/components/legacy/malloynb/cellKind.ts +24 -0
  225. package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
  226. package/src/components/styles.ts +0 -18
  227. package/src/hooks/useGivensState.ts +7 -3
  228. package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
  229. package/src/hooks/useQueryResult.ts +26 -1
  230. package/src/theme/ThemeContext.tsx +21 -1
  231. package/src/theme/classes.ts +52 -0
  232. package/src/theme/index.ts +8 -0
  233. package/src/theme/resolveTheme.ts +3 -0
  234. package/src/theme/types.ts +7 -0
  235. package/src/theme/ui.spec.tsx +91 -0
  236. package/src/theme/ui.ts +115 -0
  237. package/dist/RenderedResult-BcgYjkZ0.cjs.js +0 -153
  238. package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
  239. package/dist/components/Notebook/cellKind.d.ts +0 -20
  240. package/dist/components/Report/LinearReport.d.ts +0 -18
  241. package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
  242. package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
  243. package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
  244. package/dist/useCompiledDocument-UY28ITET.cjs.js +0 -141
  245. package/src/components/Notebook/cellKind.spec.ts +0 -199
  246. package/src/components/Notebook/cellKind.ts +0 -74
  247. package/src/components/Report/LinearReport.tsx +0 -71
  248. package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
  249. package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
  250. package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
  251. package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
  252. package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
  253. package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
  254. package/src/components/legacy/Notebook.served.spec.tsx +0 -183
  255. /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
  256. /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
  257. /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
@@ -1,8 +1,8 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { Alert, Box, Stack, Typography } from "@mui/material";
5
- import { useCallback, useMemo, useState, type ReactNode } from "react";
4
+ import { Alert } from "@mui/material";
5
+ import { useCallback, useMemo, useState } from "react";
6
6
  import type { DashboardManifest } from "../../client";
7
7
  import type { HostGivenValue } from "../../hooks/givenValue";
8
8
  import { useDocumentControls } from "../../hooks/useDocumentControls";
@@ -15,34 +15,31 @@ import {
15
15
  } from "../drill";
16
16
  import { GivensPanel, type GivensLayout } from "../given";
17
17
  import { givensToRequest, withHostGivens } from "../given/paramCodec";
18
- import { Prose } from "../Prose";
19
- import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
20
- import { usePublisherTheme } from "../../theme/ThemeContext";
21
- import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
22
18
  import {
23
- DashboardGrid,
24
- BARE_DESCRIPTION_MARGIN_PX,
25
- DEFAULT_COLUMNS,
26
- GRID_GAP_PX,
27
- NOTEBOOK_GAP_PX,
28
- } from "./DashboardGrid";
19
+ missingRequiredGivens,
20
+ requiredPrompt,
21
+ waitingOn,
22
+ waitingText,
23
+ } from "../given/required";
24
+ import { Prose, type ProseLinkContext } from "../Prose";
25
+ import type { NavigationClick } from "../click_helper";
26
+ import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
27
+ import { DashboardGrid, GRID_GAP_PX, MIN_TILE_PX } from "./DashboardGrid";
29
28
  import { DashboardTile } from "./DashboardTile";
30
29
  import { RowsDialog, stepsOf, type RowsRequest } from "./RowsDialog";
31
30
  import { useReportEvents } from "../Report/telemetry";
32
- import { TileCard, type TileChrome } from "./TileCard";
31
+ import type { TileChrome } from "./TileCard";
33
32
  import { tileIgnoredFilterLabels } from "./TileFilterTag";
34
- import { useStuck } from "./useStuck";
35
-
36
- /** Narrowest a tile that sets no `colspan` is allowed to render. */
37
- const MIN_TILE_PX = 240;
33
+ import { layoutRules } from "../Report/layoutRules";
34
+ import {
35
+ ReportHeader,
36
+ ReportPage,
37
+ StickyControls,
38
+ TextTileFrame,
39
+ } from "../Report/ReportPage";
38
40
 
39
- /**
40
- * The sticky control row's stacking level: above anything a tile raises
41
- * inside itself as it scrolls under (a result's floating buttons sit at 1–2),
42
- * and below MUI's app bar, popovers and dialogs. Shared so the builder's
43
- * control row sits at the same level as the reader's.
44
- */
45
- export const STICKY_CONTROLS_Z = 4;
41
+ /** Re-exported for hosts that import it from here; defined with the page parts. */
42
+ export { STICKY_CONTROLS_Z } from "../Report/ReportPage";
46
43
 
47
44
  export interface DashboardViewProps {
48
45
  /** The dashboard, or the tile layout a layout notebook carries. */
@@ -65,7 +62,11 @@ export interface DashboardViewProps {
65
62
  onNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
66
63
  height?: number;
67
64
  maxResultSize?: number;
68
- /** `none` renders tiles as a document, with no cards or title block. */
65
+ /**
66
+ * Ignored: kept so existing callers compile. A linear report and a grid
67
+ * draw the same header, cards and controls, and differ only in how tiles
68
+ * are arranged, which the manifest says.
69
+ */
69
70
  chrome?: TileChrome;
70
71
  /**
71
72
  * How the control row is drawn: `bar` for a dashboard, `panel` for a
@@ -82,6 +83,19 @@ export interface DashboardViewProps {
82
83
  runModelPath?: string;
83
84
  /** Givens the host sets itself: no control is shown for them. */
84
85
  hiddenGivens?: readonly string[];
86
+ /**
87
+ * Filters each tile reads through values the host writes into its query
88
+ * text rather than sending them as givens: a report held as text whose
89
+ * own `given:` the host resolves to literals before compiling. Keyed by
90
+ * the manifest's `tile.query`. Counted as read, so the tile is not marked
91
+ * as ignoring that filter, and never sent: the server does not know them.
92
+ */
93
+ literalReads?: Readonly<Record<string, readonly string[]>>;
94
+ /**
95
+ * An ordinary link in the report's prose (its description and text tiles),
96
+ * for a host with its own router. Omitted, links are plain anchors.
97
+ */
98
+ onLinkNavigate?: (to: string, event?: NavigationClick) => void;
85
99
  }
86
100
 
87
101
  /**
@@ -101,12 +115,35 @@ export function DashboardView({
101
115
  onNavigate,
102
116
  height,
103
117
  maxResultSize,
104
- chrome = "card",
105
118
  controlsLayout = "bar",
106
119
  preamble,
107
120
  runModelPath,
108
121
  hiddenGivens,
122
+ literalReads,
123
+ onLinkNavigate,
109
124
  }: DashboardViewProps) {
125
+ // Where a relative link in the report's prose resolves from, and how the
126
+ // host navigates to it. Only a host with a router gets its links resolved:
127
+ // without one they stay plain anchors, since this view cannot know the
128
+ // host's routes (a version segment, a different prefix).
129
+ const links = useMemo<ProseLinkContext | undefined>(
130
+ () =>
131
+ onLinkNavigate
132
+ ? {
133
+ environmentName,
134
+ packageName,
135
+ sourcePath: manifest.path ?? documentName,
136
+ onNavigate: onLinkNavigate,
137
+ }
138
+ : undefined,
139
+ [
140
+ environmentName,
141
+ packageName,
142
+ manifest.path,
143
+ documentName,
144
+ onLinkNavigate,
145
+ ],
146
+ );
110
147
  const specs = useMemo(
111
148
  () =>
112
149
  (manifest.givens ?? []).filter(
@@ -213,39 +250,53 @@ export function DashboardView({
213
250
  [drill],
214
251
  );
215
252
 
253
+ // The layout decides the arrangement only, as it does in the builder.
254
+ const { columns, layout } = layoutRules(
255
+ manifest.layout,
256
+ manifest.dashboardColumns,
257
+ );
258
+
259
+ // Required filters with no value yet: the tiles that read one wait, and the
260
+ // page asks for them, rather than every tile failing with the compiler's
261
+ // "has no value and no default".
262
+ const missing = useMemo(
263
+ () => missingRequiredGivens(specs, applied, givens),
264
+ [specs, applied, givens],
265
+ );
266
+
216
267
  // Reachable on the in-process load path only: production aborts the package
217
268
  // on the first compile error, so an uncompilable file answers 424 instead.
218
269
  if (manifest.error) {
219
270
  return (
220
- <Stack spacing={2}>
221
- <DashboardHeader manifest={manifest} chrome={chrome} />
271
+ <ReportPage
272
+ layout={layout}
273
+ header={<DashboardHeader manifest={manifest} links={links} />}
274
+ >
222
275
  <Alert severity="error">{manifest.error}</Alert>
223
- </Stack>
276
+ </ReportPage>
224
277
  );
225
278
  }
226
279
 
227
280
  const modelPath = runModelPath ?? manifest.path;
228
281
  const tiles = manifest.tiles ?? [];
229
- const columns = manifest.dashboardColumns ?? DEFAULT_COLUMNS;
230
282
 
231
283
  return (
232
- <Stack spacing={2}>
233
- {chrome === "card" && (
234
- <DashboardHeader manifest={manifest} chrome={chrome} />
284
+ <ReportPage
285
+ layout={layout}
286
+ header={<DashboardHeader manifest={manifest} links={links} />}
287
+ // Only when there are controls: GivensPanel draws nothing without
288
+ // them, and an empty bar would still cost the page a gap.
289
+ controls={
290
+ specs.length > 0 ? (
291
+ <StickyControls>
292
+ <GivensPanel {...controls.panel} layout={controlsLayout} />
293
+ </StickyControls>
294
+ ) : undefined
295
+ }
296
+ >
297
+ {missing.length > 0 && (
298
+ <Alert severity="info">{requiredPrompt(missing)}</Alert>
235
299
  )}
236
-
237
- {/* Sticky so the controls stay in reach while the tiles scroll under,
238
- in a grid only: a linear report's controls are a full panel, and
239
- pinned they would take a third of a laptop screen from the prose
240
- they sit above. Only when there are controls: GivensPanel draws
241
- nothing without them, and an empty box would still cost the Stack
242
- a gap. */}
243
- {specs.length > 0 && (
244
- <StickyControls sticky={chrome === "card"}>
245
- <GivensPanel {...controls.panel} layout={controlsLayout} />
246
- </StickyControls>
247
- )}
248
-
249
300
  {modelPath === undefined ? (
250
301
  <Alert severity="error">
251
302
  This dashboard has no model path, so there is nothing to run.
@@ -258,7 +309,7 @@ export function DashboardView({
258
309
  tiles={tiles}
259
310
  columns={columns}
260
311
  minTilePx={MIN_TILE_PX}
261
- rowGapPx={chrome === "none" ? NOTEBOOK_GAP_PX : GRID_GAP_PX}
312
+ rowGapPx={GRID_GAP_PX}
262
313
  // Position too, not the expression alone: `tiles=[…]` can repeat
263
314
  // one, which is a typo rather than a request for two identical
264
315
  // panels, and keying on the expression made the duplicate warn
@@ -269,7 +320,9 @@ export function DashboardView({
269
320
  renderTile={(tile, index) =>
270
321
  // An absent `kind` is a query tile, as it was before text tiles.
271
322
  tile.kind === "text" || tile.query === undefined ? (
272
- <TextTile markdown={tile.markdown ?? ""} chrome={chrome} />
323
+ // Prose, never a card, in either layout: a text tile is
324
+ // part of the page, not a result.
325
+ <TextTile markdown={tile.markdown ?? ""} links={links} />
273
326
  ) : (
274
327
  <DashboardTile
275
328
  index={index}
@@ -288,14 +341,25 @@ export function DashboardView({
288
341
  height={height ?? TILE_MAX_HEIGHT}
289
342
  maxResultSize={maxResultSize}
290
343
  drill={drillFor(tile.query)}
291
- chrome={chrome}
292
344
  ignoredFilters={tileIgnoredFilterLabels(
293
- tile.givenNames,
345
+ tile.givenNames &&
346
+ (tile.query && literalReads?.[tile.query]
347
+ ? [
348
+ ...tile.givenNames,
349
+ ...literalReads[tile.query]!,
350
+ ]
351
+ : tile.givenNames),
294
352
  specs,
295
353
  )}
296
354
  {...(preamble !== undefined
297
355
  ? { preamble, restricted: tile.restricted }
298
356
  : {})}
357
+ {...(() => {
358
+ const waiting = waitingOn(missing, tile.givenNames);
359
+ return waiting.length > 0
360
+ ? { waitingFor: waitingText(waiting) }
361
+ : {};
362
+ })()}
299
363
  />
300
364
  )
301
365
  }
@@ -329,133 +393,51 @@ export function DashboardView({
329
393
  }}
330
394
  />
331
395
  )}
332
- </Stack>
396
+ </ReportPage>
333
397
  );
334
398
  }
335
399
 
336
400
  /** A text tile: its markdown and nothing else, no heading. */
337
401
  function TextTile({
338
402
  markdown,
339
- chrome,
403
+ links,
340
404
  }: {
341
405
  markdown: string;
342
- chrome: TileChrome;
406
+ links: ProseLinkContext | undefined;
343
407
  }) {
344
408
  return (
345
- <TileCard chrome={chrome} kind="text">
346
- <Prose variant="document">{markdown}</Prose>
347
- </TileCard>
409
+ <TextTileFrame>
410
+ <Prose variant="document" links={links}>
411
+ {markdown}
412
+ </Prose>
413
+ </TextTileFrame>
348
414
  );
349
415
  }
350
416
 
351
417
  /**
352
- * The dashboard's prose header: its title, and the description as MARKDOWN
353
- * (Malloy carries a `##"` block through with its newlines intact).
418
+ * The report's header as the reader draws it: the shared {@link ReportHeader}
419
+ * with the title, and the description as markdown prose (Malloy carries a
420
+ * `##"` block through with its newlines intact) in a text tile's frame.
354
421
  */
355
422
  function DashboardHeader({
356
423
  manifest,
357
- chrome,
424
+ links,
358
425
  }: {
359
426
  manifest: DashboardManifest;
360
- chrome: TileChrome;
427
+ links: ProseLinkContext | undefined;
361
428
  }) {
362
429
  return (
363
- <DashboardProse
364
- // The description follows the text-tile rule: drawn in the same chrome
365
- // the document's text tiles take, so a dashboard boxes it as it boxes
366
- // a text tile, and a notebook (which passes `none`) leaves it bare.
367
- chrome={chrome}
430
+ <ReportHeader
368
431
  title={manifest.title ?? manifest.name}
369
- {...(manifest.description
370
- ? { description: manifest.description }
371
- : {})}
432
+ description={
433
+ manifest.description ? (
434
+ <TextTileFrame>
435
+ <Prose variant="document" links={links}>
436
+ {manifest.description}
437
+ </Prose>
438
+ </TextTileFrame>
439
+ ) : undefined
440
+ }
372
441
  />
373
442
  );
374
443
  }
375
-
376
- /**
377
- * The prose header over just the two fields it needs, so the BUILDER can draw
378
- * the same header over a `DashboardDocument`, which is not a manifest.
379
- *
380
- * The description is drawn as a text tile is, in the document's own tile
381
- * chrome: the same box and the same type as the markdown between the tiles,
382
- * so the page's prose reads as one kind of thing wherever it sits.
383
- */
384
- export function DashboardProse({
385
- title,
386
- description,
387
- chrome = "card",
388
- }: {
389
- title: string;
390
- description?: string;
391
- /** The chrome the document's tiles take, which the description matches. */
392
- chrome?: TileChrome;
393
- }) {
394
- return (
395
- <Stack sx={{ gap: 2 }}>
396
- {/* No explicit weight: the host theme's h5 weight applies. */}
397
- <Typography variant="h5">{title}</Typography>
398
- {description && (
399
- <Box
400
- sx={
401
- chrome === "none"
402
- ? { my: `${BARE_DESCRIPTION_MARGIN_PX}px` }
403
- : undefined
404
- }
405
- >
406
- <TextTile markdown={description} chrome={chrome} />
407
- </Box>
408
- )}
409
- </Stack>
410
- );
411
- }
412
-
413
- /**
414
- * A control row that pins to the top of the scroller and, while pinned, draws
415
- * a hairline under itself, so tiles scrolling beneath read as passing under a
416
- * bar rather than being cut off by nothing. Shared by the reader and the
417
- * builder so both pin the same way.
418
- */
419
- export function StickyControls({
420
- sticky = true,
421
- children,
422
- }: {
423
- sticky?: boolean;
424
- children: ReactNode;
425
- }) {
426
- const { theme } = usePublisherTheme();
427
- const { sentinelRef, stuck } = useStuck();
428
- if (!sticky) return <Box>{children}</Box>;
429
- const edge = theme.cardBorder.replace(/^1px solid /, "");
430
- return (
431
- <>
432
- {/* The sentinel the pin is detected from; it costs the parent Stack
433
- no gap, since it is a zero-height sibling and Stack gaps are on
434
- the bar's own margin. */}
435
- <Box
436
- ref={sentinelRef}
437
- aria-hidden
438
- sx={{ height: 0, m: "0 !important" }}
439
- />
440
- <Box
441
- data-stuck={stuck || undefined}
442
- sx={{
443
- position: "sticky",
444
- top: 0,
445
- zIndex: STICKY_CONTROLS_Z,
446
- bgcolor: "background.default",
447
- // Room under the bar for the edge, so the line never sits on
448
- // the controls themselves.
449
- pb: 1,
450
- // A shadow rather than a border: drawing the edge must not
451
- // change the bar's height, or the page jumps as it pins.
452
- boxShadow: stuck ? `0 1px 0 ${edge}` : "none",
453
- transition: `box-shadow ${MOTION_FAST}`,
454
- ...reducedMotionSx,
455
- }}
456
- >
457
- {children}
458
- </Box>
459
- </>
460
- );
461
- }
@@ -18,7 +18,6 @@ import { malloyLiteral } from "../../utils/malloyLiteral";
18
18
  import { isIdentifier, tileSteps } from "../../utils/malloyText";
19
19
  import { usePublisherTheme } from "../../theme/ThemeContext";
20
20
  import { ResultPanel } from "../RenderedResult/ResultPanel";
21
- import { MONO_FONT_FAMILY } from "../styles";
22
21
  import { now } from "../../utils/clock";
23
22
 
24
23
  /**
@@ -171,7 +170,7 @@ export function RowsDialog({
171
170
  sx={{
172
171
  mr: "auto",
173
172
  color: theme.tileTitle,
174
- fontFamily: MONO_FONT_FAMILY,
173
+ fontFamily: theme.ui.font.mono,
175
174
  overflow: "hidden",
176
175
  textOverflow: "ellipsis",
177
176
  whiteSpace: "nowrap",
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
+ import { reportClasses } from "../../theme/classes";
4
5
  import {
5
6
  Box,
6
7
  Paper,
@@ -34,8 +35,10 @@ export const TILE_MIN_HEIGHT = { query: 120, text: 72 } as const;
34
35
  * a different card. Both surfaces moved together when the edge was darkened;
35
36
  * either one left behind is a dashboard whose tiles are outlined two ways.
36
37
  *
37
- * Radius stays on the host's
38
- * `shape.borderRadius`, which the renderer card is pointed at too. The
38
+ * Radius is the report surfaces' tile radius ({@link ui.radius.tile}), which the
39
+ * renderer card is pointed at too, rather than the host's `shape.borderRadius`:
40
+ * a host's control radius is not a card radius, and taking it made tiles as
41
+ * round as buttons. The
39
42
  * background is `theme.tile`, the value the renderer card paints — left unset,
40
43
  * on a theme whose page is also white the composite tiles lost the tint that
41
44
  * separates a card from the page while the single-query form kept it.
@@ -70,16 +73,20 @@ export function TileCard({
70
73
  children: ReactNode;
71
74
  }) {
72
75
  const { theme } = usePublisherTheme();
76
+ const ui = theme.ui;
73
77
  const bare = borderless || chrome === "none";
74
78
  return (
75
79
  <Paper
76
80
  ref={cardRef}
81
+ className={reportClasses.tile}
77
82
  elevation={0}
78
83
  data-chrome={chrome}
84
+ // What it holds, for a host waiting on the query tiles to draw.
85
+ data-tile-kind={kind}
79
86
  sx={[
80
87
  {
81
88
  border: bare ? "none" : theme.cardBorder,
82
- borderRadius: bare ? 0 : 1,
89
+ borderRadius: bare ? 0 : ui.radius.tile,
83
90
  background: bare ? "none" : theme.tile,
84
91
  overflow: "hidden",
85
92
  // A column so a tile's result can take the room under its heading.
@@ -102,6 +109,12 @@ export function TileCard({
102
109
  );
103
110
  }
104
111
 
112
+ /**
113
+ * The class on a tile heading's root, so a surface that draws controls over
114
+ * the heading (the builder's tile menu) can leave room for them.
115
+ */
116
+ export const TILE_HEADING_CLASS = reportClasses.tileHeading;
117
+
105
118
  /** The heading's text as nodes, for a surface that makes it editable in place. */
106
119
  export interface TileHeadingSlots {
107
120
  title: ReactNode;
@@ -120,7 +133,7 @@ export function TileHeading({
120
133
  action,
121
134
  quiet = false,
122
135
  }: {
123
- /** A small caption instead of a heading, for a tile with no card around it. */
136
+ /** A tighter gap under the heading, for a tile with no card around it. */
124
137
  quiet?: boolean;
125
138
  title: ReactNode;
126
139
  subtitle?: ReactNode;
@@ -130,8 +143,10 @@ export function TileHeading({
130
143
  action?: ReactNode;
131
144
  }) {
132
145
  const { theme } = usePublisherTheme();
146
+ const ui = theme.ui;
133
147
  return (
134
148
  <Box
149
+ className={TILE_HEADING_CLASS}
135
150
  sx={{
136
151
  pb: quiet ? 0.5 : 1.5,
137
152
  display: "flex",
@@ -140,12 +155,13 @@ export function TileHeading({
140
155
  }}
141
156
  >
142
157
  <Box sx={{ minWidth: 0, flex: 1 }}>
158
+ {/* One title style in both layouts: a linear report's tile titles
159
+ were 12px captions, smaller than the prose around them. */}
143
160
  <Typography
144
- variant={quiet ? "caption" : "subtitle2"}
161
+ component="div"
145
162
  sx={{
146
- fontWeight: quiet ? 400 : 500,
147
- display: quiet ? "block" : undefined,
148
- opacity: quiet ? 0.8 : undefined,
163
+ ...ui.type.tileTitle,
164
+ display: "block",
149
165
  color: theme.tileTitle,
150
166
  fontFamily: theme.font.family,
151
167
  }}
@@ -155,12 +171,14 @@ export function TileHeading({
155
171
  </Typography>
156
172
  {subtitle !== undefined && (
157
173
  <Typography
158
- variant="caption"
174
+ component="div"
159
175
  sx={{
176
+ ...ui.type.caption,
160
177
  display: "block",
178
+ mt: "2px",
161
179
  color: theme.tileTitle,
162
180
  fontFamily: theme.font.family,
163
- opacity: 0.8,
181
+ opacity: 0.75,
164
182
  }}
165
183
  >
166
184
  {subtitle}
@@ -30,3 +30,27 @@ describe("defaultTileSpan", () => {
30
30
  expect(defaultTileSpan(1, 100, 240)).toBe(1);
31
31
  });
32
32
  });
33
+
34
+ describe("useDefaultTileSpan", () => {
35
+ it("is the reader's span for the measured box, so the builder draws an unset tile as the reader does", async () => {
36
+ const { renderHook } = await import("@testing-library/react");
37
+ const { useDefaultTileSpan } = await import("./DashboardGrid");
38
+ const box = document.createElement("div");
39
+ box.getBoundingClientRect = () => ({ width: 1200 }) as DOMRect;
40
+ const { result } = renderHook(() =>
41
+ useDefaultTileSpan({ current: box }, 12),
42
+ );
43
+ // Not 1: a one-column tile beside a colspan=6 one was a ~80px sliver.
44
+ expect(result.current).toBe(defaultTileSpan(12, 1200, 240));
45
+ expect(result.current).toBeGreaterThan(1);
46
+ });
47
+
48
+ it("is one column while nothing is measured", async () => {
49
+ const { renderHook } = await import("@testing-library/react");
50
+ const { useDefaultTileSpan } = await import("./DashboardGrid");
51
+ const { result } = renderHook(() =>
52
+ useDefaultTileSpan({ current: null }, 12),
53
+ );
54
+ expect(result.current).toBe(1);
55
+ });
56
+ });
@@ -4,35 +4,46 @@
4
4
  import { useCallback, useRef, useState } from "react";
5
5
 
6
6
  /**
7
- * Whether a `position: sticky` bar is currently pinned, so it can draw an edge
8
- * only while content scrolls under it. Unpinned, the bar sits in the flow and
9
- * an edge would be a stray line between it and the first tile.
7
+ * How far above the scroller's edge a pinned bar sits: one pixel, so the bar
8
+ * is clipped by exactly that pixel while pinned and whole while it is not,
9
+ * which is what {@link useStuck} observes.
10
+ */
11
+ export const STUCK_TOP_PX = -1;
12
+
13
+ /**
14
+ * Whether a `position: sticky` bar (pinned at `top: {@link STUCK_TOP_PX}px`)
15
+ * is currently pinned, so it can draw an edge only while content scrolls under
16
+ * it. Unpinned, the bar sits in the flow and an edge would be a stray line
17
+ * between it and the first tile.
10
18
  *
11
- * Watches a zero-height sentinel placed directly before the bar: once the
12
- * sentinel has scrolled out through the top, the bar is pinned. No explicit
13
- * root, so it works whichever ancestor scrolls — an observer with the implicit
19
+ * Observes the bar itself: pinned, its top pixel is clipped by the scroller,
20
+ * so less than all of it is visible. No sentinel element, which as a sibling
21
+ * in a `gap` layout cost the page a gap of its own above the bar. No explicit
22
+ * root, so it works whichever ancestor scrolls: an observer with the implicit
14
23
  * root counts clipping by every scrolling ancestor, not just the viewport.
15
24
  */
16
25
  export function useStuck(): {
17
- sentinelRef: (node: HTMLElement | null) => void;
26
+ stickyRef: (node: HTMLElement | null) => void;
18
27
  stuck: boolean;
19
28
  } {
20
29
  const [stuck, setStuck] = useState(false);
21
30
  const observer = useRef<IntersectionObserver | null>(null);
22
- const sentinelRef = useCallback((node: HTMLElement | null) => {
31
+ const stickyRef = useCallback((node: HTMLElement | null) => {
23
32
  observer.current?.disconnect();
24
33
  observer.current = null;
25
34
  if (!node || typeof IntersectionObserver === "undefined") return;
26
- observer.current = new IntersectionObserver(([entry]) => {
27
- if (!entry) return;
28
- // Out of view BELOW the fold is not pinned: only out through the top.
29
- setStuck(
30
- !entry.isIntersecting &&
35
+ observer.current = new IntersectionObserver(
36
+ ([entry]) => {
37
+ if (!entry) return;
38
+ // Partly hidden BELOW the fold is not pinned: only clipped at the top.
39
+ const atTop =
31
40
  entry.boundingClientRect.top <
32
- (entry.rootBounds?.height ?? window.innerHeight) / 2,
33
- );
34
- });
41
+ (entry.rootBounds?.height ?? window.innerHeight) / 2;
42
+ setStuck(entry.intersectionRatio < 1 && atTop);
43
+ },
44
+ { threshold: [1] },
45
+ );
35
46
  observer.current.observe(node);
36
47
  }, []);
37
- return { sentinelRef, stuck };
48
+ return { stickyRef, stuck };
38
49
  }
@@ -6,10 +6,17 @@ import { useMemo } from "react";
6
6
  import { useServer } from "../ServerProvider";
7
7
  import { canRetryRequest } from "./canRetry";
8
8
  import { exportedSources } from "./exportedSources";
9
+ import { chartOf, docOf } from "../ReportBuilder/viewAnnotations";
9
10
 
10
11
  export interface DocumentChoice {
11
12
  source: string;
12
13
  view: string;
14
+ /** The view's `#(doc)` line, which a picker shows as its title. */
15
+ description?: string;
16
+ /** The chart the view declares (`bar_chart`, …), for its icon. */
17
+ chart?: string;
18
+ /** The source's `#(doc)` line. */
19
+ sourceDescription?: string;
13
20
  }
14
21
 
15
22
  /**
@@ -83,9 +90,19 @@ export function useDocumentChoices({
83
90
  for (const source of result.data?.sources ?? []) {
84
91
  if (typeof source.name !== "string" || !exported.has(source.name))
85
92
  continue;
93
+ const sourceDescription = docOf(source.annotations);
86
94
  for (const view of source.views ?? [])
87
- if (typeof view.name === "string")
88
- pairs.push({ source: source.name, view: view.name });
95
+ if (typeof view.name === "string") {
96
+ const description = docOf(view.annotations);
97
+ const chart = chartOf(view.annotations);
98
+ pairs.push({
99
+ source: source.name,
100
+ view: view.name,
101
+ ...(description ? { description } : {}),
102
+ ...(chart ? { chart } : {}),
103
+ ...(sourceDescription ? { sourceDescription } : {}),
104
+ });
105
+ }
89
106
  }
90
107
  if (pairs.length > 0) out.set(models[i], pairs);
91
108
  });