@malloy-publisher/sdk 0.9.2 → 0.9.4

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 (264) hide show
  1. package/dist/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
  2. package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
  3. package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
  4. package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +112 -115
  6. package/dist/builder/index.es.js +11766 -11502
  7. package/dist/builder-entry.d.ts +1 -1
  8. package/dist/client/api.d.ts +170 -9
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +93 -89
  11. package/dist/client-entry.d.ts +2 -0
  12. package/dist/components/ApiErrorDisplay.d.ts +11 -0
  13. package/dist/components/AppDialog.d.ts +6 -6
  14. package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
  15. package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
  16. package/dist/components/Dashboard/DashboardView.d.ts +38 -3
  17. package/dist/components/Dashboard/TileCard.d.ts +16 -2
  18. package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
  19. package/dist/components/Dashboard/index.d.ts +3 -2
  20. package/dist/components/Dashboard/telemetry.d.ts +2 -1
  21. package/dist/components/Dashboard/textSource.d.ts +19 -0
  22. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
  23. package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
  24. package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
  25. package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
  26. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
  27. package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
  28. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
  29. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
  30. package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
  31. package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
  32. package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
  33. package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
  34. package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
  35. package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
  36. package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
  37. package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
  38. package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
  39. package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
  40. package/dist/components/DashboardBuilder/imports.d.ts +19 -0
  41. package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
  42. package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
  43. package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
  44. package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
  45. package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
  46. package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
  47. package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
  48. package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
  49. package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
  50. package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
  51. package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
  52. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
  53. package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
  54. package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
  55. package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
  56. package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
  57. package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
  58. package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
  59. package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
  60. package/dist/components/Loading.d.ts +13 -0
  61. package/dist/components/Notebook/NotebookCell.d.ts +1 -5
  62. package/dist/components/Package/Package.d.ts +16 -1
  63. package/dist/components/Package/index.d.ts +1 -1
  64. package/dist/components/Prose.d.ts +1 -1
  65. package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
  66. package/dist/components/given/paramCodec.d.ts +8 -1
  67. package/dist/components/index.d.ts +1 -2
  68. package/dist/components/styles.d.ts +4 -4
  69. package/dist/hooks/givenValue.d.ts +6 -0
  70. package/dist/hooks/index.d.ts +1 -0
  71. package/dist/hooks/useCompiledDocument.d.ts +23 -0
  72. package/dist/hooks/useDocumentControls.d.ts +6 -1
  73. package/dist/hooks/useNearViewport.d.ts +16 -0
  74. package/dist/hooks/useQueryWithApiError.d.ts +7 -2
  75. package/dist/hooks/useSuggestOptions.d.ts +9 -2
  76. package/dist/index.cjs.js +14 -14
  77. package/dist/index.es.js +9760 -10363
  78. package/dist/text/index.es.js +1 -1
  79. package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
  80. package/dist/text-entry.d.ts +1 -1
  81. package/dist/theme/accent.d.ts +29 -0
  82. package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
  83. package/dist/theme/index.d.ts +3 -0
  84. package/dist/theme/keys.d.ts +1 -1
  85. package/dist/theme/motion.d.ts +31 -0
  86. package/dist/theme/readChartAnnotations.d.ts +1 -1
  87. package/dist/theme/resolveTheme.d.ts +4 -4
  88. package/dist/theme/types.d.ts +33 -5
  89. package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
  90. package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
  91. package/package.json +11 -11
  92. package/src/builder-entry.ts +1 -0
  93. package/src/client-entry.ts +8 -0
  94. package/src/clientEntry.spec.ts +17 -0
  95. package/src/components/ApiErrorDisplay.tsx +37 -18
  96. package/src/components/AppDialog.tsx +8 -7
  97. package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
  98. package/src/components/Dashboard/Dashboard.tsx +2 -2
  99. package/src/components/Dashboard/DashboardGrid.tsx +23 -5
  100. package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
  101. package/src/components/Dashboard/DashboardTile.tsx +95 -31
  102. package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
  103. package/src/components/Dashboard/DashboardView.tsx +165 -89
  104. package/src/components/Dashboard/RowsDialog.tsx +3 -2
  105. package/src/components/Dashboard/TileCard.tsx +17 -2
  106. package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
  107. package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
  108. package/src/components/Dashboard/index.ts +11 -2
  109. package/src/components/Dashboard/telemetry.ts +2 -1
  110. package/src/components/Dashboard/textSource.spec.ts +36 -0
  111. package/src/components/Dashboard/textSource.ts +39 -0
  112. package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
  113. package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
  114. package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
  115. package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
  116. package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
  117. package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
  118. package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
  119. package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
  120. package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
  121. package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
  122. package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
  123. package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
  124. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
  125. package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
  126. package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
  127. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
  128. package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
  129. package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
  130. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
  131. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
  132. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
  133. package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
  134. package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
  135. package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
  136. package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
  137. package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
  138. package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
  139. package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
  140. package/src/components/DashboardBuilder/InlineText.tsx +23 -17
  141. package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
  142. package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
  143. package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
  144. package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
  145. package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
  146. package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
  147. package/src/components/DashboardBuilder/builderReport.ts +74 -0
  148. package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
  149. package/src/components/DashboardBuilder/catalog.ts +0 -36
  150. package/src/components/DashboardBuilder/controls.spec.ts +1 -1
  151. package/src/components/DashboardBuilder/controls.ts +1 -1
  152. package/src/components/DashboardBuilder/documentSession.ts +3 -2
  153. package/src/components/DashboardBuilder/imports.spec.ts +61 -0
  154. package/src/components/DashboardBuilder/imports.ts +93 -0
  155. package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
  156. package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
  157. package/src/components/DashboardBuilder/malloyTree.ts +5 -1
  158. package/src/components/DashboardBuilder/newDashboard.ts +1 -1
  159. package/src/components/DashboardBuilder/preview.ts +1 -1
  160. package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
  161. package/src/components/DashboardBuilder/readDocument.ts +10 -4
  162. package/src/components/DashboardBuilder/readForEditor.ts +7 -2
  163. package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
  164. package/src/components/DashboardBuilder/sortable.tsx +11 -0
  165. package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
  166. package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
  167. package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
  168. package/src/components/DashboardBuilder/testing/inline.ts +1 -1
  169. package/src/components/DashboardBuilder/testing/resize.ts +48 -0
  170. package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
  171. package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
  172. package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
  173. package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
  174. package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
  175. package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
  176. package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
  177. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
  178. package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
  179. package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
  180. package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
  181. package/src/components/DashboardBuilder/useDraft.ts +15 -2
  182. package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
  183. package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
  184. package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
  185. package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
  186. package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
  187. package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
  188. package/src/components/DashboardBuilder/useTileResize.ts +133 -0
  189. package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
  190. package/src/components/DocumentCreate/guards.ts +1 -1
  191. package/src/components/Environment/Environment.tsx +0 -10
  192. package/src/components/Loading.tsx +14 -0
  193. package/src/components/Model/Model.tsx +16 -9
  194. package/src/components/Model/ModelExplorer.tsx +2 -2
  195. package/src/components/Notebook/Notebook.tsx +6 -2
  196. package/src/components/Notebook/NotebookCell.tsx +90 -215
  197. package/src/components/Package/Package.artifacts.spec.tsx +8 -12
  198. package/src/components/Package/Package.create.spec.tsx +22 -1
  199. package/src/components/Package/Package.tsx +51 -27
  200. package/src/components/Package/index.ts +1 -1
  201. package/src/components/Prose.spec.tsx +37 -0
  202. package/src/components/Prose.tsx +35 -5
  203. package/src/components/RenderedResult/RenderedResult.tsx +5 -7
  204. package/src/components/RenderedResult/ResultContainer.tsx +7 -2
  205. package/src/components/RenderedResult/ResultPanel.tsx +20 -5
  206. package/src/components/RenderedResult/loadRenderer.ts +42 -0
  207. package/src/components/given/GivenInput.spec.tsx +5 -5
  208. package/src/components/given/GivenInput.tsx +46 -38
  209. package/src/components/given/GivensPanel.tsx +2 -8
  210. package/src/components/given/paramCodec.ts +27 -1
  211. package/src/components/index.ts +1 -2
  212. package/src/components/styles.ts +4 -5
  213. package/src/hooks/givenValue.ts +9 -0
  214. package/src/hooks/index.ts +4 -0
  215. package/src/hooks/useCompiledDocument.spec.tsx +86 -0
  216. package/src/hooks/useCompiledDocument.ts +59 -0
  217. package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
  218. package/src/hooks/useDocumentControls.ts +13 -1
  219. package/src/hooks/useNearViewport.spec.tsx +150 -0
  220. package/src/hooks/useNearViewport.ts +102 -0
  221. package/src/hooks/useQueryResult.ts +7 -1
  222. package/src/hooks/useQueryWithApiError.ts +10 -3
  223. package/src/hooks/useRawQueryData.ts +3 -1
  224. package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
  225. package/src/hooks/useSuggestOptions.ts +42 -10
  226. package/src/text-entry.ts +1 -1
  227. package/src/textEntry.spec.ts +2 -8
  228. package/src/theme/accent.spec.ts +116 -0
  229. package/src/theme/accent.ts +148 -0
  230. package/src/theme/buildTableCssVars.spec.ts +24 -0
  231. package/src/theme/buildTableCssVars.ts +1 -2
  232. package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
  233. package/src/theme/buildVegaThemeOverride.ts +5 -5
  234. package/src/theme/defaults.ts +34 -0
  235. package/src/theme/index.ts +9 -0
  236. package/src/theme/keys.ts +6 -0
  237. package/src/theme/motion.ts +44 -0
  238. package/src/theme/readChartAnnotations.spec.ts +18 -0
  239. package/src/theme/readChartAnnotations.ts +1 -1
  240. package/src/theme/resolveTheme.spec.ts +73 -0
  241. package/src/theme/resolveTheme.ts +61 -20
  242. package/src/theme/types.ts +30 -5
  243. package/src/utils/queryClient.ts +8 -0
  244. package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
  245. package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
  246. package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
  247. package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
  248. package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
  249. package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
  250. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
  251. package/dist/components/DashboardBuilder/diff.d.ts +0 -35
  252. package/src/components/Dashboard/DashboardBar.tsx +0 -88
  253. package/src/components/Dashboard/ExploreDialog.tsx +0 -89
  254. package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
  255. package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
  256. package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
  257. package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
  258. package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
  259. package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
  260. package/src/components/DashboardBuilder/diff.spec.ts +0 -44
  261. package/src/components/DashboardBuilder/diff.ts +0 -93
  262. /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
  263. /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
  264. /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
@@ -165,6 +165,43 @@ describe("DashboardView chrome", () => {
165
165
  });
166
166
  });
167
167
 
168
+ describe("DashboardView header", () => {
169
+ it("boxes a dashboard's description as it boxes a text tile", async () => {
170
+ render(
171
+ <DashboardView
172
+ manifest={{ ...base, description: "About **this**" }}
173
+ environmentName="env"
174
+ packageName="pkg"
175
+ documentName="ops"
176
+ />,
177
+ { wrapper: serverWrapper },
178
+ );
179
+ const strong = await screen.findByText("this");
180
+ expect(strong.closest("[data-chrome]")?.getAttribute("data-chrome")).toBe(
181
+ "card",
182
+ );
183
+ });
184
+ });
185
+
186
+ describe("DashboardView control row", () => {
187
+ it("draws no sticky row when the document declares no controls", async () => {
188
+ const { container } = render(
189
+ <DashboardView
190
+ manifest={{ ...base, givens: [] }}
191
+ environmentName="env"
192
+ packageName="pkg"
193
+ documentName="ops"
194
+ />,
195
+ { wrapper: serverWrapper },
196
+ );
197
+ await screen.findByText("reader");
198
+ const sticky = Array.from(container.querySelectorAll("div")).filter(
199
+ (el) => getComputedStyle(el).position === "sticky",
200
+ );
201
+ expect(sticky).toHaveLength(0);
202
+ });
203
+ });
204
+
168
205
  describe("DashboardView gate givens", () => {
169
206
  // ORG is read only by the source's `#(authorize)` gate: the tile names it,
170
207
  // the control row does not declare it, and the host supplies it.
@@ -209,4 +246,123 @@ describe("DashboardView gate givens", () => {
209
246
  expect(tileGivens("orders -> by_year")).toEqual({ REGION: "CA" });
210
247
  expect(screen.queryByText("ORG")).toBeNull();
211
248
  });
249
+
250
+ it("sends a list-valued host given to the tiles that name it", async () => {
251
+ render(
252
+ <DashboardView
253
+ manifest={gated}
254
+ environmentName="env"
255
+ packageName="pkg"
256
+ documentName="ops"
257
+ givens={{ ORG: ["1", "2"], REGION: "CA" }}
258
+ />,
259
+ { wrapper: serverWrapper },
260
+ );
261
+
262
+ await waitFor(() =>
263
+ expect(tileGivens("orders -> by_month")).toEqual({
264
+ ORG: ["1", "2"],
265
+ REGION: "CA",
266
+ }),
267
+ );
268
+ });
269
+ });
270
+
271
+ describe("DashboardView in text-source mode", () => {
272
+ const document = {
273
+ ...base,
274
+ givens: [
275
+ { name: "REGION", type: "string", label: "Region" },
276
+ { name: "TENANT", type: "string", label: "Tenant" },
277
+ { name: "ORG", type: "string", label: "Organization", secure: true },
278
+ ],
279
+ tiles: [
280
+ { kind: "query", query: "a -> by_month", givenNames: ["REGION"] },
281
+ { kind: "query", query: "gated -> total", restricted: true },
282
+ ],
283
+ } as DashboardManifest;
284
+
285
+ const mountText = () =>
286
+ render(
287
+ <DashboardView
288
+ manifest={document}
289
+ environmentName="env"
290
+ packageName="pkg"
291
+ documentName="ops"
292
+ preamble={"source: a is orders"}
293
+ runModelPath="models/orders.malloy"
294
+ hiddenGivens={["TENANT"]}
295
+ />,
296
+ { wrapper: serverWrapper },
297
+ );
298
+
299
+ it("runs each tile as the definitions plus one run: against the model, and nothing for a restricted tile", async () => {
300
+ mountText();
301
+
302
+ await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(1));
303
+ const [, , modelPath, request] = executeQueryModel.mock.calls[0];
304
+ expect(modelPath).toBe("models/orders.malloy");
305
+ expect((request as { query?: string }).query).toBe(
306
+ "source: a is orders\n\nrun: a -> by_month",
307
+ );
308
+ expect(
309
+ await screen.findByText("You don't have access to this data"),
310
+ ).toBeDefined();
311
+ });
312
+
313
+ it("shows no control for a host-hidden or #(secure) given", async () => {
314
+ mountText();
315
+
316
+ expect((await screen.findAllByText("Region")).length).toBeGreaterThan(0);
317
+ expect(screen.queryByText("Tenant")).toBeNull();
318
+ expect(screen.queryByText("Organization")).toBeNull();
319
+ });
320
+
321
+ it("answers a 403 on a tile with the access notice, where an ordinary view shows the error", async () => {
322
+ executeQueryModel.mockImplementation(() =>
323
+ Promise.reject({
324
+ response: { status: 403, data: { code: 403, message: "denied" } },
325
+ }),
326
+ );
327
+ const text = mountText();
328
+ await waitFor(() =>
329
+ expect(
330
+ screen.getAllByText("You don't have access to this data").length,
331
+ ).toBe(2),
332
+ );
333
+ expect(screen.queryByText("denied")).toBeNull();
334
+ text.unmount();
335
+
336
+ render(view(), { wrapper: serverWrapper });
337
+ expect((await screen.findAllByText("denied")).length).toBeGreaterThan(0);
338
+ });
339
+ });
340
+
341
+ it("leaves a #(secure) given's control alone outside text-source mode", async () => {
342
+ render(
343
+ <DashboardView
344
+ manifest={
345
+ {
346
+ name: "ops",
347
+ path: "dashboards/ops.malloy",
348
+ givens: [
349
+ {
350
+ name: "ORG",
351
+ type: "string",
352
+ label: "Organization",
353
+ secure: true,
354
+ },
355
+ ],
356
+ tiles: [{ kind: "query", query: "a -> v", givenNames: ["ORG"] }],
357
+ } as DashboardManifest
358
+ }
359
+ environmentName="env"
360
+ packageName="pkg"
361
+ documentName="ops"
362
+ />,
363
+ { wrapper: serverWrapper },
364
+ );
365
+ expect((await screen.findAllByText("Organization")).length).toBeGreaterThan(
366
+ 0,
367
+ );
212
368
  });
@@ -4,7 +4,7 @@
4
4
  import { Alert, Box, Stack, Typography } from "@mui/material";
5
5
  import { useCallback, useMemo, useState } from "react";
6
6
  import type { DashboardManifest } from "../../client";
7
- import type { GivenValue } from "../../hooks/givenValue";
7
+ import type { HostGivenValue } from "../../hooks/givenValue";
8
8
  import { useDocumentControls } from "../../hooks/useDocumentControls";
9
9
  import {
10
10
  useDrill,
@@ -13,13 +13,18 @@ import {
13
13
  type DrillNavigation,
14
14
  type DrillRowsRequest,
15
15
  } from "../drill";
16
- import { GivensPanel } from "../given";
17
- import { givensToParams, givensToRequest } from "../given/paramCodec";
16
+ import { GivensPanel, type GivensLayout } from "../given";
17
+ import { givensToRequest, withHostGivens } from "../given/paramCodec";
18
18
  import { Prose } from "../Prose";
19
19
  import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
20
- import { DashboardGrid, DEFAULT_COLUMNS } from "./DashboardGrid";
20
+ import {
21
+ DashboardGrid,
22
+ BARE_DESCRIPTION_MARGIN_PX,
23
+ DEFAULT_COLUMNS,
24
+ GRID_GAP_PX,
25
+ NOTEBOOK_GAP_PX,
26
+ } from "./DashboardGrid";
21
27
  import { DashboardTile } from "./DashboardTile";
22
- import { ExploreDialog } from "./ExploreDialog";
23
28
  import { RowsDialog, stepsOf, type RowsRequest } from "./RowsDialog";
24
29
  import type { DashboardEventHandler } from "./telemetry";
25
30
  import { TileCard, type TileChrome } from "./TileCard";
@@ -28,6 +33,14 @@ import { tileIgnoredFilterLabels } from "./TileFilterTag";
28
33
  /** Narrowest a tile that sets no `colspan` is allowed to render. */
29
34
  const MIN_TILE_PX = 240;
30
35
 
36
+ /**
37
+ * The sticky control row's stacking level: above anything a tile raises
38
+ * inside itself as it scrolls under (a result's floating buttons sit at 1–2),
39
+ * and below MUI's app bar, popovers and dialogs. Shared so the builder's
40
+ * control row sits at the same level as the reader's.
41
+ */
42
+ export const STICKY_CONTROLS_Z = 4;
43
+
31
44
  export interface DashboardViewProps {
32
45
  /** The dashboard, or the tile layout a layout notebook carries. */
33
46
  manifest: DashboardManifest;
@@ -36,7 +49,12 @@ export interface DashboardViewProps {
36
49
  versionId?: string;
37
50
  /** The slug or path the manifest was fetched under, which keys its control edits. */
38
51
  documentName: string;
39
- givens?: Record<string, string>;
52
+ /**
53
+ * The host's values, typically its URL query parameters. A string drives a
54
+ * control; a value no control declares is sent as given to the tiles that
55
+ * read it, and only there may it be a list.
56
+ */
57
+ givens?: Record<string, HostGivenValue>;
40
58
  onGivensChange?: (
41
59
  givens: Record<string, string>,
42
60
  managed: readonly string[],
@@ -47,6 +65,21 @@ export interface DashboardViewProps {
47
65
  onEvent?: DashboardEventHandler;
48
66
  /** `none` renders tiles as a document, with no cards or title block. */
49
67
  chrome?: TileChrome;
68
+ /**
69
+ * How the control row is drawn: `bar` for a dashboard, `panel` for a
70
+ * notebook, so a layout notebook's controls match a cell notebook's.
71
+ */
72
+ controlsLayout?: GivensLayout;
73
+ /**
74
+ * Text-source mode: the document's definitions (see `documentPreamble`),
75
+ * sent ahead of each tile's `run:` so every query runs as the viewer's own
76
+ * text. Rows, which reopens a tile by name, is off in this mode.
77
+ */
78
+ preamble?: string;
79
+ /** Text-source mode: the model the text runs on top of, in place of `manifest.path`. */
80
+ runModelPath?: string;
81
+ /** Givens the host sets itself: no control is shown for them. */
82
+ hiddenGivens?: readonly string[];
50
83
  }
51
84
 
52
85
  /**
@@ -68,8 +101,34 @@ export function DashboardView({
68
101
  maxResultSize,
69
102
  onEvent,
70
103
  chrome = "card",
104
+ controlsLayout = "bar",
105
+ preamble,
106
+ runModelPath,
107
+ hiddenGivens,
71
108
  }: DashboardViewProps) {
72
- const specs = useMemo(() => manifest.givens ?? [], [manifest]);
109
+ const specs = useMemo(
110
+ () =>
111
+ (manifest.givens ?? []).filter(
112
+ // In text-source mode, a `#(secure)` given is the host's to set: no control for it.
113
+ (spec) =>
114
+ !(preamble !== undefined && spec.secure === true) &&
115
+ !(spec.name !== undefined && hiddenGivens?.includes(spec.name)),
116
+ ),
117
+ [manifest, hiddenGivens, preamble],
118
+ );
119
+
120
+ // Only a string can be a control's value; a list has no URL form.
121
+ const controlParams = useMemo(
122
+ () =>
123
+ givens === undefined
124
+ ? undefined
125
+ : (Object.fromEntries(
126
+ Object.entries(givens).filter(
127
+ ([, value]) => typeof value === "string",
128
+ ),
129
+ ) as Record<string, string>),
130
+ [givens],
131
+ );
73
132
 
74
133
  // The control row's state, options and `to=self` drill: the same hook the
75
134
  // notebook uses, so a control behaves identically on both surfaces.
@@ -77,7 +136,7 @@ export function DashboardView({
77
136
  specs,
78
137
  loaded: true,
79
138
  startingValues: manifest.startingGivens,
80
- params: givens,
139
+ params: controlParams,
81
140
  onGivensChange,
82
141
  // Version included: two dashboards whose starting values coincide would
83
142
  // otherwise look like one document, and the one you came from would keep
@@ -87,30 +146,30 @@ export function DashboardView({
87
146
  autorun: manifest.autorun !== false,
88
147
  environmentName,
89
148
  packageName,
90
- modelPath: manifest.path,
149
+ modelPath: runModelPath ?? manifest.path,
91
150
  versionId,
92
151
  documentName,
152
+ ...(preamble !== undefined ? { preamble } : {}),
153
+ ...(givens ? { hostGivens: givens } : {}),
93
154
  });
94
155
  const { applied, declaredTypes, canSelf, onSelf } = controls;
95
156
 
96
157
  // A given only a gate reads is in a tile's `givenNames` but not the row, so
97
158
  // the host's value for it is sent as given: the row would drop it as undeclared.
98
- const tileGivens = useMemo(() => {
159
+ const tileHostGivens = useMemo(() => {
99
160
  const named = new Set(
100
161
  (manifest.tiles ?? []).flatMap((tile) => tile.givenNames ?? []),
101
162
  );
102
- const hostOnly = Object.entries(givens ?? {}).filter(
103
- ([name]) => named.has(name) && !declaredTypes.has(name),
163
+ return Object.fromEntries(
164
+ Object.entries(givens ?? {}).filter(
165
+ ([name]) => named.has(name) && !declaredTypes.has(name),
166
+ ),
104
167
  );
105
- if (hostOnly.length === 0) return applied;
106
- return new Map<string, GivenValue>([...hostOnly, ...applied]);
107
- }, [manifest, givens, declaredTypes, applied]);
168
+ }, [manifest, givens, declaredTypes]);
108
169
 
109
- // The rows behind a clicked value, and a tile's query in the explorer —
110
- // the two ways past a number. Composite tiles only: each names its
111
- // source, which is what the rows are of and what the explorer opens on.
170
+ // The rows behind a clicked value: the way past a number. Composite tiles
171
+ // only: each names its source, which is what the rows are of.
112
172
  const [rows, setRows] = useState<RowsRequest | undefined>(undefined);
113
- const [exploring, setExploring] = useState<string | undefined>(undefined);
114
173
  const onRows = useCallback((request: DrillRowsRequest) => {
115
174
  const steps = stepsOf(request.context);
116
175
  if (steps === undefined) return;
@@ -125,14 +184,12 @@ export function DashboardView({
125
184
  // The whole applied row and any gate givens: a source's own `where:` may read any of it, and a
126
185
  // given the rows query does not reference is ignored by the server.
127
186
  const rowsGivens = useMemo(
128
- () => givensToRequest(tileGivens, declaredTypes),
129
- [tileGivens, declaredTypes],
130
- );
131
-
132
- // The explorer's controls take the URL-string form, not the request form.
133
- const exploreGivens = useMemo(
134
- () => givensToParams(applied, declaredTypes),
135
- [applied, declaredTypes],
187
+ () =>
188
+ withHostGivens(
189
+ givensToRequest(applied, declaredTypes),
190
+ tileHostGivens,
191
+ ),
192
+ [applied, declaredTypes, tileHostGivens],
136
193
  );
137
194
 
138
195
  const { drill, drillMenu } = useDrill({
@@ -140,7 +197,7 @@ export function DashboardView({
140
197
  onSelf,
141
198
  canSelf,
142
199
  selfLabel: "Filter this dashboard",
143
- onRows,
200
+ ...(preamble === undefined ? { onRows } : {}),
144
201
  });
145
202
  // Each tile's clicks carry the tile they came from, so the rows behind a
146
203
  // value know which source to run against.
@@ -158,31 +215,37 @@ export function DashboardView({
158
215
  if (manifest.error) {
159
216
  return (
160
217
  <Stack spacing={2}>
161
- <DashboardHeader manifest={manifest} />
218
+ <DashboardHeader manifest={manifest} chrome={chrome} />
162
219
  <Alert severity="error">{manifest.error}</Alert>
163
220
  </Stack>
164
221
  );
165
222
  }
166
223
 
167
- const modelPath = manifest.path;
224
+ const modelPath = runModelPath ?? manifest.path;
168
225
  const tiles = manifest.tiles ?? [];
169
226
  const columns = manifest.dashboardColumns ?? DEFAULT_COLUMNS;
170
227
 
171
228
  return (
172
229
  <Stack spacing={2}>
173
- {chrome === "card" && <DashboardHeader manifest={manifest} />}
230
+ {chrome === "card" && (
231
+ <DashboardHeader manifest={manifest} chrome={chrome} />
232
+ )}
174
233
 
175
- {/* Sticky so the controls stay in reach while the tiles scroll under. */}
176
- <Box
177
- sx={{
178
- position: "sticky",
179
- top: 0,
180
- zIndex: 2,
181
- bgcolor: "background.default",
182
- }}
183
- >
184
- <GivensPanel {...controls.panel} layout="bar" />
185
- </Box>
234
+ {/* Sticky so the controls stay in reach while the tiles scroll under.
235
+ Only when there are controls: GivensPanel draws nothing without
236
+ them, and an empty box would still cost the Stack a gap. */}
237
+ {specs.length > 0 && (
238
+ <Box
239
+ sx={{
240
+ position: "sticky",
241
+ top: 0,
242
+ zIndex: STICKY_CONTROLS_Z,
243
+ bgcolor: "background.default",
244
+ }}
245
+ >
246
+ <GivensPanel {...controls.panel} layout={controlsLayout} />
247
+ </Box>
248
+ )}
186
249
 
187
250
  {modelPath === undefined ? (
188
251
  <Alert severity="error">
@@ -213,6 +276,7 @@ export function DashboardView({
213
276
  tiles={tiles}
214
277
  columns={columns}
215
278
  minTilePx={MIN_TILE_PX}
279
+ rowGapPx={chrome === "none" ? NOTEBOOK_GAP_PX : GRID_GAP_PX}
216
280
  // Position too, not the expression alone: `tiles=[…]` can repeat
217
281
  // one, which is a typo rather than a request for two identical
218
282
  // panels, and keying on the expression made the duplicate warn
@@ -234,7 +298,8 @@ export function DashboardView({
234
298
  label={tile.label}
235
299
  subtitle={tile.subtitle}
236
300
  borderless={tile.borderless}
237
- givens={tileGivens}
301
+ givens={applied}
302
+ hostGivens={tileHostGivens}
238
303
  declaredTypes={declaredTypes}
239
304
  givenNames={tile.givenNames}
240
305
  height={height ?? TILE_MAX_HEIGHT}
@@ -245,13 +310,9 @@ export function DashboardView({
245
310
  tile.givenNames,
246
311
  specs,
247
312
  )}
248
- onExplore={() => {
249
- setExploring(tile.query);
250
- onEvent?.({
251
- type: "dashboard.explored",
252
- tile: tile.query ?? "",
253
- });
254
- }}
313
+ {...(preamble !== undefined
314
+ ? { preamble, restricted: tile.restricted }
315
+ : {})}
255
316
  />
256
317
  )
257
318
  }
@@ -264,37 +325,26 @@ export function DashboardView({
264
325
 
265
326
  {drillMenu}
266
327
  {modelPath !== undefined && (
267
- <>
268
- <RowsDialog
269
- request={rows}
270
- environmentName={environmentName}
271
- packageName={packageName}
272
- {...(versionId === undefined ? {} : { versionId })}
273
- modelPath={modelPath}
274
- givens={rowsGivens}
275
- onClose={() => setRows(undefined)}
276
- onDone={(ok, durationMs) => {
277
- if (rows)
278
- onEvent?.({
279
- type: "dashboard.rows_shown",
280
- source: rows.source,
281
- view: rows.view,
282
- field: rows.field,
283
- ok,
284
- durationMs,
285
- });
286
- }}
287
- />
288
- <ExploreDialog
289
- tile={exploring}
290
- environmentName={environmentName}
291
- packageName={packageName}
292
- {...(versionId === undefined ? {} : { versionId })}
293
- modelPath={modelPath}
294
- givens={exploreGivens}
295
- onClose={() => setExploring(undefined)}
296
- />
297
- </>
328
+ <RowsDialog
329
+ request={rows}
330
+ environmentName={environmentName}
331
+ packageName={packageName}
332
+ {...(versionId === undefined ? {} : { versionId })}
333
+ modelPath={modelPath}
334
+ givens={rowsGivens}
335
+ onClose={() => setRows(undefined)}
336
+ onDone={(ok, durationMs) => {
337
+ if (rows)
338
+ onEvent?.({
339
+ type: "dashboard.rows_shown",
340
+ source: rows.source,
341
+ view: rows.view,
342
+ field: rows.field,
343
+ ok,
344
+ durationMs,
345
+ });
346
+ }}
347
+ />
298
348
  )}
299
349
  </Stack>
300
350
  );
@@ -309,7 +359,7 @@ function TextTile({
309
359
  chrome: TileChrome;
310
360
  }) {
311
361
  return (
312
- <TileCard chrome={chrome}>
362
+ <TileCard chrome={chrome} kind="text">
313
363
  <Prose variant="document">{markdown}</Prose>
314
364
  </TileCard>
315
365
  );
@@ -319,9 +369,19 @@ function TextTile({
319
369
  * The dashboard's prose header: its title, and the description as MARKDOWN
320
370
  * (Malloy carries a `##"` block through with its newlines intact).
321
371
  */
322
- function DashboardHeader({ manifest }: { manifest: DashboardManifest }) {
372
+ function DashboardHeader({
373
+ manifest,
374
+ chrome,
375
+ }: {
376
+ manifest: DashboardManifest;
377
+ chrome: TileChrome;
378
+ }) {
323
379
  return (
324
380
  <DashboardProse
381
+ // The description follows the text-tile rule: drawn in the same chrome
382
+ // the document's text tiles take, so a dashboard boxes it as it boxes
383
+ // a text tile, and a notebook (which passes `none`) leaves it bare.
384
+ chrome={chrome}
325
385
  title={manifest.title ?? manifest.name}
326
386
  {...(manifest.description
327
387
  ? { description: manifest.description }
@@ -333,20 +393,36 @@ function DashboardHeader({ manifest }: { manifest: DashboardManifest }) {
333
393
  /**
334
394
  * The prose header over just the two fields it needs, so the BUILDER can draw
335
395
  * the same header over a `DashboardDocument`, which is not a manifest.
396
+ *
397
+ * The description is drawn as a text tile is, in the document's own tile
398
+ * chrome: the same box and the same type as the markdown between the tiles,
399
+ * so the page's prose reads as one kind of thing wherever it sits.
336
400
  */
337
401
  export function DashboardProse({
338
402
  title,
339
403
  description,
404
+ chrome = "card",
340
405
  }: {
341
406
  title: string;
342
407
  description?: string;
408
+ /** The chrome the document's tiles take, which the description matches. */
409
+ chrome?: TileChrome;
343
410
  }) {
344
411
  return (
345
- <Box>
346
- <Typography variant="h5" sx={{ fontWeight: 600 }}>
347
- {title}
348
- </Typography>
349
- {description && <Prose variant="caption">{description}</Prose>}
350
- </Box>
412
+ <Stack sx={{ gap: 2 }}>
413
+ {/* No explicit weight: the host theme's h5 weight applies. */}
414
+ <Typography variant="h5">{title}</Typography>
415
+ {description && (
416
+ <Box
417
+ sx={
418
+ chrome === "none"
419
+ ? { my: `${BARE_DESCRIPTION_MARGIN_PX}px` }
420
+ : undefined
421
+ }
422
+ >
423
+ <TextTile markdown={description} chrome={chrome} />
424
+ </Box>
425
+ )}
426
+ </Stack>
351
427
  );
352
428
  }
@@ -15,9 +15,10 @@ import {
15
15
  import { useEffect, useRef } from "react";
16
16
  import { useQueryResult } from "../../hooks/useQueryResult";
17
17
  import { malloyLiteral } from "../../utils/malloyLiteral";
18
- import { isIdentifier, tileSteps } from "../DashboardBuilder/malloyText";
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";
21
22
  import { now } from "../../utils/clock";
22
23
 
23
24
  /**
@@ -170,7 +171,7 @@ export function RowsDialog({
170
171
  sx={{
171
172
  mr: "auto",
172
173
  color: theme.tileTitle,
173
- fontFamily: "ui-monospace, monospace",
174
+ fontFamily: MONO_FONT_FAMILY,
174
175
  overflow: "hidden",
175
176
  textOverflow: "ellipsis",
176
177
  whiteSpace: "nowrap",
@@ -8,13 +8,21 @@ import {
8
8
  type SxProps,
9
9
  type Theme,
10
10
  } from "@mui/material";
11
- import type { ReactNode } from "react";
11
+ import type { ReactNode, Ref } from "react";
12
12
  import { DASHBOARD_CARD_PADDING_PX } from "../../theme/buildTableCssVars";
13
13
  import { usePublisherTheme } from "../../theme/ThemeContext";
14
14
 
15
15
  /** `card` is a dashboard tile's panel; `none` is a notebook's bare flow. */
16
16
  export type TileChrome = "card" | "none";
17
17
 
18
+ /**
19
+ * The least a carded tile is drawn at, by kind: a query tile holds a spinner
20
+ * and then a result, so it keeps room for one; a text tile holds a line or two
21
+ * of prose and is no taller than its text needs, past a floor that keeps a
22
+ * one-word tile from reading as a sliver. A bare (`none`) tile has no floor.
23
+ */
24
+ export const TILE_MIN_HEIGHT = { query: 120, text: 72 } as const;
25
+
18
26
  /**
19
27
  * The card a dashboard tile sits in, and nothing else — so the builder, which
20
28
  * draws a stand-in tile when it has no server to run one, draws the same card
@@ -46,19 +54,26 @@ export type TileChrome = "card" | "none";
46
54
  export function TileCard({
47
55
  borderless = false,
48
56
  chrome = "card",
57
+ kind = "query",
49
58
  sx,
59
+ cardRef,
50
60
  children,
51
61
  }: {
52
62
  borderless?: boolean;
63
+ /** What the tile holds, which sets its {@link TILE_MIN_HEIGHT}. */
64
+ kind?: keyof typeof TILE_MIN_HEIGHT;
53
65
  /** `none` drops the card entirely, for a document that reads top to bottom. */
54
66
  chrome?: TileChrome;
55
67
  sx?: SxProps<Theme>;
68
+ /** The card's element, for a caller that watches where it is on the page. */
69
+ cardRef?: Ref<HTMLDivElement>;
56
70
  children: ReactNode;
57
71
  }) {
58
72
  const { theme } = usePublisherTheme();
59
73
  const bare = borderless || chrome === "none";
60
74
  return (
61
75
  <Paper
76
+ ref={cardRef}
62
77
  elevation={0}
63
78
  data-chrome={chrome}
64
79
  sx={[
@@ -71,7 +86,7 @@ export function TileCard({
71
86
  display: "flex",
72
87
  flexDirection: "column",
73
88
  minWidth: 0,
74
- minHeight: chrome === "none" ? 0 : 120,
89
+ minHeight: chrome === "none" ? 0 : TILE_MIN_HEIGHT[kind],
75
90
  p:
76
91
  chrome === "none"
77
92
  ? 0