@malloy-publisher/sdk 0.9.9 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/dist/RenderedResult-BlNoIiSi.cjs.js +153 -0
  2. package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
  3. package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
  4. package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
  5. package/dist/builder/index.cjs.js +78 -130
  6. package/dist/builder/index.es.js +7440 -6727
  7. package/dist/builder-entry.d.ts +3 -0
  8. package/dist/client/api.d.ts +26 -22
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +1 -1
  11. package/dist/components/AppDialog.d.ts +9 -1
  12. package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
  13. package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
  14. package/dist/components/Dashboard/DashboardView.d.ts +22 -23
  15. package/dist/components/Dashboard/TileCard.d.ts +10 -3
  16. package/dist/components/Dashboard/useStuck.d.ts +22 -0
  17. package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
  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 -6
  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 +19 -11
  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 +8324 -7769
  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-1dgF5CC9.es.js → useCompiledDocument-7j5cBjQd.es.js} +8768 -7912
  92. package/dist/useCompiledDocument-B21sVbb4.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/Dashboard/DashboardGrid.tsx +39 -17
  97. package/src/components/Dashboard/DashboardTile.tsx +19 -2
  98. package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
  99. package/src/components/Dashboard/DashboardView.tsx +136 -105
  100. package/src/components/Dashboard/RowsDialog.tsx +1 -2
  101. package/src/components/Dashboard/TileCard.tsx +28 -10
  102. package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
  103. package/src/components/Dashboard/useStuck.ts +49 -0
  104. package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
  105. package/src/components/DocumentCreate/newNotebook.ts +26 -12
  106. package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
  107. package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
  108. package/src/components/Package/NewDocumentDialog.tsx +383 -119
  109. package/src/components/Package/Package.artifacts.spec.tsx +1 -1
  110. package/src/components/Package/Package.create.spec.tsx +7 -6
  111. package/src/components/Package/Package.tsx +10 -7
  112. package/src/components/Package/PackageProblems.spec.tsx +41 -0
  113. package/src/components/Package/PackageProblems.tsx +95 -0
  114. package/src/components/Prose.tsx +12 -7
  115. package/src/components/RemoveBadge.tsx +94 -0
  116. package/src/components/RenderedResult/RenderedResult.tsx +5 -9
  117. package/src/components/RenderedResult/ResultPanel.tsx +59 -3
  118. package/src/components/Report/Report.spec.tsx +50 -32
  119. package/src/components/Report/Report.telemetry.spec.tsx +0 -45
  120. package/src/components/Report/Report.tsx +45 -77
  121. package/src/components/Report/ReportPage.tsx +168 -0
  122. package/src/components/Report/layoutRules.spec.ts +35 -0
  123. package/src/components/Report/layoutRules.ts +55 -0
  124. package/src/components/Report/reportQuery.ts +53 -0
  125. package/src/components/Report/telemetry.ts +0 -2
  126. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
  127. package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
  128. package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
  129. package/src/components/ReportBuilder/BuilderDialogs.tsx +30 -39
  130. package/src/components/ReportBuilder/BuilderGrid.tsx +43 -31
  131. package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
  132. package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
  133. package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
  134. package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
  135. package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
  136. package/src/components/ReportBuilder/FilterStrip.tsx +129 -150
  137. package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
  138. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
  139. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
  140. package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
  141. package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -16
  142. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
  143. package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
  144. package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
  145. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +41 -36
  146. package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
  147. package/src/components/ReportBuilder/ReportBuilder.tsx +292 -116
  148. package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
  149. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
  150. package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
  151. package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
  152. package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
  153. package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
  154. package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
  155. package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
  156. package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
  157. package/src/components/ReportBuilder/TileFrame.tsx +212 -75
  158. package/src/components/ReportBuilder/TileMenu.tsx +248 -142
  159. package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
  160. package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
  161. package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
  162. package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
  163. package/src/components/ReportBuilder/builderControls.ts +164 -0
  164. package/src/components/ReportBuilder/builderReport.ts +1 -2
  165. package/src/components/ReportBuilder/catalog.ts +10 -26
  166. package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
  167. package/src/components/ReportBuilder/localGiven.ts +56 -0
  168. package/src/components/ReportBuilder/newDashboard.spec.ts +2 -3
  169. package/src/components/ReportBuilder/preview.spec.ts +125 -5
  170. package/src/components/ReportBuilder/preview.ts +60 -44
  171. package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
  172. package/src/components/ReportBuilder/readDocument.ts +14 -11
  173. package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
  174. package/src/components/ReportBuilder/readForEditor.ts +4 -26
  175. package/src/components/ReportBuilder/reportTag.ts +28 -7
  176. package/src/components/ReportBuilder/sortable.tsx +15 -7
  177. package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
  178. package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
  179. package/src/components/ReportBuilder/testing/inline.ts +25 -5
  180. package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
  181. package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
  182. package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
  183. package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
  184. package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
  185. package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
  186. package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
  187. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
  188. package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
  189. package/src/components/ReportBuilder/useExitGuard.ts +16 -0
  190. package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
  191. package/src/components/ReportBuilder/useFilterForm.ts +5 -1
  192. package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
  193. package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
  194. package/src/components/ReportBuilder/useReportDraft.ts +292 -0
  195. package/src/components/ReportBuilder/useReportEditor.ts +3 -12
  196. package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
  197. package/src/components/ReportBuilder/useTileEditing.ts +43 -12
  198. package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
  199. package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
  200. package/src/components/ReportBuilder/widthLabel.ts +26 -0
  201. package/src/components/ServerProvider.tsx +11 -0
  202. package/src/components/controlTokens.ts +47 -0
  203. package/src/components/drill/markDrillableCells.ts +2 -1
  204. package/src/components/given/FilterButton.spec.tsx +143 -0
  205. package/src/components/given/FilterButton.tsx +478 -0
  206. package/src/components/given/GivenInput.spec.tsx +47 -0
  207. package/src/components/given/GivenInput.tsx +20 -2
  208. package/src/components/given/GivensPanel.spec.tsx +11 -3
  209. package/src/components/given/GivensPanel.tsx +45 -44
  210. package/src/components/given/filterEditing.ts +60 -0
  211. package/src/components/given/filterSummary.spec.ts +108 -0
  212. package/src/components/given/filterSummary.ts +109 -0
  213. package/src/components/given/paramCodec.ts +1 -1
  214. package/src/components/given/required.spec.ts +60 -0
  215. package/src/components/given/required.ts +78 -0
  216. package/src/components/index.ts +9 -0
  217. package/src/components/legacy/Dashboard.spec.tsx +3 -1
  218. package/src/components/legacy/index.ts +1 -1
  219. package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
  220. package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
  221. package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
  222. package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
  223. package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
  224. package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
  225. package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
  226. package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
  227. package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
  228. package/src/components/legacy/malloynb/cellKind.ts +24 -0
  229. package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
  230. package/src/components/styles.ts +0 -18
  231. package/src/hooks/useGivensState.ts +7 -3
  232. package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
  233. package/src/hooks/useQueryResult.ts +26 -1
  234. package/src/theme/ThemeContext.tsx +21 -1
  235. package/src/theme/classes.ts +52 -0
  236. package/src/theme/index.ts +8 -0
  237. package/src/theme/resolveTheme.ts +3 -0
  238. package/src/theme/types.ts +7 -0
  239. package/src/theme/ui.spec.tsx +91 -0
  240. package/src/theme/ui.ts +115 -0
  241. package/dist/RenderedResult-Bw7EQc42.cjs.js +0 -153
  242. package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
  243. package/dist/components/Notebook/cellKind.d.ts +0 -20
  244. package/dist/components/Report/LinearReport.d.ts +0 -18
  245. package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
  246. package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
  247. package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
  248. package/dist/useCompiledDocument-BKyRnXmA.cjs.js +0 -141
  249. package/src/components/Notebook/cellKind.spec.ts +0 -199
  250. package/src/components/Notebook/cellKind.ts +0 -74
  251. package/src/components/Report/LinearReport.tsx +0 -71
  252. package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
  253. package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
  254. package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
  255. package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
  256. package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
  257. package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
  258. package/src/components/legacy/Notebook.served.spec.tsx +0 -183
  259. /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
  260. /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
  261. /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
@@ -1,9 +1,9 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { parseResourceUri } from "../../utils/formatting";
5
- import type { CellReportProps } from "../Report/CellReport";
6
- import { LinearReport } from "../Report/LinearReport";
4
+ import { parseResourceUri } from "../../../utils/formatting";
5
+ import type { CellReportProps } from "./CellRunnerView";
6
+ import { DashboardView } from "../../Dashboard/DashboardView";
7
7
  import { MalloynbCells, useNotebookQuery } from "./MalloynbCells";
8
8
 
9
9
  type NotebookProps = CellReportProps;
@@ -22,20 +22,22 @@ type NotebookProps = CellReportProps;
22
22
  // Requires PackageProvider
23
23
  export default function Notebook(props: NotebookProps) {
24
24
  const { data: notebook } = useNotebookQuery(props.resourceUri);
25
- // A notebook written as a tile layout renders as a one-column grid.
25
+ // A notebook written as a tile layout is a linear report: the report view,
26
+ // in one column.
26
27
  if (notebook?.dashboard) {
27
28
  const { environmentName, packageName, versionId, modelPath } =
28
29
  parseResourceUri(props.resourceUri);
29
30
  return (
30
- <LinearReport
31
- manifest={notebook.dashboard}
31
+ <DashboardView
32
+ manifest={{ ...notebook.dashboard, layout: "linear" }}
32
33
  environmentName={environmentName}
33
34
  packageName={packageName}
34
35
  versionId={versionId}
35
36
  documentName={modelPath}
36
37
  givens={props.givens}
37
38
  onGivensChange={props.onGivensChange}
38
- onDrillNavigate={props.onDrillNavigate}
39
+ onNavigate={props.onDrillNavigate}
40
+ {...(props.onNavigate ? { onLinkNavigate: props.onNavigate } : {})}
39
41
  maxResultSize={props.maxResultSize}
40
42
  />
41
43
  );
@@ -1,8 +1,11 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import ChevronRightIcon from "@mui/icons-material/ChevronRight";
5
- import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
4
+ /**
5
+ * @deprecated `.malloynb` only; deleted with the format. One cell of a
6
+ * `.malloynb` notebook: prose, or code with its result in a report tile.
7
+ */
8
+
6
9
  import CodeIcon from "@mui/icons-material/Code";
7
10
  import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
8
11
  import SearchIcon from "@mui/icons-material/Search";
@@ -14,25 +17,26 @@ import {
14
17
  Snackbar,
15
18
  Stack,
16
19
  Tooltip,
17
- Typography,
18
20
  } from "@mui/material";
19
- import React, { useEffect, useId, useState } from "react";
20
- import type { Given } from "../../client";
21
- import { usePublisherTheme } from "../../theme/ThemeContext";
22
- import { parseResourceUri } from "../../utils/formatting";
23
- import { ErrorDetailAlert } from "../ApiErrorDisplay";
24
- import { AppDialog } from "../AppDialog";
25
- import { highlight } from "../highlighter";
26
- import { ModelExplorerDialog } from "../Model/ModelExplorerDialog";
27
- import { FloatingIconButton } from "../FloatingIconButton";
28
- import { Prose } from "../Prose";
29
- import type { NavigationClick } from "../click_helper";
30
- import { useDrill, type DrillNavigation } from "../drill";
31
- import ResultContainer from "../RenderedResult/ResultContainer";
32
- import { NOTEBOOK_CELL_MAX_HEIGHT } from "../RenderedResult/resultSizing";
33
- import ResultsDialog from "../ResultsDialog";
34
- import { CleanMetricCard, MONO_FONT_FAMILY } from "../styles";
35
- import { cellCaption, definitionSummary, stripProse } from "./cellKind";
21
+ import React, { useEffect, useState } from "react";
22
+ import type { Given } from "../../../client";
23
+ import { usePublisherTheme } from "../../../theme/ThemeContext";
24
+ import { parseResourceUri } from "../../../utils/formatting";
25
+ import { ErrorDetailAlert } from "../../ApiErrorDisplay";
26
+ import { AppDialog } from "../../AppDialog";
27
+ import { highlight } from "../../highlighter";
28
+ import { ModelExplorerDialog } from "../../Model/ModelExplorerDialog";
29
+ import { FloatingIconButton } from "../../FloatingIconButton";
30
+ import { Prose } from "../../Prose";
31
+ import type { NavigationClick } from "../../click_helper";
32
+ import { useDrill, type DrillNavigation } from "../../drill";
33
+ import ResultContainer from "../../RenderedResult/ResultContainer";
34
+ import { NOTEBOOK_CELL_MAX_HEIGHT } from "../../RenderedResult/resultSizing";
35
+ import ResultsDialog from "../../ResultsDialog";
36
+ import { CleanMetricCard, MONO_FONT_FAMILY } from "../../styles";
37
+ import { stripProse } from "./cellKind";
38
+ import { TileCard, TileHeading } from "../../Dashboard/TileCard";
39
+ import { TextTileFrame } from "../../Report/ReportPage";
36
40
  import { EnhancedNotebookCell } from "./types";
37
41
 
38
42
  interface NotebookCellProps {
@@ -111,8 +115,6 @@ export function NotebookCell({
111
115
  const [sourcesDialogOpen, setSourcesDialogOpen] =
112
116
  React.useState<boolean>(false);
113
117
 
114
- const [definitionOpen, setDefinitionOpen] = useState(false);
115
- const definitionRegionId = useId();
116
118
  const [copyMessage, setCopyMessage] = useState("");
117
119
 
118
120
  const { environmentName, packageName, modelPath } =
@@ -228,13 +230,6 @@ export function NotebookCell({
228
230
  });
229
231
  }, [cell, mode]);
230
232
 
231
- const caption = cell.kind === "query" ? cellCaption(cell) : undefined;
232
- const header = cell.markdown ? (
233
- <Prose variant="document" links={links}>
234
- {cell.markdown}
235
- </Prose>
236
- ) : null;
237
-
238
233
  const copyToClipboard = () => {
239
234
  const url = window.location.href;
240
235
  navigator.clipboard
@@ -281,7 +276,7 @@ export function NotebookCell({
281
276
  return (
282
277
  (cell.type === "markdown" && (
283
278
  <Box>
284
- <Box>
279
+ <TextTileFrame>
285
280
  {showCopyLink ? (
286
281
  <Stack
287
282
  direction="row"
@@ -312,65 +307,11 @@ export function NotebookCell({
312
307
  onClose={() => setCopyMessage("")}
313
308
  message={copyMessage}
314
309
  />
315
- </Box>
316
- </Box>
317
- )) ||
318
- (cell.kind === "definition" && (
319
- <Box>
320
- {header}
321
- <Box
322
- component="button"
323
- type="button"
324
- aria-expanded={definitionOpen}
325
- aria-controls={definitionRegionId}
326
- onClick={() => setDefinitionOpen((open) => !open)}
327
- sx={{
328
- display: "flex",
329
- alignItems: "center",
330
- gap: "4px",
331
- p: 0,
332
- border: 0,
333
- background: "none",
334
- cursor: "pointer",
335
- fontFamily: MONO_FONT_FAMILY,
336
- fontSize: "13px",
337
- color: "text.secondary",
338
- }}
339
- >
340
- {definitionOpen ? (
341
- <ExpandMoreIcon fontSize="small" />
342
- ) : (
343
- <ChevronRightIcon fontSize="small" />
344
- )}
345
- {definitionSummary(cell)}
346
- </Box>
347
- {definitionOpen && (
348
- <CleanMetricCard
349
- id={definitionRegionId}
350
- sx={{ mt: 1, padding: "12px 24px" }}
351
- >
352
- <pre
353
- className="code-display"
354
- style={{ margin: 0, overflow: "auto" }}
355
- dangerouslySetInnerHTML={{
356
- __html: highlightedMalloyCode ?? "",
357
- }}
358
- />
359
- </CleanMetricCard>
360
- )}
310
+ </TextTileFrame>
361
311
  </Box>
362
312
  )) ||
363
313
  (cell.type === "code" && (
364
314
  <Box>
365
- {header}
366
- {caption && (
367
- <Typography
368
- variant="body2"
369
- sx={{ color: "text.secondary", mb: 1 }}
370
- >
371
- {caption}
372
- </Typography>
373
- )}
374
315
  {cell.newSources && cell.newSources.length > 0 && (
375
316
  <Stack
376
317
  sx={{
@@ -453,16 +394,18 @@ export function NotebookCell({
453
394
  !cell.error &&
454
395
  !hasValidImport &&
455
396
  !(cell.newSources && cell.newSources.length > 0) && (
456
- <CleanMetricCard
457
- sx={{
458
- display: "flex",
459
- justifyContent: "center",
460
- alignItems: "center",
461
- minHeight: 200,
462
- }}
463
- >
464
- <CircularProgress size={32} />
465
- </CleanMetricCard>
397
+ <TileCard>
398
+ <Box
399
+ sx={{
400
+ display: "flex",
401
+ justifyContent: "center",
402
+ alignItems: "center",
403
+ minHeight: 200,
404
+ }}
405
+ >
406
+ <CircularProgress size={32} />
407
+ </Box>
408
+ </TileCard>
466
409
  )}
467
410
 
468
411
  {!cell.result && cell.error && (
@@ -480,62 +423,39 @@ export function NotebookCell({
480
423
  )}
481
424
 
482
425
  {cell.result && (
483
- <CleanMetricCard
484
- sx={{
485
- position: "relative",
486
- }}
487
- >
488
- <Box
489
- sx={{
490
- paddingTop: "24px",
491
- }}
492
- >
493
- <ResultContainer
494
- result={cell.result}
495
- maxHeight={NOTEBOOK_CELL_MAX_HEIGHT}
496
- maxResultSize={maxResultSize}
497
- drill={drill}
498
- />
499
- </Box>
426
+ // The tile a grid draws: the cell's own actions on the heading's
427
+ // row, then the result.
428
+ <TileCard>
429
+ <TileHeading
430
+ title=""
431
+ action={
432
+ <Stack direction="row" sx={{ gap: 0.5, mt: "-4px" }}>
433
+ <FloatingIconButton
434
+ aria-label="Malloy code"
435
+ onClick={(e) => {
436
+ e.stopPropagation();
437
+ setCodeDialogOpen(true);
438
+ }}
439
+ >
440
+ <CodeIcon />
441
+ </FloatingIconButton>
442
+ <FloatingIconButton
443
+ aria-label="Expand results"
444
+ onClick={() => setResultsDialogOpen(true)}
445
+ >
446
+ <SearchIcon />
447
+ </FloatingIconButton>
448
+ </Stack>
449
+ }
450
+ />
451
+ <ResultContainer
452
+ result={cell.result}
453
+ maxHeight={NOTEBOOK_CELL_MAX_HEIGHT}
454
+ maxResultSize={maxResultSize}
455
+ drill={drill}
456
+ />
500
457
  {drillMenu}
501
-
502
- {/* Top right corner controls.
503
- `top: -12px` lifts the buttons above the
504
- CleanMetricCard's inner ResultContainer so the
505
- dashboard panel (which now paints slate in dark
506
- mode) doesn't bisect them. The icons were already
507
- visually overlapping the panel's top edge in
508
- light mode too, but the white-on-white made it
509
- invisible; in dark mode the contrast made the
510
- clipping obvious. */}
511
- <Stack
512
- sx={{
513
- position: "absolute",
514
- top: "-12px",
515
- right: "8px",
516
- flexDirection: "row",
517
- gap: "8px",
518
- alignItems: "center",
519
- zIndex: 2,
520
- }}
521
- >
522
- <FloatingIconButton
523
- aria-label="Malloy code"
524
- onClick={(e) => {
525
- e.stopPropagation();
526
- setCodeDialogOpen(true);
527
- }}
528
- >
529
- <CodeIcon />
530
- </FloatingIconButton>
531
- <FloatingIconButton
532
- aria-label="Expand results"
533
- onClick={() => setResultsDialogOpen(true)}
534
- >
535
- <SearchIcon />
536
- </FloatingIconButton>
537
- </Stack>
538
- </CleanMetricCard>
458
+ </TileCard>
539
459
  )}
540
460
  </Box>
541
461
  ))
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ // DEPRECATED FEATURE COVERAGE — delete together with
5
+ // `.malloynb` notebooks (see RELEASE_NOTES deprecations).
6
+ import { describe, expect, it } from "bun:test";
7
+ import { cellRuns, stripProse } from "./cellKind";
8
+
9
+ describe("cellRuns", () => {
10
+ it("runs a .malloynb code cell and skips its markdown", () => {
11
+ expect(cellRuns({ type: "code" })).toBe(true);
12
+ expect(cellRuns({ type: "markdown" })).toBe(false);
13
+ });
14
+ });
15
+
16
+ describe("stripProse", () => {
17
+ it("drops the ## lines, as the released viewer did", () => {
18
+ expect(
19
+ stripProse({ text: "## title\n ## indented\nrun: q\n#(markdown) x" }),
20
+ ).toBe("run: q\n#(markdown) x");
21
+ });
22
+
23
+ it("drops a .malloynb ##! line", () => {
24
+ expect(stripProse({ text: "##! experimental.parameters\nrun: q" })).toBe(
25
+ "run: q",
26
+ );
27
+ });
28
+
29
+ it("leaves (markdown) lines alone", () => {
30
+ const cell = '#(markdown) note\n#|(markdown)\nbody\n|#\n#" c\nrun: q';
31
+ expect(stripProse({ text: cell })).toBe(cell);
32
+ });
33
+ });
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ /**
5
+ * @deprecated `.malloynb` only; deleted with the format.
6
+ *
7
+ * How a `.malloynb` cell is read: every code cell runs, and a cell's code is
8
+ * shown without its `##` lines (the notebook's own annotations), which are not
9
+ * part of the query. A `.malloy` report never reaches here: it is tiles.
10
+ */
11
+ import type { NotebookCell } from "../../../client";
12
+
13
+ /** Whether the viewer sends a cell to the server to run: every code cell. */
14
+ export function cellRuns(cell: Pick<NotebookCell, "type">): boolean {
15
+ return cell.type === "code";
16
+ }
17
+
18
+ /** A cell's code without its `##` lines. */
19
+ export function stripProse(cell: Pick<NotebookCell, "text">): string {
20
+ return (cell.text ?? "")
21
+ .split("\n")
22
+ .filter((line) => !line.trimStart().startsWith("##"))
23
+ .join("\n");
24
+ }
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { NotebookCell as ClientNotebookCell } from "../../client";
4
+ import { NotebookCell as ClientNotebookCell } from "../../../client";
5
5
 
6
6
  /**
7
7
  * Enhanced notebook cell that extends the base API cell with execution results.
@@ -89,24 +89,6 @@ export const StyledCardMedia = styled(CardMedia)({
89
89
  padding: "0",
90
90
  });
91
91
 
92
- // New clean notebook styles
93
- // No width or side padding of its own: like the Dashboard, a notebook fills
94
- // the column its host gives it, so a package's pages share one set of edges.
95
- export const CleanNotebookContainer = styled("div")(({ theme }) => ({
96
- backgroundColor: theme.palette.background.default,
97
- borderRadius: "12px",
98
- boxShadow: "none",
99
- border: "none",
100
- }));
101
-
102
- export const CleanNotebookSection = styled("div")({
103
- marginBottom: "48px",
104
- padding: "0",
105
- backgroundColor: "transparent",
106
- border: "none",
107
- boxShadow: "none",
108
- });
109
-
110
92
  export const CleanMetricCard = styled("div")({
111
93
  backgroundColor: "transparent",
112
94
  paddingTop: "12px",
@@ -328,9 +328,13 @@ export function useGivensState({
328
328
  // they already match, so this cannot loop against a host that feeds its URL
329
329
  // back in through `params`.
330
330
  //
331
- // Starting values are reported too, not just edits: the address bar is meant
332
- // to show what the reader is looking at, so a dashboard opened at its
333
- // declared defaults is already a link that reproduces them.
331
+ // Only the reader's own values are reported, not the file's starting values:
332
+ // a link copied before anything was touched follows the file's starting
333
+ // values as they are later edited, rather than pinning the ones it was opened
334
+ // at. That falls out of the seeding below for a host that mounts this with
335
+ // its manifest loaded, as the report reader does. (A host that mounts first
336
+ // and loads after, as the deprecated `.malloynb` runner does, reports them on
337
+ // an uncached load.)
334
338
  //
335
339
  // The reference starts at the first render's values rather than empty. The
336
340
  // control row is empty until the manifest arrives and says which givens
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { describe, expect, it } from "bun:test";
5
+ import { onlyGivensDiffer, queryResultKey } from "./useQueryResult";
6
+
7
+ const spec = {
8
+ environmentName: "e",
9
+ packageName: "p",
10
+ modelPath: "m.malloy",
11
+ query: "run: a -> by_cat",
12
+ };
13
+
14
+ describe("which earlier answer a re-run may show", () => {
15
+ it("keeps the last answer when only the control values changed", () => {
16
+ expect(
17
+ onlyGivensDiffer(
18
+ [...queryResultKey({ ...spec, givens: { R: "w" } }), "server"],
19
+ [...queryResultKey({ ...spec, givens: { R: "e" } }), "server"],
20
+ ),
21
+ ).toBe(true);
22
+ });
23
+
24
+ it("drops it when the query changed: another view is not its answer", () => {
25
+ expect(
26
+ onlyGivensDiffer(
27
+ [...queryResultKey(spec), "server"],
28
+ [
29
+ ...queryResultKey({ ...spec, query: "run: a -> by_brand" }),
30
+ "server",
31
+ ],
32
+ ),
33
+ ).toBe(false);
34
+ });
35
+
36
+ it("drops it for another server", () => {
37
+ expect(
38
+ onlyGivensDiffer(
39
+ [...queryResultKey(spec), "one"],
40
+ [...queryResultKey(spec), "two"],
41
+ ),
42
+ ).toBe(false);
43
+ });
44
+ });
@@ -4,6 +4,7 @@
4
4
  import type { QueryKey } from "@tanstack/react-query";
5
5
  import { useServer } from "../components/ServerProvider";
6
6
  import { CHART_RESULT_QUERY_OPTIONS } from "../utils/queryClient";
7
+ import { keepPreviousData } from "@tanstack/react-query";
7
8
  import { useQueryWithApiError } from "./useQueryWithApiError";
8
9
 
9
10
  /**
@@ -74,8 +75,9 @@ export function useQueryResult(
74
75
  { enabled = true }: { enabled?: boolean } = {},
75
76
  ) {
76
77
  const { apiClients } = useServer();
78
+ const key = queryResultKey(spec);
77
79
  return useQueryWithApiError({
78
- queryKey: queryResultKey(spec),
80
+ queryKey: key,
79
81
  // The signal cancels a run the page no longer wants: a tile whose givens
80
82
  // changed under it, or one that unmounted. react-query reverts a
81
83
  // cancelled query to its previous state rather than to an error, so an
@@ -96,9 +98,32 @@ export function useQueryResult(
96
98
  { signal },
97
99
  ),
98
100
  enabled,
101
+ // A change of givens is a new key, and without this the surface drops to
102
+ // "Running…" and back: every tile on a page blanked and redrew on each
103
+ // filter pick. The last result stays up until the new one lands, and
104
+ // `isPlaceholderData` says it is the previous answer.
105
+ placeholderData: (previous, previousQuery) =>
106
+ previousQuery && onlyGivensDiffer(previousQuery.queryKey, key)
107
+ ? keepPreviousData(previous)
108
+ : undefined,
99
109
  ...CHART_RESULT_QUERY_OPTIONS,
100
110
  });
101
111
  }
102
112
 
113
+ /** Where the applied values sit in {@link queryResultKey}. */
114
+ const GIVENS_AT = 8;
115
+
116
+ /**
117
+ * The same request but for its control values. Only then is the last answer
118
+ * worth showing while the new one runs: a tile switched to another view, or a
119
+ * query changed for any other reason, showed the old view's rows under the
120
+ * new title. The wrapper appends the server; that has to match too.
121
+ */
122
+ export function onlyGivensDiffer(previous: QueryKey, next: QueryKey): boolean {
123
+ return previous.every(
124
+ (part, i) => i === GIVENS_AT || i >= next.length || part === next[i],
125
+ );
126
+ }
127
+
103
128
  /** What a result surface holds while a query runs: hand it to `ResultPanel`. */
104
129
  export type QueryResultState = ReturnType<typeof useQueryResult>;
@@ -8,6 +8,7 @@ import React, {
8
8
  type ReactNode,
9
9
  } from "react";
10
10
  import { resolveTheme } from "./resolveTheme";
11
+ import { mergeUi, type ReportUiOverrides } from "./ui";
11
12
  import type { ResolvedTheme, Theme, ThemeMode } from "./types";
12
13
 
13
14
  interface ThemeContextValue {
@@ -46,6 +47,12 @@ interface ThemeProviderProps {
46
47
  userChoice: ThemeMode | "auto" | undefined;
47
48
  setMode: (mode: ThemeMode | "auto") => void;
48
49
  allowUserToggle?: boolean;
50
+ /**
51
+ * The host's design tokens for the report and builder chrome: radii,
52
+ * control sizes, the type scale, the mono face, the menu shadow. Any subset;
53
+ * the rest stay the SDK's. See `ReportUi`.
54
+ */
55
+ ui?: ReportUiOverrides;
49
56
  children: ReactNode;
50
57
  }
51
58
 
@@ -55,9 +62,22 @@ export function ThemeProvider({
55
62
  userChoice,
56
63
  setMode,
57
64
  allowUserToggle = true,
65
+ ui,
58
66
  children,
59
67
  }: ThemeProviderProps) {
60
- const theme = useMemo(() => resolveTheme(layers, mode), [layers, mode]);
68
+ // Keyed on the tokens' content, not the object: a host writing `ui={{…}}`
69
+ // inline hands a new object every render, and a new theme every render
70
+ // repainted every chart on the page.
71
+ const uiKey = JSON.stringify(ui ?? null);
72
+ const merged = useMemo(
73
+ () => mergeUi(ui),
74
+ // eslint-disable-next-line react-hooks/exhaustive-deps
75
+ [uiKey],
76
+ );
77
+ const theme = useMemo(
78
+ () => ({ ...resolveTheme(layers, mode), ui: merged }),
79
+ [layers, mode, merged],
80
+ );
61
81
  const value = useMemo<ThemeContextValue>(
62
82
  () => ({ theme, layers, mode, userChoice, setMode, allowUserToggle }),
63
83
  [theme, layers, mode, userChoice, setMode, allowUserToggle],
@@ -0,0 +1,52 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ /**
5
+ * Stable class names on the parts of the report reader and builder, for a
6
+ * host to style what the theme tokens (`ui`, the instance theme, the host's
7
+ * MUI palette) do not reach: a global stylesheet, or a styled wrapper,
8
+ * selecting `.publisher-tile` rather than an MUI class that changes between
9
+ * versions.
10
+ *
11
+ * These names are API: they are kept across releases, and a part that goes
12
+ * away is said so in the release notes.
13
+ */
14
+ export const reportClasses = {
15
+ /** A report page, read or edited: header, filter row and tiles. */
16
+ report: "publisher-report",
17
+ /** The title and description over a report. */
18
+ header: "publisher-report-header",
19
+ /** The report's title. */
20
+ title: "publisher-report-title",
21
+ /** The row of filter buttons (pinned under the header while scrolling). */
22
+ filterRow: "publisher-filter-row",
23
+ /** One filter's button. */
24
+ filter: "publisher-filter",
25
+ /** The popover a filter button opens. */
26
+ filterPopover: "publisher-filter-popover",
27
+ /** A tile's card: a query result, or a block of prose (`data-tile-kind`). */
28
+ tile: "publisher-tile",
29
+ /** A tile's title and subtitle. */
30
+ tileHeading: "publisher-tile-heading",
31
+ /** A cell that can be clicked to filter (`# drill`). */
32
+ drillCell: "publisher-drill",
33
+ /** The builder, around the page it edits. */
34
+ builder: "publisher-builder",
35
+ /** The builder's controls as one bar (`BuilderBar`). */
36
+ builderBar: "publisher-builder-bar",
37
+ /** The bar's save status. */
38
+ saveStatus: "publisher-save-status",
39
+ /** A tile as the builder draws it: selection, handle and menu around the card. */
40
+ builderTile: "publisher-builder-tile",
41
+ /** The grip on a tile's right edge that sets its width. */
42
+ widthHandle: "publisher-width-handle",
43
+ /** The builder's menus (Add, a tile's ⋯, the save status). */
44
+ menu: "publisher-menu",
45
+ /** Every builder window; each also carries its own name below. */
46
+ dialog: "publisher-dialog",
47
+ addTileDialog: "publisher-add-tile-dialog",
48
+ filterDialog: "publisher-filter-dialog",
49
+ clickableCellsDialog: "publisher-clickable-cells-dialog",
50
+ /** The New report window. */
51
+ newReportDialog: "publisher-new-report-dialog",
52
+ } as const;
@@ -4,6 +4,7 @@
4
4
  export { accentFor, contrastRatio, type Accent } from "./accent";
5
5
  export { buildMalloyExplicitTheme } from "./buildMalloyExplicitTheme";
6
6
  export { buildTableCssVars } from "./buildTableCssVars";
7
+ export { reportClasses } from "./classes";
7
8
  export { buildVegaThemeOverride } from "./buildVegaThemeOverride";
8
9
  export { DEFAULT_THEME } from "./defaults";
9
10
  export {
@@ -18,3 +19,10 @@ export { readChartAnnotations } from "./readChartAnnotations";
18
19
  export { resolveMode, resolveTheme } from "./resolveTheme";
19
20
  export { ThemeProvider, usePublisherTheme } from "./ThemeContext";
20
21
  export type { ResolvedTheme, Theme, ThemeMode } from "./types";
22
+ export {
23
+ DEFAULT_UI,
24
+ mergeUi,
25
+ type ReportUi,
26
+ type ReportUiOverrides,
27
+ type UiTextStyle,
28
+ } from "./ui";
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
+ import { DEFAULT_UI } from "./ui";
4
5
  import { accentFor, legibleOn } from "./accent";
5
6
  import { DEFAULT_THEME } from "./defaults";
6
7
  import { PER_MODE_COLOR_KEYS, type PerModeColorKey } from "./keys";
@@ -94,6 +95,8 @@ export function resolveTheme(
94
95
  : pick("mapColor");
95
96
  return {
96
97
  mode,
98
+ // The host's chrome tokens are laid over this by `ThemeProvider`.
99
+ ui: DEFAULT_UI,
97
100
  // One series list for both modes, picked against a light page: in dark,
98
101
  // an operator's colour too dark to see on the canvas is lifted until it
99
102
  // reads. The defaults are drawn as they always were.