@malloy-publisher/sdk 0.9.10 → 0.9.12

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 (263) hide show
  1. package/dist/{RenderedResult-Dp1Qdajz.es.js → RenderedResult-CDiXJAh9.es.js} +102 -102
  2. package/dist/RenderedResult-De51QvsZ.cjs.js +153 -0
  3. package/dist/ServerProvider-DKrBcXL7.cjs.js +1 -0
  4. package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-RvKSbvnL.es.js} +622 -587
  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 +72 -23
  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/Connections/common.d.ts +11 -3
  13. package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
  14. package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
  15. package/dist/components/Dashboard/DashboardView.d.ts +22 -34
  16. package/dist/components/Dashboard/TileCard.d.ts +10 -3
  17. package/dist/components/Dashboard/useStuck.d.ts +15 -7
  18. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
  19. package/dist/components/Package/PackageProblems.d.ts +14 -0
  20. package/dist/components/RemoveBadge.d.ts +40 -0
  21. package/dist/components/Report/Report.d.ts +13 -4
  22. package/dist/components/Report/ReportPage.d.ts +60 -0
  23. package/dist/components/Report/layoutRules.d.ts +32 -0
  24. package/dist/components/Report/reportQuery.d.ts +30 -0
  25. package/dist/components/Report/telemetry.d.ts +0 -2
  26. package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
  27. package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
  28. package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
  29. package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
  30. package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
  31. package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
  32. package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
  33. package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
  34. package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
  35. package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -8
  36. package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
  37. package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
  38. package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
  39. package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
  40. package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
  41. package/dist/components/ReportBuilder/TileMenu.d.ts +12 -9
  42. package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
  43. package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
  44. package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
  45. package/dist/components/ReportBuilder/catalog.d.ts +2 -4
  46. package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
  47. package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
  48. package/dist/components/ReportBuilder/preview.d.ts +17 -2
  49. package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
  50. package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
  51. package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
  52. package/dist/components/ReportBuilder/sortable.d.ts +4 -3
  53. package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
  54. package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
  55. package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
  56. package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
  57. package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
  58. package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
  59. package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
  60. package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
  61. package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
  62. package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
  63. package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
  64. package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
  65. package/dist/components/ServerProvider.d.ts +9 -0
  66. package/dist/components/controlTokens.d.ts +45 -0
  67. package/dist/components/drill/markDrillableCells.d.ts +1 -1
  68. package/dist/components/given/FilterButton.d.ts +35 -0
  69. package/dist/components/given/GivensPanel.d.ts +2 -1
  70. package/dist/components/given/filterEditing.d.ts +54 -0
  71. package/dist/components/given/filterSummary.d.ts +9 -0
  72. package/dist/components/given/paramCodec.d.ts +11 -0
  73. package/dist/components/given/required.d.ts +25 -0
  74. package/dist/components/index.d.ts +3 -0
  75. package/dist/components/legacy/index.d.ts +1 -1
  76. package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
  77. package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
  78. package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
  79. package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
  80. package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
  81. package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
  82. package/dist/components/styles.d.ts +0 -2
  83. package/dist/hooks/useQueryResult.d.ts +7 -0
  84. package/dist/index.cjs.js +16 -19
  85. package/dist/index.es.js +8418 -7722
  86. package/dist/theme/ThemeContext.d.ts +8 -1
  87. package/dist/theme/classes.d.ts +49 -0
  88. package/dist/theme/index.d.ts +2 -0
  89. package/dist/theme/types.d.ts +7 -0
  90. package/dist/theme/ui.d.ts +75 -0
  91. package/dist/{useCompiledDocument-BMPDvdFx.es.js → useCompiledDocument-Bf4RSfB6.es.js} +8669 -7851
  92. package/dist/useCompiledDocument-XsQz85Ri.cjs.js +141 -0
  93. package/package.json +2 -2
  94. package/src/builder-entry.ts +9 -0
  95. package/src/components/AppDialog.tsx +23 -0
  96. package/src/components/Connections/AddConnectionDialog.tsx +34 -2
  97. package/src/components/Connections/EditConnectionDialog.tsx +45 -3
  98. package/src/components/Connections/common.spec.ts +69 -0
  99. package/src/components/Connections/common.ts +132 -0
  100. package/src/components/Dashboard/DashboardGrid.tsx +39 -17
  101. package/src/components/Dashboard/DashboardTile.tsx +19 -2
  102. package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
  103. package/src/components/Dashboard/DashboardView.tsx +137 -155
  104. package/src/components/Dashboard/RowsDialog.tsx +1 -2
  105. package/src/components/Dashboard/TileCard.tsx +28 -10
  106. package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
  107. package/src/components/Dashboard/useStuck.ts +28 -17
  108. package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
  109. package/src/components/Environment/Connections.tsx +1 -0
  110. package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
  111. package/src/components/Package/NewDocumentDialog.tsx +383 -119
  112. package/src/components/Package/Package.artifacts.spec.tsx +1 -1
  113. package/src/components/Package/Package.create.spec.tsx +7 -6
  114. package/src/components/Package/Package.tsx +10 -7
  115. package/src/components/Package/PackageProblems.spec.tsx +41 -0
  116. package/src/components/Package/PackageProblems.tsx +95 -0
  117. package/src/components/Prose.tsx +12 -7
  118. package/src/components/RemoveBadge.tsx +94 -0
  119. package/src/components/RenderedResult/RenderedResult.tsx +5 -9
  120. package/src/components/RenderedResult/ResultPanel.tsx +59 -3
  121. package/src/components/Report/Report.spec.tsx +50 -32
  122. package/src/components/Report/Report.telemetry.spec.tsx +0 -45
  123. package/src/components/Report/Report.tsx +45 -77
  124. package/src/components/Report/ReportPage.tsx +168 -0
  125. package/src/components/Report/layoutRules.spec.ts +35 -0
  126. package/src/components/Report/layoutRules.ts +55 -0
  127. package/src/components/Report/reportQuery.ts +53 -0
  128. package/src/components/Report/telemetry.ts +0 -2
  129. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
  130. package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
  131. package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
  132. package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -39
  133. package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
  134. package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
  135. package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
  136. package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
  137. package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
  138. package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
  139. package/src/components/ReportBuilder/FilterStrip.tsx +130 -151
  140. package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
  141. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
  142. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
  143. package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
  144. package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -15
  145. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
  146. package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
  147. package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
  148. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +37 -31
  149. package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
  150. package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
  151. package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
  152. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
  153. package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
  154. package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
  155. package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
  156. package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
  157. package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
  158. package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
  159. package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
  160. package/src/components/ReportBuilder/TileFrame.tsx +212 -75
  161. package/src/components/ReportBuilder/TileMenu.tsx +241 -140
  162. package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
  163. package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
  164. package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
  165. package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
  166. package/src/components/ReportBuilder/builderControls.ts +164 -0
  167. package/src/components/ReportBuilder/builderReport.ts +1 -2
  168. package/src/components/ReportBuilder/catalog.ts +10 -26
  169. package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
  170. package/src/components/ReportBuilder/localGiven.ts +56 -0
  171. package/src/components/ReportBuilder/preview.spec.ts +125 -5
  172. package/src/components/ReportBuilder/preview.ts +60 -44
  173. package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
  174. package/src/components/ReportBuilder/readDocument.ts +14 -11
  175. package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
  176. package/src/components/ReportBuilder/readForEditor.ts +4 -26
  177. package/src/components/ReportBuilder/reportTag.ts +28 -7
  178. package/src/components/ReportBuilder/sortable.tsx +15 -7
  179. package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
  180. package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
  181. package/src/components/ReportBuilder/testing/inline.ts +25 -5
  182. package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
  183. package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
  184. package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
  185. package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
  186. package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
  187. package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
  188. package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
  189. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
  190. package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
  191. package/src/components/ReportBuilder/useExitGuard.ts +16 -0
  192. package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
  193. package/src/components/ReportBuilder/useFilterForm.ts +5 -1
  194. package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
  195. package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
  196. package/src/components/ReportBuilder/useReportDraft.ts +292 -0
  197. package/src/components/ReportBuilder/useReportEditor.ts +3 -12
  198. package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
  199. package/src/components/ReportBuilder/useTileEditing.ts +43 -12
  200. package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
  201. package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
  202. package/src/components/ReportBuilder/widthLabel.ts +26 -0
  203. package/src/components/ServerProvider.tsx +11 -0
  204. package/src/components/controlTokens.ts +47 -0
  205. package/src/components/drill/markDrillableCells.ts +2 -1
  206. package/src/components/given/FilterButton.spec.tsx +143 -0
  207. package/src/components/given/FilterButton.tsx +478 -0
  208. package/src/components/given/GivenInput.spec.tsx +47 -0
  209. package/src/components/given/GivenInput.tsx +20 -2
  210. package/src/components/given/GivensPanel.spec.tsx +11 -3
  211. package/src/components/given/GivensPanel.tsx +45 -44
  212. package/src/components/given/filterEditing.ts +60 -0
  213. package/src/components/given/filterSummary.spec.ts +108 -0
  214. package/src/components/given/filterSummary.ts +109 -0
  215. package/src/components/given/paramCodec.ts +1 -1
  216. package/src/components/given/required.spec.ts +60 -0
  217. package/src/components/given/required.ts +78 -0
  218. package/src/components/index.ts +9 -0
  219. package/src/components/legacy/Dashboard.spec.tsx +3 -1
  220. package/src/components/legacy/index.ts +1 -1
  221. package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
  222. package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
  223. package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
  224. package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
  225. package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
  226. package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
  227. package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
  228. package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
  229. package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
  230. package/src/components/legacy/malloynb/cellKind.ts +24 -0
  231. package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
  232. package/src/components/styles.ts +0 -18
  233. package/src/hooks/useGivensState.ts +7 -3
  234. package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
  235. package/src/hooks/useQueryResult.ts +26 -1
  236. package/src/theme/ThemeContext.tsx +21 -1
  237. package/src/theme/classes.ts +52 -0
  238. package/src/theme/index.ts +8 -0
  239. package/src/theme/resolveTheme.ts +3 -0
  240. package/src/theme/types.ts +7 -0
  241. package/src/theme/ui.spec.tsx +91 -0
  242. package/src/theme/ui.ts +115 -0
  243. package/dist/RenderedResult-BcgYjkZ0.cjs.js +0 -153
  244. package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
  245. package/dist/components/Notebook/cellKind.d.ts +0 -20
  246. package/dist/components/Report/LinearReport.d.ts +0 -18
  247. package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
  248. package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
  249. package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
  250. package/dist/useCompiledDocument-UY28ITET.cjs.js +0 -141
  251. package/src/components/Notebook/cellKind.spec.ts +0 -199
  252. package/src/components/Notebook/cellKind.ts +0 -74
  253. package/src/components/Report/LinearReport.tsx +0 -71
  254. package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
  255. package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
  256. package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
  257. package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
  258. package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
  259. package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
  260. package/src/components/legacy/Notebook.served.spec.tsx +0 -183
  261. /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
  262. /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
  263. /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
@@ -125,27 +125,154 @@ describe("DashboardView tiles", () => {
125
125
  });
126
126
  });
127
127
 
128
- describe("DashboardView chrome", () => {
129
- it("draws cards by default", async () => {
130
- const { container } = render(view(), { wrapper: serverWrapper });
131
- await screen.findByText("reader");
128
+ describe("filters a host writes into the query (literalReads)", () => {
129
+ it("count as read for the tile, and are never sent as givens", async () => {
130
+ const manifest = {
131
+ ...base,
132
+ givens: [
133
+ { name: "REGION", type: "string", label: "Region" },
134
+ // The document's own filter: resolved to a literal by the host.
135
+ { name: "BRAND", type: "string", label: "Brand" },
136
+ ],
137
+ tiles: [
138
+ {
139
+ kind: "query",
140
+ query: "orders -> by_brand",
141
+ givenNames: ["REGION"],
142
+ },
143
+ {
144
+ kind: "query",
145
+ query: "orders -> by_region",
146
+ givenNames: ["REGION"],
147
+ },
148
+ ],
149
+ } as DashboardManifest;
150
+ render(
151
+ <DashboardView
152
+ manifest={manifest}
153
+ environmentName="env"
154
+ packageName="pkg"
155
+ documentName="ops"
156
+ givens={{ REGION: "West", BRAND: "Acme" }}
157
+ literalReads={{ "orders -> by_brand": ["BRAND"] }}
158
+ />,
159
+ { wrapper: serverWrapper },
160
+ );
161
+
162
+ await waitFor(() =>
163
+ expect(executeQueryModel.mock.calls.length).toBeGreaterThanOrEqual(2),
164
+ );
165
+ // Only the tile that does not read Brand says so.
166
+ const tags = await screen.findAllByTestId("tile-filter-tag");
167
+ expect(tags.map((tag) => tag.textContent)).toEqual([
168
+ "Doesn't respond to Brand",
169
+ ]);
170
+ expect(tags[0].closest("[data-chrome]")?.textContent).toContain(
171
+ "By region",
172
+ );
173
+ // Brand's value reaches no request: the server does not know it.
174
+ for (const call of executeQueryModel.mock.calls)
175
+ expect(JSON.stringify(call[3])).not.toContain("BRAND");
176
+ });
177
+ });
178
+
179
+ describe("a required filter with no value", () => {
180
+ const manifest = {
181
+ ...base,
182
+ givens: [
183
+ {
184
+ name: "RECALL_YEAR",
185
+ type: "number",
186
+ label: "Recall Year",
187
+ required: true,
188
+ },
189
+ ],
190
+ tiles: [
191
+ {
192
+ kind: "query",
193
+ query: "recalls -> by_year",
194
+ givenNames: ["RECALL_YEAR"],
195
+ label: "By year",
196
+ },
197
+ {
198
+ kind: "query",
199
+ query: "recalls -> everything",
200
+ givenNames: [],
201
+ label: "Everything",
202
+ },
203
+ ],
204
+ } as DashboardManifest;
205
+ const sent = () =>
206
+ executeQueryModel.mock.calls.map(
207
+ (call) => (call[3] as { query?: string }).query,
208
+ );
209
+
210
+ it("runs no tile that reads it, and asks for it once for the page", async () => {
211
+ render(
212
+ <DashboardView
213
+ manifest={manifest}
214
+ environmentName="env"
215
+ packageName="pkg"
216
+ documentName="recalls"
217
+ />,
218
+ { wrapper: serverWrapper },
219
+ );
220
+ expect(
221
+ await screen.findByText(
222
+ "Pick a value for Recall Year to see this report.",
223
+ ),
224
+ ).toBeDefined();
225
+ expect(screen.getByText("Waiting for Recall Year.")).toBeDefined();
226
+ await waitFor(() =>
227
+ expect(sent()).toContain("run: recalls -> everything"),
228
+ );
229
+ expect(sent()).not.toContain("run: recalls -> by_year");
230
+ // The control says it, rather than "Any".
132
231
  expect(
133
- container.querySelectorAll('[data-chrome="card"]').length,
134
- ).toBeGreaterThan(0);
135
- expect(container.querySelector('[data-chrome="none"]')).toBeNull();
232
+ screen.getByRole("button", { name: "Recall Year: Required" }),
233
+ ).toBeDefined();
136
234
  });
137
235
 
138
- it("draws no cards and no title block with chrome none", async () => {
139
- const { container } = render(view("none"), { wrapper: serverWrapper });
140
- await screen.findByText("reader");
141
- expect(container.querySelector('[data-chrome="card"]')).toBeNull();
142
- expect(container.querySelectorAll('[data-chrome="none"]').length).toBe(3);
143
- expect(screen.queryByText("ops")).toBeNull();
236
+ it("runs every tile once it has a value, with no prompt", async () => {
237
+ render(
238
+ <DashboardView
239
+ manifest={manifest}
240
+ environmentName="env"
241
+ packageName="pkg"
242
+ documentName="recalls-set"
243
+ givens={{ RECALL_YEAR: "2020" }}
244
+ />,
245
+ { wrapper: serverWrapper },
246
+ );
247
+ await waitFor(() => expect(sent()).toContain("run: recalls -> by_year"));
248
+ expect(
249
+ screen.queryByText("Pick a value for Recall Year to see this report."),
250
+ ).toBeNull();
144
251
  });
145
252
  });
146
253
 
254
+ describe("DashboardView chrome", () => {
255
+ // A linear report and a grid draw the same page: query tiles in cards, text
256
+ // tiles as bare prose, and the title block. `chrome` is accepted and ignored.
257
+ for (const chrome of [undefined, "card", "none"] as const) {
258
+ it(`draws query tiles as cards and text as prose, with chrome ${chrome ?? "unset"}`, async () => {
259
+ const { container } = render(view(chrome), {
260
+ wrapper: serverWrapper,
261
+ });
262
+ const strong = await screen.findByText("reader");
263
+ expect(
264
+ strong.closest("[data-chrome]")?.getAttribute("data-chrome"),
265
+ ).toBe("none");
266
+ expect(
267
+ container.querySelectorAll('[data-chrome="card"]'),
268
+ ).toHaveLength(2);
269
+ expect(screen.getByRole("heading", { name: "ops" })).toBeDefined();
270
+ });
271
+ }
272
+ });
273
+
147
274
  describe("DashboardView header", () => {
148
- it("boxes a dashboard's description as it boxes a text tile", async () => {
275
+ it("draws a dashboard's description as bare page prose, not a card", async () => {
149
276
  render(
150
277
  <DashboardView
151
278
  manifest={{ ...base, description: "About **this**" }}
@@ -157,8 +284,82 @@ describe("DashboardView header", () => {
157
284
  );
158
285
  const strong = await screen.findByText("this");
159
286
  expect(strong.closest("[data-chrome]")?.getAttribute("data-chrome")).toBe(
160
- "card",
287
+ "none",
288
+ );
289
+ });
290
+ });
291
+
292
+ describe("DashboardView layout marker", () => {
293
+ it("marks the page with its layout, and a report that failed to load too", () => {
294
+ const { container, unmount } = render(
295
+ <DashboardView
296
+ manifest={{ ...base, layout: "linear" }}
297
+ environmentName="env"
298
+ packageName="pkg"
299
+ documentName="ops"
300
+ />,
301
+ { wrapper: serverWrapper },
302
+ );
303
+ expect(container.querySelector('[data-layout="linear"]')).not.toBeNull();
304
+ unmount();
305
+
306
+ const failed = render(
307
+ <DashboardView
308
+ manifest={{ ...base, layout: "grid", error: "did not compile" }}
309
+ environmentName="env"
310
+ packageName="pkg"
311
+ documentName="ops"
312
+ />,
313
+ { wrapper: serverWrapper },
161
314
  );
315
+ expect(
316
+ failed.container.querySelector('[data-layout="grid"]'),
317
+ ).not.toBeNull();
318
+ });
319
+ });
320
+
321
+ describe("DashboardView prose links", () => {
322
+ const linked = {
323
+ ...base,
324
+ tiles: [
325
+ { kind: "text", name: "intro", markdown: "See [the tour](tour)" },
326
+ ],
327
+ } as DashboardManifest;
328
+
329
+ it("leaves a relative link as written when the host has no router", async () => {
330
+ render(
331
+ <DashboardView
332
+ manifest={linked}
333
+ environmentName="env"
334
+ packageName="pkg"
335
+ documentName="ops"
336
+ />,
337
+ { wrapper: serverWrapper },
338
+ );
339
+
340
+ const link = await screen.findByRole("link", { name: "the tour" });
341
+ // Its host's routes are unknown here (a version segment, another prefix), so nothing is rewritten.
342
+ expect(link.getAttribute("href")).toBe("tour");
343
+ });
344
+
345
+ it("resolves a relative link against the report and hands it to the host's router", async () => {
346
+ const onLinkNavigate = mock((_to: string) => undefined);
347
+ render(
348
+ <DashboardView
349
+ manifest={linked}
350
+ environmentName="env"
351
+ packageName="pkg"
352
+ documentName="ops"
353
+ onLinkNavigate={onLinkNavigate}
354
+ />,
355
+ { wrapper: serverWrapper },
356
+ );
357
+
358
+ const link = await screen.findByRole("link", { name: "the tour" });
359
+ expect(link.getAttribute("href")).toBe("/env/pkg/dashboards/tour");
360
+ link.click();
361
+ expect(onLinkNavigate).toHaveBeenCalledTimes(1);
362
+ expect(onLinkNavigate.mock.calls[0][0]).toBe("/env/pkg/dashboards/tour");
162
363
  });
163
364
  });
164
365
 
@@ -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",