@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
@@ -18,6 +18,8 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
18
18
  import { Database, type AgentSummary } from "../../client";
19
19
  import { useNarrowScreen } from "../../hooks/useNarrowScreen";
20
20
  import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
21
+ import { AddButton } from "../buttons";
22
+ import { PackageProblems } from "./PackageProblems";
21
23
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
22
24
  import { Loading } from "../Loading";
23
25
  import { chooseWorkspace } from "../ReportBuilder/documentSession";
@@ -362,6 +364,8 @@ export default function Package({
362
364
  )}
363
365
  </Box>
364
366
 
367
+ <PackageProblems warnings={pkgQuery.data?.data?.warnings} />
368
+
365
369
  {isLoading && <Loading text="Loading package..." />}
366
370
 
367
371
  {createTarget && (
@@ -438,14 +442,13 @@ export default function Package({
438
442
  count={artifacts.length}
439
443
  {...(canNew
440
444
  ? {
445
+ // The section heading's add button, as every
446
+ // other section's: "+ Report".
441
447
  action: (
442
- <Button
443
- variant="outlined"
444
- size="small"
448
+ <AddButton
449
+ label="Report"
445
450
  onClick={() => setCreating(true)}
446
- >
447
- New report
448
- </Button>
451
+ />
449
452
  ),
450
453
  }
451
454
  : {})}
@@ -456,7 +459,7 @@ export default function Package({
456
459
  {...(canNew
457
460
  ? {
458
461
  action: {
459
- label: "New report",
462
+ label: "Add report",
460
463
  onClick: () => setCreating(true),
461
464
  },
462
465
  }
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { describe, expect, it } from "bun:test";
5
+ import { fireEvent, render, screen } from "@testing-library/react";
6
+ import { PackageProblems } from "./PackageProblems";
7
+
8
+ const KIND_REMOVED = {
9
+ model: "notebooks/overview.malloy",
10
+ code: "report-kind-removed",
11
+ severity: "error" as const,
12
+ message:
13
+ "Line 11: `kind=notebook` is no longer read, so this file is not a report.",
14
+ };
15
+ const NOTE = {
16
+ model: "old.malloynb",
17
+ code: "deprecated-malloynb-notebook",
18
+ severity: "warn" as const,
19
+ message: "A .malloynb notebook is deprecated.",
20
+ };
21
+
22
+ describe("PackageProblems", () => {
23
+ it("draws nothing for a clean package", () => {
24
+ const { container } = render(<PackageProblems warnings={undefined} />);
25
+ expect(container.textContent).toBe("");
26
+ });
27
+
28
+ it("says why a file is not a report, naming the file", () => {
29
+ render(<PackageProblems warnings={[KIND_REMOVED]} />);
30
+ expect(screen.getByText("1 problem in this package")).toBeDefined();
31
+ expect(screen.getByText("notebooks/overview.malloy")).toBeDefined();
32
+ expect(screen.getByText(/is no longer read/)).toBeDefined();
33
+ });
34
+
35
+ it("folds warn-level findings away until asked", () => {
36
+ render(<PackageProblems warnings={[KIND_REMOVED, NOTE]} />);
37
+ expect(screen.queryByText(/is deprecated/)).toBeNull();
38
+ fireEvent.click(screen.getByRole("button", { name: "Show 1 note" }));
39
+ expect(screen.getByText(/is deprecated/)).toBeDefined();
40
+ });
41
+ });
@@ -0,0 +1,95 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import {
5
+ Alert,
6
+ AlertTitle,
7
+ Box,
8
+ Button,
9
+ Stack,
10
+ Typography,
11
+ } from "@mui/material";
12
+ import { useState } from "react";
13
+ import type { PackageWarningsInner } from "../../client";
14
+ import { MONO_FONT_FAMILY } from "../styles";
15
+
16
+ /**
17
+ * What the server found wrong with a package when it loaded it, on the
18
+ * package page.
19
+ *
20
+ * Without it a broken file simply moved: a report whose artifact tag the
21
+ * server no longer reads stopped listing under Reports and listed under
22
+ * Models instead, with nothing on the page saying why. Errors (a file that
23
+ * should have been a report and is not, a tile that cannot load) are shown;
24
+ * `warn` findings, which still work, are counted and folded away.
25
+ */
26
+ export function PackageProblems({
27
+ warnings,
28
+ }: {
29
+ warnings: PackageWarningsInner[] | undefined;
30
+ }) {
31
+ const [showNotes, setShowNotes] = useState(false);
32
+ const errors = (warnings ?? []).filter((w) => w.severity === "error");
33
+ const notes = (warnings ?? []).filter((w) => w.severity !== "error");
34
+ if (errors.length === 0 && notes.length === 0) return null;
35
+ return (
36
+ <Stack sx={{ gap: 1, mb: 4 }}>
37
+ {errors.length > 0 && (
38
+ <Alert severity="warning">
39
+ <AlertTitle>
40
+ {errors.length === 1
41
+ ? "1 problem in this package"
42
+ : `${errors.length} problems in this package`}
43
+ </AlertTitle>
44
+ <FindingList findings={errors} />
45
+ </Alert>
46
+ )}
47
+ {notes.length > 0 && (
48
+ <Box>
49
+ <Button
50
+ size="small"
51
+ aria-expanded={showNotes}
52
+ onClick={() => setShowNotes((open) => !open)}
53
+ sx={{ px: 0.5, color: "text.secondary" }}
54
+ >
55
+ {showNotes ? "Hide" : "Show"} {notes.length}{" "}
56
+ {notes.length === 1 ? "note" : "notes"}
57
+ </Button>
58
+ {showNotes && (
59
+ <Box sx={{ pl: 0.5, pt: 0.5 }}>
60
+ <FindingList findings={notes} />
61
+ </Box>
62
+ )}
63
+ </Box>
64
+ )}
65
+ </Stack>
66
+ );
67
+ }
68
+
69
+ function FindingList({ findings }: { findings: PackageWarningsInner[] }) {
70
+ return (
71
+ <Stack component="ul" sx={{ m: 0, p: 0, listStyle: "none", gap: 0.75 }}>
72
+ {findings.map((finding, index) => (
73
+ <Typography
74
+ component="li"
75
+ key={`${finding.model ?? ""}:${finding.code ?? ""}:${index}`}
76
+ variant="body2"
77
+ >
78
+ {finding.model && (
79
+ <Box
80
+ component="span"
81
+ sx={{
82
+ fontFamily: MONO_FONT_FAMILY,
83
+ fontSize: "0.85em",
84
+ mr: 1,
85
+ }}
86
+ >
87
+ {finding.model}
88
+ </Box>
89
+ )}
90
+ {finding.message}
91
+ </Typography>
92
+ ))}
93
+ </Stack>
94
+ );
95
+ }
@@ -5,8 +5,10 @@ import { Box, type SxProps, type Theme } from "@mui/material";
5
5
  import Markdown from "markdown-to-jsx";
6
6
  import type { ReactNode } from "react";
7
7
  import { usePublisherTheme } from "../theme/ThemeContext";
8
+ import type { ReportUi } from "../theme/ui";
8
9
  import type { NavigationClick } from "./click_helper";
9
- import { MONO_FONT_FAMILY } from "./styles";
10
+
11
+ import { PROSE_MAX_WIDTH } from "./controlTokens";
10
12
 
11
13
  /**
12
14
  * Markdown authored inside a package — a dashboard's `##"` description, a
@@ -119,7 +121,8 @@ function ProseLink({
119
121
  );
120
122
  }
121
123
 
122
- const STYLES: Record<ProseVariant, SxProps<Theme>> = {
124
+ /** Each variant's styles, set in the host's prose type (`ui.type.prose`). */
125
+ const stylesFor = (ui: ReportUi): Record<ProseVariant, SxProps<Theme>> => ({
123
126
  document: {
124
127
  // Flush at both ends, as a caption is: the space around a block of
125
128
  // prose is the layout's (the gap between tiles), not its first and last
@@ -136,11 +139,13 @@ const STYLES: Record<ProseVariant, SxProps<Theme>> = {
136
139
  "& h1": { fontSize: "28px" },
137
140
  "& h2": { fontSize: "24px" },
138
141
  "& h3": { fontSize: "20px" },
142
+ // A readable line rather than the grid's width: prose ran 180
143
+ // characters across a wide tile, too long to read.
139
144
  "& p, & ul, & ol": {
140
145
  color: "text.primary",
141
- lineHeight: 1.7,
146
+ ...ui.type.prose,
142
147
  mb: 1,
143
- fontSize: "16px",
148
+ maxWidth: PROSE_MAX_WIDTH,
144
149
  },
145
150
  "& li": { mb: 0.5 },
146
151
  },
@@ -161,9 +166,9 @@ const STYLES: Record<ProseVariant, SxProps<Theme>> = {
161
166
  },
162
167
  "& p": { m: "0.5em 0" },
163
168
  "& ul, & ol": { m: "0.5em 0", pl: 3 },
164
- "& code": { fontFamily: MONO_FONT_FAMILY, fontSize: "0.9em" },
169
+ "& code": { fontFamily: ui.font.mono, fontSize: "0.9em" },
165
170
  },
166
- };
171
+ });
167
172
 
168
173
  function ProseImageAlt({ alt }: { alt?: string }) {
169
174
  return <>{alt}</>;
@@ -181,7 +186,7 @@ export function Prose({
181
186
  return (
182
187
  <Box
183
188
  sx={[
184
- STYLES[variant],
189
+ stylesFor(theme.ui)[variant],
185
190
  // After the variant: `caption`'s `typography: body2` sets a face too.
186
191
  { fontFamily: theme.font.family },
187
192
  ...(Array.isArray(sx) ? sx : [sx]),
@@ -0,0 +1,94 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import CloseIcon from "@mui/icons-material/Close";
5
+ import { IconButton, Tooltip } from "@mui/material";
6
+ import { MOTION_FAST, reducedMotionSx } from "../theme/motion";
7
+ import { usePublisherTheme } from "../theme/ThemeContext";
8
+ import { edgeColor, hoverEdgeColor } from "./controlTokens";
9
+
10
+ /**
11
+ * The class on a remove badge. Its container shows it while hovered or
12
+ * focused: `"& .remove-badge": { opacity: 0 }` and
13
+ * `"&:hover .remove-badge, &:focus-within .remove-badge": { opacity: 1 }`,
14
+ * as {@link removeBadgeRevealSx} writes.
15
+ */
16
+ export const REMOVE_BADGE_CLASS = "remove-badge";
17
+
18
+ /** The container rules that reveal its remove badge on hover and focus, and always on touch. */
19
+ export const removeBadgeRevealSx = {
20
+ [`& .${REMOVE_BADGE_CLASS}`]: { opacity: 0 },
21
+ [`&:hover .${REMOVE_BADGE_CLASS}, &:focus-within .${REMOVE_BADGE_CLASS}`]: {
22
+ opacity: 1,
23
+ },
24
+ "@media (hover: none)": {
25
+ [`& .${REMOVE_BADGE_CLASS}`]: { opacity: 1 },
26
+ },
27
+ } as const;
28
+
29
+ /**
30
+ * Take something off the page: a small round × on its top-right corner. The
31
+ * one removal control in the builder, for a filter and a tile alike, so
32
+ * removing looks and works the same wherever it is. The container must be
33
+ * `position: relative` and spread {@link removeBadgeRevealSx}.
34
+ *
35
+ * With `disabledReason`, the badge stays focusable (aria-disabled, not
36
+ * disabled) and says why on hover and to a screen reader, rather than
37
+ * vanishing or greying out without explanation.
38
+ */
39
+ export function RemoveBadge({
40
+ label,
41
+ onRemove,
42
+ disabledReason,
43
+ /** How far outside the container's edge the badge's centre sits, in px. */
44
+ inset = 0,
45
+ }: {
46
+ /** The accessible name: "Remove filter BRAND", "Remove Revenue by month". */
47
+ label: string;
48
+ onRemove: () => void;
49
+ disabledReason?: string;
50
+ inset?: number;
51
+ }) {
52
+ const { theme } = usePublisherTheme();
53
+ const disabled = disabledReason !== undefined;
54
+ const badge = (
55
+ <IconButton
56
+ className={REMOVE_BADGE_CLASS}
57
+ aria-label={label}
58
+ aria-disabled={disabled || undefined}
59
+ {...(disabled ? { "aria-description": disabledReason } : {})}
60
+ onClick={(event) => {
61
+ // Never also the tile's or filter's own press.
62
+ event.stopPropagation();
63
+ if (!disabled) onRemove();
64
+ }}
65
+ onPointerDown={(event) => event.stopPropagation()}
66
+ sx={(mui) => ({
67
+ position: "absolute",
68
+ top: -8 - inset,
69
+ right: -8 - inset,
70
+ zIndex: 3,
71
+ width: 18,
72
+ height: 18,
73
+ p: 0,
74
+ borderRadius: "50%",
75
+ border: `1px solid ${edgeColor(theme.cardBorder)}`,
76
+ bgcolor: mui.palette.background.paper,
77
+ color: mui.palette.text.secondary,
78
+ cursor: disabled ? "default" : "pointer",
79
+ transition: `opacity ${MOTION_FAST}`,
80
+ ...reducedMotionSx,
81
+ "&:hover": {
82
+ bgcolor: mui.palette.background.paper,
83
+ color: disabled
84
+ ? mui.palette.text.secondary
85
+ : mui.palette.text.primary,
86
+ borderColor: hoverEdgeColor(theme.cardBorder, theme.tileTitle),
87
+ },
88
+ })}
89
+ >
90
+ <CloseIcon sx={{ fontSize: 12 }} />
91
+ </IconButton>
92
+ );
93
+ return disabled ? <Tooltip title={disabledReason}>{badge}</Tooltip> : badge;
94
+ }
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { Box, useTheme } from "@mui/material";
4
+ import { Box } from "@mui/material";
5
5
  import React, {
6
6
  Suspense,
7
7
  useCallback,
@@ -443,18 +443,14 @@ function RenderedResultInner({
443
443
  // bails, so overlapping renders can't leave two charts or leak a viz.
444
444
  const renderGenRef = useRef(0);
445
445
  const { theme: baseTheme, layers, mode } = usePublisherTheme();
446
- // The host app's card radius, so a dashboard card reads as a card of the app
447
- // it is embedded in rather than as the renderer's 8px on a 4px page. Both
448
- // cards take it from here; see DashboardTile, which is the other one.
449
- const cardRadius = useTheme().shape.borderRadius;
450
- // Memoized because it is a dependency of the render effect below, and a fresh
451
- // object each render would re-render the chart on every render.
446
+ // The report surfaces' tile radius, the one TileCard draws the composite
447
+ // tile with, so the renderer's own cards and ours are the same shape.
452
448
  const cardGeometry = useMemo<DashboardCardGeometry>(
453
449
  () => ({
454
- radius: `${cardRadius}px`,
450
+ radius: baseTheme.ui.radius.tile,
455
451
  padding: `${DASHBOARD_CARD_PADDING_PX}px`,
456
452
  }),
457
- [cardRadius],
453
+ [baseTheme.ui.radius.tile],
458
454
  );
459
455
 
460
456
  // Dispose the last live viz on unmount only. Deliberately NOT done in the
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { Box } from "@mui/material";
4
+ import { Box, LinearProgress } from "@mui/material";
5
5
  import { useEffect, useMemo } from "react";
6
6
  import type { QueryResultState } from "../../hooks/useQueryResult";
7
7
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
@@ -50,7 +50,8 @@ export function ResultPanel({
50
50
  fill,
51
51
  transform,
52
52
  }: ResultPanelProps) {
53
- const { data, isSuccess, isError, error, fetchStatus } = state;
53
+ const { data, isSuccess, isError, error, fetchStatus, isPlaceholderData } =
54
+ state;
54
55
  // Fetch the renderer while the query runs, so the first chart does not wait
55
56
  // on it after the rows arrive. Not before: a tile still waiting to scroll
56
57
  // into view has asked for nothing, and neither should its renderer.
@@ -79,7 +80,7 @@ export function ResultPanel({
79
80
  text={fetchStatus === "idle" ? LOADING_COPY.loading : loadingText}
80
81
  />
81
82
  );
82
- return (
83
+ const shown = (
83
84
  <ResultContainer
84
85
  result={result}
85
86
  maxHeight={maxHeight}
@@ -89,4 +90,59 @@ export function ResultPanel({
89
90
  fill={fill}
90
91
  />
91
92
  );
93
+ // The previous answer, while the new one runs: it stays where it is, eased
94
+ // back after a beat so a quick run never flickers, with a thin bar along
95
+ // the top saying work is under way, and is replaced in place when the rows
96
+ // land. The wrapper is always there, so going stale and back never moves
97
+ // the result in the tree, which would remount (and redraw) the chart.
98
+ return (
99
+ <Box
100
+ aria-busy={isPlaceholderData || undefined}
101
+ sx={{
102
+ position: "relative",
103
+ // Both layers pass the parent's flex column through: the result
104
+ // sizes itself as a flex child (a basis from its own height, or the
105
+ // cell's height under `fill`), and an ordinary block between it and
106
+ // its parent left it zero tall.
107
+ display: "flex",
108
+ flexDirection: "column",
109
+ flex: "1 1 auto",
110
+ minHeight: 0,
111
+ minWidth: 0,
112
+ ...(fill ? { height: "100%" } : {}),
113
+ "& > .result-body": {
114
+ display: "flex",
115
+ flexDirection: "column",
116
+ flex: "1 1 auto",
117
+ minHeight: 0,
118
+ minWidth: 0,
119
+ ...(fill ? { height: "100%" } : {}),
120
+ opacity: isPlaceholderData ? 0.55 : 1,
121
+ transition: isPlaceholderData
122
+ ? "opacity 160ms ease 200ms"
123
+ : "opacity 120ms ease",
124
+ "@media (prefers-reduced-motion: reduce)": {
125
+ transition: "none",
126
+ },
127
+ },
128
+ }}
129
+ >
130
+ {isPlaceholderData && (
131
+ <LinearProgress
132
+ aria-label={loadingText}
133
+ sx={{
134
+ position: "absolute",
135
+ top: 0,
136
+ left: 0,
137
+ right: 0,
138
+ height: 2,
139
+ zIndex: 1,
140
+ bgcolor: "transparent",
141
+ borderRadius: 1,
142
+ }}
143
+ />
144
+ )}
145
+ <Box className="result-body">{shown}</Box>
146
+ </Box>
147
+ );
92
148
  }
@@ -18,6 +18,7 @@ import {
18
18
  serverWrapper,
19
19
  } from "../../../test/serverProvider";
20
20
  import type { ReportManifest } from "../../client";
21
+ import { globalQueryClient } from "../../utils/queryClient";
21
22
 
22
23
  let manifest = {} as ReportManifest;
23
24
  const getReport = mock(
@@ -116,6 +117,44 @@ describe("the manifest fetch", () => {
116
117
  ]);
117
118
  });
118
119
 
120
+ it("asks again on every mount unless the host says otherwise", async () => {
121
+ manifest = { ...TILES, layout: "grid" };
122
+ const first = render(
123
+ <Report resourceUri={URI} path="sales/q3.malloy" />,
124
+ {
125
+ wrapper: serverWrapper,
126
+ },
127
+ );
128
+ await waitFor(() => expect(getReport).toHaveBeenCalledTimes(1));
129
+ first.unmount();
130
+ render(<Report resourceUri={URI} path="sales/q3.malloy" />, {
131
+ wrapper: serverWrapper,
132
+ });
133
+ await waitFor(() => expect(getReport).toHaveBeenCalledTimes(2));
134
+ });
135
+
136
+ it("leaves the read's staleness to the host's default for the report key", async () => {
137
+ // A host that reads the manifest itself first, then mounts the report
138
+ // over the same entry, keeps that entry fresh with one default.
139
+ globalQueryClient.setQueryDefaults(["report"], { staleTime: Infinity });
140
+ try {
141
+ manifest = { ...TILES, layout: "grid" };
142
+ const first = render(
143
+ <Report resourceUri={URI} path="sales/q3.malloy" />,
144
+ { wrapper: serverWrapper },
145
+ );
146
+ await waitFor(() => expect(getReport).toHaveBeenCalledTimes(1));
147
+ first.unmount();
148
+ render(<Report resourceUri={URI} path="sales/q3.malloy" />, {
149
+ wrapper: serverWrapper,
150
+ });
151
+ await screen.findAllByText("Third quarter");
152
+ expect(getReport).toHaveBeenCalledTimes(1);
153
+ } finally {
154
+ globalQueryClient.setQueryDefaults(["report"], {});
155
+ }
156
+ });
157
+
119
158
  it("says so, rather than throwing, for a URI that names no package", () => {
120
159
  render(
121
160
  <Report resourceUri="publisher://environments/env" path="x.malloy" />,
@@ -146,7 +185,7 @@ describe("rendering by layout", () => {
146
185
  expect(container.querySelector('[data-chrome="none"]')).toBeNull();
147
186
  });
148
187
 
149
- it("draws a linear report's tiles bare, top to bottom", async () => {
188
+ it("draws a linear report's query tiles in cards, as a grid does", async () => {
150
189
  manifest = { ...TILES, layout: "linear" };
151
190
  const { container } = render(
152
191
  <Report resourceUri={URI} path="sales/q3.malloy" />,
@@ -157,53 +196,32 @@ describe("rendering by layout", () => {
157
196
  await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
158
197
  expect(executeQueryModel.mock.calls[0][2]).toBe("sales/q3.malloy");
159
198
  await waitFor(() =>
160
- expect(container.querySelector('[data-chrome="none"]')).not.toBeNull(),
199
+ expect(container.querySelector('[data-chrome="card"]')).not.toBeNull(),
161
200
  );
162
- expect(container.querySelector('[data-chrome="card"]')).toBeNull();
163
201
  });
164
202
 
165
- it("runs a .malloy run:-cell report's cells through the query endpoint, against the report itself", async () => {
203
+ it("runs no cells: a manifest carrying `run:` cells draws no cells", async () => {
166
204
  manifest = {
167
205
  path: "review.malloy",
168
206
  name: "review",
169
207
  layout: "linear",
208
+ title: "Review",
170
209
  editable: false,
171
210
  notebook: {
172
211
  format: "malloy",
173
212
  notebookCells: [
174
213
  { type: "markdown", kind: "markdown", text: "Cell prose" },
175
- {
176
- type: "code",
177
- kind: "query",
178
- text: "run: orders -> by_month",
179
- },
214
+ { type: "code", kind: "query", text: "run: orders -> by_month" },
180
215
  ],
181
216
  },
182
217
  } as ReportManifest;
183
- render(
184
- <Report resourceUri={`${URI}?versionId=v4`} path="review.malloy" />,
185
- {
186
- wrapper: serverWrapper,
187
- },
188
- );
218
+ render(<Report resourceUri={URI} path="review.malloy" />, {
219
+ wrapper: serverWrapper,
220
+ });
189
221
 
190
- expect(await screen.findByText("Cell prose")).toBeTruthy();
191
- await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
192
- // The report's path is the model and the cell's text the query, the
193
- // governed path every grid tile takes.
194
- expect(
195
- executeQueryModel.mock.calls.map((call) => call.slice(0, 4)),
196
- ).toEqual([
197
- [
198
- "env",
199
- "pkg",
200
- "review.malloy",
201
- { query: "run: orders -> by_month", givens: {}, versionId: "v4" },
202
- ],
203
- ]);
204
- expect(executeNotebookCell).not.toHaveBeenCalled();
205
- // The cells came with the manifest; nothing reads them again.
206
- expect(getNotebook).not.toHaveBeenCalled();
222
+ expect(await screen.findByText("Review")).toBeTruthy();
223
+ expect(screen.queryByText("Cell prose")).toBeNull();
224
+ expect(executeQueryModel).not.toHaveBeenCalled();
207
225
  });
208
226
 
209
227
  // DEPRECATED FEATURE COVERAGE — delete together with
@@ -136,22 +136,6 @@ describe("opening a report", () => {
136
136
  });
137
137
  });
138
138
 
139
- it("reports a run:-cell report's open as linear, counting its cells", async () => {
140
- manifest = CELLS;
141
- const onEvent = mock((_event: ReportEvent) => {});
142
- render(
143
- <Report resourceUri={URI} path="review.malloy" onEvent={onEvent} />,
144
- { wrapper: serverWrapper },
145
- );
146
- expect(await screen.findByText("Cell prose")).toBeTruthy();
147
- expect(onEvent.mock.calls[0][0]).toMatchObject({
148
- type: "report.opened",
149
- path: "review.malloy",
150
- layout: "linear",
151
- tiles: 2,
152
- });
153
- });
154
-
155
139
  it("reports a failed read as load_failed with a category, never the message, and no open", async () => {
156
140
  reportFailure = Object.assign(
157
141
  new Error("no such report: secret.malloy"),
@@ -260,33 +244,4 @@ describe("a failed query", () => {
260
244
  },
261
245
  ]);
262
246
  });
263
-
264
- it("reports a cell's failure to the host instead of the console", async () => {
265
- manifest = CELLS;
266
- queryFailure = { response: { status: 403 } };
267
- const onEvent = mock((_event: ReportEvent) => {});
268
- render(
269
- <Report resourceUri={URI} path="review.malloy" onEvent={onEvent} />,
270
- { wrapper: serverWrapper },
271
- );
272
- await waitFor(() =>
273
- expect(typesOf(onEvent.mock.calls)).toContain("report.query_failed"),
274
- );
275
- expect(
276
- onEvent.mock.calls
277
- .map(([event]) => event)
278
- .find((event) => event.type === "report.query_failed"),
279
- ).toMatchObject({ tile: 1, category: "forbidden", layout: "linear" });
280
- expect(errorSpy).not.toHaveBeenCalled();
281
- });
282
-
283
- it("logs a cell's failure to the console when no host listens", async () => {
284
- manifest = CELLS;
285
- queryFailure = { response: { status: 500 } };
286
- render(<Report resourceUri={URI} path="review.malloy" />, {
287
- wrapper: serverWrapper,
288
- });
289
- await waitFor(() => expect(errorSpy).toHaveBeenCalled());
290
- expect(String(errorSpy.mock.calls[0][0])).toContain("cell 1");
291
- });
292
247
  });