@malloy-publisher/sdk 0.9.10 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/RenderedResult-BlNoIiSi.cjs.js +153 -0
  2. package/dist/{RenderedResult-Dp1Qdajz.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
  3. package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
  4. package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
  5. package/dist/builder/index.cjs.js +78 -130
  6. package/dist/builder/index.es.js +7493 -6769
  7. package/dist/builder-entry.d.ts +3 -0
  8. package/dist/client/api.d.ts +26 -22
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +1 -1
  11. package/dist/components/AppDialog.d.ts +9 -1
  12. package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
  13. package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
  14. package/dist/components/Dashboard/DashboardView.d.ts +22 -34
  15. package/dist/components/Dashboard/TileCard.d.ts +10 -3
  16. package/dist/components/Dashboard/useStuck.d.ts +15 -7
  17. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
  18. package/dist/components/Package/PackageProblems.d.ts +14 -0
  19. package/dist/components/RemoveBadge.d.ts +40 -0
  20. package/dist/components/Report/Report.d.ts +13 -4
  21. package/dist/components/Report/ReportPage.d.ts +60 -0
  22. package/dist/components/Report/layoutRules.d.ts +32 -0
  23. package/dist/components/Report/reportQuery.d.ts +30 -0
  24. package/dist/components/Report/telemetry.d.ts +0 -2
  25. package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
  26. package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
  27. package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
  28. package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
  29. package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
  30. package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
  31. package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
  32. package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
  33. package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
  34. package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -8
  35. package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
  36. package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
  37. package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
  38. package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
  39. package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
  40. package/dist/components/ReportBuilder/TileMenu.d.ts +12 -9
  41. package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
  42. package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
  43. package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
  44. package/dist/components/ReportBuilder/catalog.d.ts +2 -4
  45. package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
  46. package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
  47. package/dist/components/ReportBuilder/preview.d.ts +17 -2
  48. package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
  49. package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
  50. package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
  51. package/dist/components/ReportBuilder/sortable.d.ts +4 -3
  52. package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
  53. package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
  54. package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
  55. package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
  56. package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
  57. package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
  58. package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
  59. package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
  60. package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
  61. package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
  62. package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
  63. package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
  64. package/dist/components/ServerProvider.d.ts +9 -0
  65. package/dist/components/controlTokens.d.ts +45 -0
  66. package/dist/components/drill/markDrillableCells.d.ts +1 -1
  67. package/dist/components/given/FilterButton.d.ts +35 -0
  68. package/dist/components/given/GivensPanel.d.ts +2 -1
  69. package/dist/components/given/filterEditing.d.ts +54 -0
  70. package/dist/components/given/filterSummary.d.ts +9 -0
  71. package/dist/components/given/paramCodec.d.ts +11 -0
  72. package/dist/components/given/required.d.ts +25 -0
  73. package/dist/components/index.d.ts +3 -0
  74. package/dist/components/legacy/index.d.ts +1 -1
  75. package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
  76. package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
  77. package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
  78. package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
  79. package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
  80. package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
  81. package/dist/components/styles.d.ts +0 -2
  82. package/dist/hooks/useQueryResult.d.ts +7 -0
  83. package/dist/index.cjs.js +16 -19
  84. package/dist/index.es.js +8324 -7769
  85. package/dist/theme/ThemeContext.d.ts +8 -1
  86. package/dist/theme/classes.d.ts +49 -0
  87. package/dist/theme/index.d.ts +2 -0
  88. package/dist/theme/types.d.ts +7 -0
  89. package/dist/theme/ui.d.ts +75 -0
  90. package/dist/{useCompiledDocument-BMPDvdFx.es.js → useCompiledDocument-7j5cBjQd.es.js} +8669 -7851
  91. package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
  92. package/package.json +2 -2
  93. package/src/builder-entry.ts +9 -0
  94. package/src/components/AppDialog.tsx +23 -0
  95. package/src/components/Dashboard/DashboardGrid.tsx +39 -17
  96. package/src/components/Dashboard/DashboardTile.tsx +19 -2
  97. package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
  98. package/src/components/Dashboard/DashboardView.tsx +137 -155
  99. package/src/components/Dashboard/RowsDialog.tsx +1 -2
  100. package/src/components/Dashboard/TileCard.tsx +28 -10
  101. package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
  102. package/src/components/Dashboard/useStuck.ts +28 -17
  103. package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
  104. package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
  105. package/src/components/Package/NewDocumentDialog.tsx +383 -119
  106. package/src/components/Package/Package.artifacts.spec.tsx +1 -1
  107. package/src/components/Package/Package.create.spec.tsx +7 -6
  108. package/src/components/Package/Package.tsx +10 -7
  109. package/src/components/Package/PackageProblems.spec.tsx +41 -0
  110. package/src/components/Package/PackageProblems.tsx +95 -0
  111. package/src/components/Prose.tsx +12 -7
  112. package/src/components/RemoveBadge.tsx +94 -0
  113. package/src/components/RenderedResult/RenderedResult.tsx +5 -9
  114. package/src/components/RenderedResult/ResultPanel.tsx +59 -3
  115. package/src/components/Report/Report.spec.tsx +50 -32
  116. package/src/components/Report/Report.telemetry.spec.tsx +0 -45
  117. package/src/components/Report/Report.tsx +45 -77
  118. package/src/components/Report/ReportPage.tsx +168 -0
  119. package/src/components/Report/layoutRules.spec.ts +35 -0
  120. package/src/components/Report/layoutRules.ts +55 -0
  121. package/src/components/Report/reportQuery.ts +53 -0
  122. package/src/components/Report/telemetry.ts +0 -2
  123. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
  124. package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
  125. package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
  126. package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -39
  127. package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
  128. package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
  129. package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
  130. package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
  131. package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
  132. package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
  133. package/src/components/ReportBuilder/FilterStrip.tsx +130 -151
  134. package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
  135. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
  136. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
  137. package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
  138. package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -15
  139. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
  140. package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
  141. package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
  142. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +37 -31
  143. package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
  144. package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
  145. package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
  146. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
  147. package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
  148. package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
  149. package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
  150. package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
  151. package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
  152. package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
  153. package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
  154. package/src/components/ReportBuilder/TileFrame.tsx +212 -75
  155. package/src/components/ReportBuilder/TileMenu.tsx +241 -140
  156. package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
  157. package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
  158. package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
  159. package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
  160. package/src/components/ReportBuilder/builderControls.ts +164 -0
  161. package/src/components/ReportBuilder/builderReport.ts +1 -2
  162. package/src/components/ReportBuilder/catalog.ts +10 -26
  163. package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
  164. package/src/components/ReportBuilder/localGiven.ts +56 -0
  165. package/src/components/ReportBuilder/preview.spec.ts +125 -5
  166. package/src/components/ReportBuilder/preview.ts +60 -44
  167. package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
  168. package/src/components/ReportBuilder/readDocument.ts +14 -11
  169. package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
  170. package/src/components/ReportBuilder/readForEditor.ts +4 -26
  171. package/src/components/ReportBuilder/reportTag.ts +28 -7
  172. package/src/components/ReportBuilder/sortable.tsx +15 -7
  173. package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
  174. package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
  175. package/src/components/ReportBuilder/testing/inline.ts +25 -5
  176. package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
  177. package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
  178. package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
  179. package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
  180. package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
  181. package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
  182. package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
  183. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
  184. package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
  185. package/src/components/ReportBuilder/useExitGuard.ts +16 -0
  186. package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
  187. package/src/components/ReportBuilder/useFilterForm.ts +5 -1
  188. package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
  189. package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
  190. package/src/components/ReportBuilder/useReportDraft.ts +292 -0
  191. package/src/components/ReportBuilder/useReportEditor.ts +3 -12
  192. package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
  193. package/src/components/ReportBuilder/useTileEditing.ts +43 -12
  194. package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
  195. package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
  196. package/src/components/ReportBuilder/widthLabel.ts +26 -0
  197. package/src/components/ServerProvider.tsx +11 -0
  198. package/src/components/controlTokens.ts +47 -0
  199. package/src/components/drill/markDrillableCells.ts +2 -1
  200. package/src/components/given/FilterButton.spec.tsx +143 -0
  201. package/src/components/given/FilterButton.tsx +478 -0
  202. package/src/components/given/GivenInput.spec.tsx +47 -0
  203. package/src/components/given/GivenInput.tsx +20 -2
  204. package/src/components/given/GivensPanel.spec.tsx +11 -3
  205. package/src/components/given/GivensPanel.tsx +45 -44
  206. package/src/components/given/filterEditing.ts +60 -0
  207. package/src/components/given/filterSummary.spec.ts +108 -0
  208. package/src/components/given/filterSummary.ts +109 -0
  209. package/src/components/given/paramCodec.ts +1 -1
  210. package/src/components/given/required.spec.ts +60 -0
  211. package/src/components/given/required.ts +78 -0
  212. package/src/components/index.ts +9 -0
  213. package/src/components/legacy/Dashboard.spec.tsx +3 -1
  214. package/src/components/legacy/index.ts +1 -1
  215. package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
  216. package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
  217. package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
  218. package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
  219. package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
  220. package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
  221. package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
  222. package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
  223. package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
  224. package/src/components/legacy/malloynb/cellKind.ts +24 -0
  225. package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
  226. package/src/components/styles.ts +0 -18
  227. package/src/hooks/useGivensState.ts +7 -3
  228. package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
  229. package/src/hooks/useQueryResult.ts +26 -1
  230. package/src/theme/ThemeContext.tsx +21 -1
  231. package/src/theme/classes.ts +52 -0
  232. package/src/theme/index.ts +8 -0
  233. package/src/theme/resolveTheme.ts +3 -0
  234. package/src/theme/types.ts +7 -0
  235. package/src/theme/ui.spec.tsx +91 -0
  236. package/src/theme/ui.ts +115 -0
  237. package/dist/RenderedResult-BcgYjkZ0.cjs.js +0 -153
  238. package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
  239. package/dist/components/Notebook/cellKind.d.ts +0 -20
  240. package/dist/components/Report/LinearReport.d.ts +0 -18
  241. package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
  242. package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
  243. package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
  244. package/dist/useCompiledDocument-UY28ITET.cjs.js +0 -141
  245. package/src/components/Notebook/cellKind.spec.ts +0 -199
  246. package/src/components/Notebook/cellKind.ts +0 -74
  247. package/src/components/Report/LinearReport.tsx +0 -71
  248. package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
  249. package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
  250. package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
  251. package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
  252. package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
  253. package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
  254. package/src/components/legacy/Notebook.served.spec.tsx +0 -183
  255. /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
  256. /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
  257. /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
@@ -8,10 +8,10 @@ import { chartLineText, isChartPick } from "./chartLine";
8
8
  import {
9
9
  isQueryTile,
10
10
  type DashboardDocument,
11
- type LocalGiven,
12
11
  type QueryTile,
13
12
  } from "./document";
14
13
  import { malloyPath } from "../../utils/malloyText";
14
+ import { localGivenSpec } from "./localGiven";
15
15
 
16
16
  /**
17
17
  * What a reader would see if the DOCUMENT were the file: the controls, and
@@ -30,7 +30,9 @@ import { malloyPath } from "../../utils/malloyText";
30
30
 
31
31
  /**
32
32
  * The controls this document shows: every given some tile binds, this file's
33
- * own declarations first in declaration order, then the model's.
33
+ * own declarations first in declaration order, then the model's in the
34
+ * manifest's order, whether a tile binds one in this file or reads it through
35
+ * the model (`modelReads`, from {@link givensReadThroughModel}).
34
36
  *
35
37
  * That is the reader's rule — only a given some tile reads becomes a control
36
38
  * — applied to the document instead of the manifest. A local declaration is
@@ -41,6 +43,7 @@ import { malloyPath } from "../../utils/malloyText";
41
43
  export function previewGivens(
42
44
  document: DashboardDocument,
43
45
  modelSpecs: readonly Given[],
46
+ modelReads: ReadonlySet<string> = new Set(),
44
47
  ): Given[] {
45
48
  const bound = new Set<string>();
46
49
  for (const tile of document.tiles)
@@ -52,13 +55,13 @@ export function previewGivens(
52
55
  for (const local of document.localGivens ?? []) {
53
56
  if (!bound.has(local.name)) continue;
54
57
  seen.add(local.name);
55
- out.push(givenFromLocal(local));
58
+ out.push(localGivenSpec(local));
56
59
  }
57
60
  for (const spec of modelSpecs) {
58
61
  if (
59
62
  spec.name === undefined ||
60
63
  seen.has(spec.name) ||
61
- !bound.has(spec.name)
64
+ !(bound.has(spec.name) || modelReads.has(spec.name))
62
65
  )
63
66
  continue;
64
67
  seen.add(spec.name);
@@ -67,44 +70,50 @@ export function previewGivens(
67
70
  return out;
68
71
  }
69
72
 
70
- /** A `given:` this file declares, as the `Given` the control row renders. */
71
- function givenFromLocal(local: LocalGiven): Given {
72
- const shown = displayDefault(local);
73
- return {
74
- name: local.name,
75
- type: local.type,
76
- ...(shown === undefined ? {} : { default: shown }),
77
- ...(local.label === undefined ? {} : { label: local.label }),
78
- ...(local.description === undefined
79
- ? {}
80
- : { description: local.description }),
81
- ...(local.control === undefined
82
- ? {}
83
- : { control: local.control as Given["control"] }),
84
- ...(local.suggest
85
- ? {
86
- suggest: {
87
- ...(local.suggest.source === undefined
88
- ? {}
89
- : { source: local.suggest.source }),
90
- ...(local.suggest.query === undefined
91
- ? {}
92
- : { query: local.suggest.query }),
93
- dimension: local.suggest.dimension,
94
- },
95
- }
96
- : {}),
97
- ...(local.rangeMin === undefined ? {} : { rangeMin: local.rangeMin }),
98
- ...(local.rangeMax === undefined ? {} : { rangeMax: local.rangeMax }),
99
- };
73
+ /**
74
+ * The givens the document's tiles read through the model rather than through
75
+ * a binding in this file: a source whose own `where:` reads a given, say.
76
+ *
77
+ * The server says what each served tile reads (`servedReads`, by tile
78
+ * expression), bindings in the file included. What the file bound when it
79
+ * was opened is taken back out, so what is left is what the model reads; a
80
+ * binding the author removes then takes its control with it. A tile the
81
+ * server has not compiled (new, or under a new name) is read by the served
82
+ * tile with the same expression, if there is one, and otherwise reads
83
+ * nothing until the next save.
84
+ */
85
+ export function givensReadThroughModel(
86
+ document: DashboardDocument,
87
+ opened: DashboardDocument,
88
+ servedReads: ReadonlyMap<string, readonly string[]>,
89
+ ): Set<string> {
90
+ const boundWhenOpened = new Map<string, Set<string>>();
91
+ for (const tile of opened.tiles) {
92
+ if (!isQueryTile(tile)) continue;
93
+ boundWhenOpened.set(
94
+ tileExpressionKey(`${tile.source} -> ${tile.name}`),
95
+ new Set((tile.filters ?? []).map((filter) => filter.given)),
96
+ );
97
+ }
98
+ const reads = new Set<string>();
99
+ for (const tile of document.tiles) {
100
+ if (!isQueryTile(tile)) continue;
101
+ const key = tileExpressionKey(`${tile.source} -> ${tile.name}`);
102
+ const bound = boundWhenOpened.get(key);
103
+ for (const name of servedReads.get(key) ?? [])
104
+ if (!bound?.has(name)) reads.add(name);
105
+ }
106
+ return reads;
100
107
  }
101
108
 
102
- /** The default the server would publish: it unwraps a filter's `f'…'`, so an empty one shows no caption. */
103
- function displayDefault(local: LocalGiven): string | undefined {
104
- if (!local.type?.startsWith("filter<")) return local.default;
105
- const body = local.default?.match(/^f(['"])([\s\S]*)\1$/)?.[2];
106
- if (body === undefined) return local.default;
107
- return body === "" ? undefined : body;
109
+ /**
110
+ * A declaration's default as a clause can use it: none when it filters
111
+ * nothing (an empty `f''`), so an unset filter adds no clause, as before.
112
+ */
113
+ function defaultLiteral(spelled: string | undefined): string | undefined {
114
+ const text = spelled?.trim();
115
+ if (!text || /^f(['"])\1$/.test(text)) return undefined;
116
+ return text;
108
117
  }
109
118
 
110
119
  /**
@@ -225,6 +234,12 @@ export function previewTileQuery(
225
234
  const localTypes = new Map(
226
235
  (document.localGivens ?? []).map((local) => [local.name, local.type]),
227
236
  );
237
+ // Each declaration's default, already a Malloy literal (`f'Jeans'`,
238
+ // `@2023-01-01`): what applies when no value is set, as the server applies
239
+ // a given's default.
240
+ const localDefaults = new Map(
241
+ (document.localGivens ?? []).map((local) => [local.name, local.default]),
242
+ );
228
243
  // The extension's own `where:` filters every tile on it, as the served manifest counts.
229
244
  const scopedBy =
230
245
  document.sources.find((source) => source.name === on)?.scopedBy ?? [];
@@ -246,10 +261,11 @@ export function previewTileQuery(
246
261
  if (!localTypes.has(filter.given)) continue;
247
262
  // Applied as a literal, so the control still changes this tile.
248
263
  reads.add(filter.given);
249
- const literal = malloyLiteral(
250
- values.get(filter.given),
251
- localTypes.get(filter.given),
252
- );
264
+ const literal =
265
+ malloyLiteral(
266
+ values.get(filter.given),
267
+ localTypes.get(filter.given),
268
+ ) ?? defaultLiteral(localDefaults.get(filter.given));
253
269
  if (literal !== undefined) clauses.push(`${comparison} ${literal}`);
254
270
  }
255
271
  const refinement = clauses.join(", ");
@@ -2,11 +2,11 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import { describe, expect, it } from "bun:test";
5
+ import { CELLS_REMOVED_REASON } from "./reportTag";
5
6
  import { openDocument } from "./testing/fixtures";
6
7
  import * as fs from "fs";
7
8
  import * as path from "path";
8
9
  import { blockAbove, readDashboardDocument, readFailed } from "./readDocument";
9
- import { readForEditor } from "./readForEditor";
10
10
  import { readReportTagOfText } from "./reportTag";
11
11
  import { parseMalloy, parseRefused } from "./malloyTree";
12
12
  import { queryTile } from "./testing/fixtures";
@@ -862,15 +862,6 @@ describe("a tag whose artifact property is not the first", () => {
862
862
  expect(result.reason).toContain("`artifact { … }` first");
863
863
  });
864
864
 
865
- it("is refused, not converted, for a cell-format notebook", async () => {
866
- const open = await readForEditor(
867
- `##! experimental.givens\n## dashboard { columns=2 } artifact { layout=linear title="T" }\nrun: a -> by_cat`,
868
- );
869
- expect(open.ok === false && open.reason).toContain(
870
- "`artifact { … }` first",
871
- );
872
- });
873
-
874
865
  it("still opens when artifact leads and another property follows", async () => {
875
866
  const doc = await read(
876
867
  `## artifact { title="Probe" tiles=["a -> by_cat"] } dashboard { columns=2 }\n${rest}`,
@@ -948,7 +939,6 @@ describe("the compiler stays lazy", () => {
948
939
  fs.readFileSync(path.join(import.meta.dir, file), "utf8");
949
940
  const staticImport = /^\s*import\s[^(]*@malloydata\/malloy"/m;
950
941
  expect(read("malloyTree.ts")).not.toMatch(staticImport);
951
- expect(read("legacyNotebook.ts")).not.toMatch(staticImport);
952
942
  expect(read("malloyTree.ts")).toContain("await loadMalloy()");
953
943
  expect(read("loadMalloy.ts")).toContain(
954
944
  'await import("@malloydata/malloy")',
@@ -957,20 +947,22 @@ describe("the compiler stays lazy", () => {
957
947
  expect(read("loadMalloy.ts")).toContain(
958
948
  `await import("@malloydata/${pkg}")`,
959
949
  );
960
- for (const file of ["readDocument.ts", "legacyNotebook.ts"])
961
- expect(read(file)).not.toContain('import("@malloydata/malloy-tag")');
950
+ expect(read("readDocument.ts")).not.toContain(
951
+ 'import("@malloydata/malloy-tag")',
952
+ );
962
953
  });
963
954
  });
964
955
 
965
956
  describe("the layout of a report", () => {
966
957
  it("reads the same layout wherever the file lives: the folder no longer matters", async () => {
958
+ // `null`: no report, whatever the folder.
967
959
  const cases = [
968
- ["## artifact { }\nrun: q -> { aggregate: c }\n", true],
969
- [`## artifact { tiles=["a -> v"] }\n`, false],
970
- [`## artifact { layout=linear tiles=["a -> v"] }\n`, true],
971
- ["## artifact { layout=grid tiles=[] }\n", false],
960
+ ["## artifact { }\nrun: q -> { aggregate: c }\n", null],
961
+ [`## artifact { tiles=["a -> v"] }\n`, "grid"],
962
+ [`## artifact { layout=linear tiles=["a -> v"] }\n`, "linear"],
963
+ ["## artifact { layout=grid tiles=[] }\n", "grid"],
972
964
  ] as const;
973
- for (const [source, linear] of cases)
965
+ for (const [source, layout] of cases)
974
966
  for (const where of [
975
967
  undefined,
976
968
  "x.malloy",
@@ -979,10 +971,12 @@ describe("the layout of a report", () => {
979
971
  "sales/q3/x.malloy",
980
972
  ]) {
981
973
  const result = await readDashboardDocument(source, where);
982
- const isLinear = readFailed(result)
983
- ? result.legacyNotebook === true
984
- : result.document.layout === "linear";
985
- expect([where, isLinear]).toEqual([where, linear]);
974
+ const read = readFailed(result)
975
+ ? result.reason === CELLS_REMOVED_REASON
976
+ ? null
977
+ : result.reason
978
+ : result.document.layout;
979
+ expect([where, read]).toEqual([where, layout]);
986
980
  }
987
981
  });
988
982
  });
@@ -16,7 +16,12 @@ import type {
16
16
  } from "./document";
17
17
  import { isTextTile } from "./document";
18
18
  import { loadMalloyTag } from "./loadMalloy";
19
- import { kindRemovedReason, readReportTag } from "./reportTag";
19
+ import {
20
+ CELLS_REMOVED_REASON,
21
+ kindRemovedReason,
22
+ readReportTag,
23
+ unknownLayoutReason,
24
+ } from "./reportTag";
20
25
  import { parseTagLines } from "./tagParse";
21
26
  import {
22
27
  parseMalloy,
@@ -67,8 +72,6 @@ export interface ReadFailure {
67
72
  reason: string;
68
73
  /** 1-based, for a message that can point at the line. */
69
74
  line?: number;
70
- /** The file is a linear report in the run-cell format, which `convertLegacyNotebook` turns into a tile layout. */
71
- legacyNotebook?: true;
72
75
  }
73
76
 
74
77
  export type ReadResult =
@@ -324,6 +327,14 @@ async function readDocumentText(sourceText: string): Promise<ReadResult> {
324
327
  };
325
328
  if (reportTag.status === "kind-removed")
326
329
  return { ok: false, reason: kindRemovedReason(reportTag.kind) };
330
+ if (reportTag.status === "cells-removed")
331
+ return {
332
+ ok: false,
333
+ reason:
334
+ reportTag.unknownLayout !== undefined
335
+ ? unknownLayoutReason(reportTag.unknownLayout)
336
+ : CELLS_REMOVED_REASON,
337
+ };
327
338
  const layout = reportTag.layout;
328
339
 
329
340
  const artifactAt = locateArtifactTag(lines);
@@ -350,14 +361,6 @@ async function readDocumentText(sourceText: string): Promise<ReadResult> {
350
361
  ok: false,
351
362
  reason: `The \`## artifact\` tag does not parse: ${tagErrors[0]}`,
352
363
  };
353
- // A linear report is told from a tile layout by whether it lists tiles at all.
354
- if (layout === "linear")
355
- return {
356
- ok: false,
357
- legacyNotebook: true,
358
- reason:
359
- "This report is in the cell format, with no `tiles=[…]` list.",
360
- };
361
364
  return {
362
365
  ok: false,
363
366
  reason:
@@ -2,44 +2,32 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import { describe, expect, it } from "bun:test";
5
- import * as fs from "fs";
6
- import * as path from "path";
7
5
  import { readForEditor } from "./readForEditor";
8
-
9
- const REPO = path.resolve(import.meta.dir, "../../../../..");
10
- const LEGACY = fs
11
- .readFileSync(
12
- path.join(REPO, "examples/storefront/category-review.malloy"),
13
- "utf8",
14
- )
15
- .replace(/\r\n/g, "\n");
6
+ import { CELLS_REMOVED_REASON, unknownLayoutReason } from "./reportTag";
16
7
 
17
8
  describe("readForEditor", () => {
18
- it("opens a layout file as it is, with no conversion", async () => {
9
+ it("opens a layout file as it is", async () => {
19
10
  const result = await readForEditor(
20
11
  `## artifact { title="D" tiles=["a -> x"] }\nsource: a is b extend {\n view: x is v\n}\n`,
21
12
  );
22
13
  expect(result.ok).toBe(true);
23
- expect(result.ok && result.conversion).toBeUndefined();
24
14
  });
25
15
 
26
- it("converts a cell-format notebook, keeping the disk text to hand back", async () => {
27
- const result = await readForEditor(LEGACY);
28
- if (result.ok === false) throw new Error(result.reason);
29
- expect(result.conversion?.from).toBe(LEGACY);
30
- expect(result.conversion?.to).toContain(
31
- "tiles=[\n text_1 { kind=text }",
16
+ it("refuses a file written as run: cells, naming the fix", async () => {
17
+ const result = await readForEditor(
18
+ `## artifact { layout=linear }\nimport { o } from "../m.malloy"\n\nrun: o -> v\n`,
32
19
  );
33
- expect(result.document.layout).toBe("linear");
34
- expect(result.document.tiles).toHaveLength(7);
20
+ // The reason, with no line: the server's finding names the tag's line.
21
+ expect(result.ok === false && result.reason).toBe(CELLS_REMOVED_REASON);
35
22
  });
36
23
 
37
- it("refuses a conversion it cannot make, naming the line", async () => {
24
+ it("names an unknown layout rather than the cell format", async () => {
38
25
  const result = await readForEditor(
39
- `## artifact { layout=linear }\nimport { o } from "../m.malloy"\n\nrun: o extend { dimension: z is 1 } -> { select: z }\n`,
26
+ `## artifact { layout=Grid }\nimport { o } from "../m.malloy"\n`,
27
+ );
28
+ expect(result.ok === false && result.reason).toBe(
29
+ unknownLayoutReason("Grid"),
40
30
  );
41
- expect(result.ok).toBe(false);
42
- expect(result.ok === false && result.reason).toMatch(/line 4/i);
43
31
  });
44
32
 
45
33
  it("says why a file that is not a notebook will not open, with its line", async () => {
@@ -75,22 +63,5 @@ describe("readForEditor", () => {
75
63
  "`layout=grid` or `layout=linear`",
76
64
  );
77
65
  });
78
-
79
- it("converts a cell-format file with no layout rather than refusing it", async () => {
80
- const layoutless = LEGACY.replace("layout=linear ", "");
81
- expect(layoutless).not.toBe(LEGACY);
82
- const result = await readForEditor(layoutless);
83
- if (result.ok === false) throw new Error(result.reason);
84
- expect(result.conversion?.from).toBe(layoutless);
85
- });
86
-
87
- // A tile list with no `layout=` reads as grid, so the converter writes `layout=linear`.
88
- it("converts a cell-format file with no layout into a LINEAR report", async () => {
89
- const layoutless = LEGACY.replace("layout=linear ", "");
90
- const result = await readForEditor(layoutless);
91
- if (result.ok === false) throw new Error(result.reason);
92
- expect(result.document.layout).toBe("linear");
93
- expect(result.conversion?.to).toContain("layout=linear");
94
- });
95
66
  });
96
67
  });
@@ -2,17 +2,11 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import type { DashboardDocument } from "./document";
5
- import { conversionRefused, convertLegacyNotebook } from "./legacyNotebook";
6
5
  import { readDashboardDocument, readFailed } from "./readDocument";
7
6
 
8
- /** A file opened for editing: its document, and the conversion it is the result of when the file is a cell-format notebook. */
7
+ /** A file opened for editing: its document, or why it cannot be opened. */
9
8
  export type EditorOpen =
10
- | {
11
- ok: true;
12
- document: DashboardDocument;
13
- /** `from` is the text on disk, `to` the layout text it converts to. */
14
- conversion?: { from: string; to: string };
15
- }
9
+ | { ok: true; document: DashboardDocument }
16
10
  | { ok: false; reason: string };
17
11
 
18
12
  const withLine = (reason: string, line: number | undefined) =>
@@ -20,25 +14,9 @@ const withLine = (reason: string, line: number | undefined) =>
20
14
  ? `${reason} (line ${line})`
21
15
  : reason;
22
16
 
23
- /** Read `text` for the builder, converting a cell-format notebook rather than refusing it. */
17
+ /** Read `text` for the builder, with the line a refusal points at in its reason. */
24
18
  export async function readForEditor(text: string): Promise<EditorOpen> {
25
19
  const read = await readDashboardDocument(text);
26
20
  if (!readFailed(read)) return { ok: true, document: read.document };
27
- if (!read.legacyNotebook)
28
- return { ok: false, reason: withLine(read.reason, read.line) };
29
-
30
- const converted = await convertLegacyNotebook(text);
31
- if (conversionRefused(converted))
32
- return { ok: false, reason: withLine(converted.refused, converted.line) };
33
- const reread = await readDashboardDocument(converted.text);
34
- if (readFailed(reread))
35
- return {
36
- ok: false,
37
- reason: `The converted notebook cannot be opened: ${withLine(reread.reason, reread.line)}`,
38
- };
39
- return {
40
- ok: true,
41
- document: reread.document,
42
- conversion: { from: text, to: converted.text },
43
- };
21
+ return { ok: false, reason: withLine(read.reason, read.line) };
44
22
  }
@@ -26,6 +26,7 @@ export type ReportTag =
26
26
  | { status: "none" }
27
27
  | { status: "unparsed"; errors: string[] }
28
28
  | { status: "kind-removed"; kind: string }
29
+ | { status: "cells-removed"; unknownLayout?: string }
29
30
  | { status: "report"; layout: ReportLayout };
30
31
 
31
32
  type Parsed = { tag: TagReads; log: Array<{ message: string }> };
@@ -33,6 +34,7 @@ type TagReads = {
33
34
  tag(key: string): TagReads | undefined;
34
35
  text(key: string): string | undefined;
35
36
  has(key: string): boolean;
37
+ array(key: string): unknown[] | undefined;
36
38
  };
37
39
 
38
40
  /** A tag property as text; `text()` throws on a malformed date literal, which reads as no value. */
@@ -51,6 +53,14 @@ const onTagRoute = (note: string) => /^##\|?(?:[ \t\r\n]|$)/.test(note);
51
53
  export const kindRemovedReason = (kind: string) =>
52
54
  `\`kind=${kind}\` is no longer read, so this file is not a report. Fix: remove \`kind=${kind}\` and write \`layout=grid\` or \`layout=linear\`.`;
53
55
 
56
+ /** Why a tileless tag naming an unknown layout makes no report, and the fix: the server's message, capitalized. */
57
+ export const unknownLayoutReason = (layout: string) =>
58
+ `\`layout=${layout}\` is not a layout Publisher knows (grid, linear), and the tag lists no tiles, so this file is not a report. Fix: write \`layout=grid\` or \`layout=linear\`, and list the tiles in \`tiles=[…]\`.`;
59
+
60
+ /** Why a linear tag with no `tiles` makes no report, and the fix: the server's message, capitalized. */
61
+ export const CELLS_REMOVED_REASON =
62
+ "A linear report written as `run:` cells is no longer read, so this file is not a report. Fix: list its tiles in `tiles=[…]` (a text tile per prose block, a query tile per view), or remove the `## artifact` tag.";
63
+
54
64
  /**
55
65
  * The one reader of a report's tag in the SDK, over a file's model-level
56
66
  * notes (`ParsedMalloy.modelNotes`). The server's `readReportTag` is the same
@@ -58,7 +68,9 @@ export const kindRemovedReason = (kind: string) =>
58
68
  *
59
69
  * The layout, first match wins: `layout=grid|linear`; else grid when the tag
60
70
  * lists `tiles` (an empty list counts) or a model-level `dashboard { … }` grid
61
- * tag is present; else linear.
71
+ * tag is present; else linear. A linear tag with no `tiles` key (an empty
72
+ * list counts as one) is the retired cell format, and no report. A `tiles`
73
+ * that is not a list (`tiles=foo`) is a tag the reader cannot use: unparsed.
62
74
  */
63
75
  export function readReportTag(
64
76
  modelNotes: readonly string[],
@@ -80,12 +92,21 @@ export function readReportTag(
80
92
  : { status: "none" };
81
93
  const kind = textOf(artifact, "kind");
82
94
  if (kind !== undefined) return { status: "kind-removed", kind };
83
- const layout = textOf(artifact, "layout");
84
- if (layout === "grid" || layout === "linear")
85
- return { status: "report", layout };
86
- if (artifact.has("tiles") || tag?.tag("dashboard") !== undefined)
87
- return { status: "report", layout: "grid" };
88
- return { status: "report", layout: "linear" };
95
+ const named = textOf(artifact, "layout");
96
+ const hasTiles = artifact.has("tiles");
97
+ if (hasTiles && artifact.array("tiles") === undefined)
98
+ return { status: "unparsed", errors };
99
+ const layout: ReportLayout =
100
+ named === "grid" || named === "linear"
101
+ ? named
102
+ : hasTiles || tag?.tag("dashboard") !== undefined
103
+ ? "grid"
104
+ : "linear";
105
+ if (layout === "linear" && !hasTiles)
106
+ return named !== undefined && named !== "grid" && named !== "linear"
107
+ ? { status: "cells-removed", unknownLayout: named }
108
+ : { status: "cells-removed" };
109
+ return { status: "report", layout };
89
110
  }
90
111
 
91
112
  /**
@@ -30,9 +30,10 @@ export const GAP_TYPE = "gap";
30
30
  /**
31
31
  * The sensors: the library's own, with one addition.
32
32
  *
33
- * `activatorElements`: the whole tile starts a pointer drag,
34
- * not only the grip. A 22px corner that appears on hover is not a target a
35
- * reader finds; the whole card is. The grip stays the `handle`, which is what
33
+ * `activatorElements`: the whole tile starts a pointer drag, not only the
34
+ * grip, except inside its rendered result (see `preventActivation`). A 22px
35
+ * corner that appears on hover is not a target a reader finds; the card's
36
+ * heading and padding are. The grip stays the `handle`, which is what
36
37
  * gives it keyboard focus and the screen-reader instructions — and, by the
37
38
  * library's own rule, a press on the handle drags at once while a press
38
39
  * anywhere else on the card waits for a short hold or a few pixels of travel,
@@ -45,12 +46,16 @@ export const builderSensors = [
45
46
  PointerSensor.configure({
46
47
  activatorElements: (source) => [source.element],
47
48
  // A press on a control of the tile's own that is not a button — the
48
- // resize edge — is that control's gesture, never a move. The library's
49
- // own check only knows buttons, links and inputs, and it listens on the
50
- // tile natively, before any React handler on the control could stop it.
49
+ // resize edge — is that control's gesture, never a move. So is a press
50
+ // inside the result: a table scrolls and selects, a chart shows its
51
+ // tooltips, and a move that started there fought both. A tile moves from
52
+ // its heading and its padding. The library's own check only knows
53
+ // buttons, links and inputs, and it listens on the tile natively, before
54
+ // any React handler on the control could stop it.
51
55
  preventActivation: (event, source) =>
52
56
  (event.target instanceof Element &&
53
- event.target.closest(`[${NO_DRAG}]`) !== null) ||
57
+ event.target.closest(`[${NO_DRAG}], ${RESULT_SELECTOR}`) !==
58
+ null) ||
54
59
  (PointerSensor.defaults.preventActivation?.(event, source) ?? false),
55
60
  }),
56
61
  KeyboardSensor,
@@ -59,6 +64,9 @@ export const builderSensors = [
59
64
  /** Marks an element inside a tile whose presses must never start a move. */
60
65
  export const NO_DRAG = "data-no-drag";
61
66
 
67
+ /** A rendered result inside a tile: its table, chart or cards, where a press is the result's, not a move. */
68
+ const RESULT_SELECTOR = ".malloy-render, .malloy-table";
69
+
62
70
  /**
63
71
  * What a tile looks like while it is dragged: a COPY follows the pointer, and
64
72
  * the tile itself stays in the flow at its previewed place, dimmed. The
@@ -69,7 +69,7 @@ describe("spliceDashboardDocument: imports", () => {
69
69
  {
70
70
  modelPath: "dashboards/blank.malloy",
71
71
  textHeld: false,
72
- notebook: false,
72
+ widths: true,
73
73
  },
74
74
  );
75
75
  });
@@ -2,7 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import { describe, expect, it } from "bun:test";
5
- import { conversionRefused, convertLegacyNotebook } from "./legacyNotebook";
6
5
  import { quoteFilterLiterals } from "./tagParse";
7
6
  import { readDashboardDocument, readFailed } from "./readDocument";
8
7
  import { spliceDashboardDocument, spliceFailed } from "./spliceDocument";
@@ -23,15 +22,6 @@ const BLOCK = `##! experimental.givens
23
22
  }
24
23
  |##
25
24
  ${BODY}`;
26
- const LEGACY = (tag: string) => `##! experimental.givens
27
- ${tag}
28
- import "../models/orders.malloy"
29
-
30
- ##(markdown) Hello
31
-
32
- run: orders -> kpis
33
- `;
34
-
35
25
  describe("filter-literal givens in the artifact tag", () => {
36
26
  for (const [name, text] of [
37
27
  ["line", LINE],
@@ -57,36 +47,6 @@ describe("filter-literal givens in the artifact tag", () => {
57
47
  });
58
48
  }
59
49
 
60
- for (const [name, tag] of [
61
- [
62
- "line",
63
- "## artifact { layout=linear autorun=false givens { REGION=f'US' } }",
64
- ],
65
- [
66
- "block",
67
- "##| artifact { layout=linear\n autorun=false\n givens { REGION=f'US' }\n}\n|##",
68
- ],
69
- ]) {
70
- it(`converts a legacy notebook with the ${name} tag and keeps the literal as written`, async () => {
71
- const result = await convertLegacyNotebook(LEGACY(tag));
72
- if (conversionRefused(result)) throw new Error(result.refused);
73
- expect(result.text).toContain("givens { REGION=f'US' }");
74
- const read = await readDashboardDocument(result.text);
75
- if (readFailed(read)) throw new Error(read.reason);
76
- expect(read.document.startingGivens).toEqual({ REGION: "f'US'" });
77
- });
78
- }
79
-
80
- it("reads a legacy notebook with a filter literal as a legacy notebook", async () => {
81
- const read = await readDashboardDocument(
82
- LEGACY(
83
- "## artifact { layout=linear autorun=false givens { REGION=f'US' } }",
84
- ),
85
- );
86
- if (!readFailed(read)) throw new Error("expected a refusal");
87
- expect(read.legacyNotebook).toBe(true);
88
- });
89
-
90
50
  it("surfaces the tag's own syntax error when it does not parse", async () => {
91
51
  const read = await readDashboardDocument(
92
52
  LINE.replace("tiles=[", "tiles=[[[[").replace("autorun=false", "="),
@@ -18,8 +18,28 @@ export function editInline(
18
18
  }
19
19
 
20
20
  /** Close an open tile menu: Escape inside it, now that no field in it holds focus. */
21
- export const closeMenu = () =>
22
- fireEvent.keyDown(
23
- screen.getByRole("button", { name: "Delete", hidden: true }),
24
- { key: "Escape" },
25
- );
21
+ export function closeMenu() {
22
+ const menu = document.querySelector(".MuiPopover-paper");
23
+ if (!menu) throw new Error("no tile menu is open");
24
+ fireEvent.keyDown(menu, { key: "Escape" });
25
+ }
26
+
27
+ /** A view in the add-tile picker, by its Malloy name; within one source's group when `source` is given. */
28
+ export const viewOption = (view: string, source?: string): HTMLElement => {
29
+ const scope = source
30
+ ? within(screen.getByRole("group", { name: source, hidden: true }))
31
+ : screen;
32
+ return scope.getAllByRole("option", {
33
+ name: (name) => name.endsWith(`(${view})`),
34
+ hidden: true,
35
+ })[0]!;
36
+ };
37
+
38
+ /** {@link viewOption}, once the picker has listed it. */
39
+ export const findViewOption = async (view: string): Promise<HTMLElement> =>
40
+ (
41
+ await screen.findAllByRole("option", {
42
+ name: (name) => name.endsWith(`(${view})`),
43
+ hidden: true,
44
+ })
45
+ )[0]!;