@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
@@ -1,25 +1,24 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { Button } from "@mui/material";
5
- import type { ComponentProps } from "react";
6
- import { AppDialog } from "../AppDialog";
4
+ import { useState, type ComponentProps, type ReactNode } from "react";
7
5
  import { UnsavedChangesDialog } from "../UnsavedChangesDialog";
8
- import { AddTileDialog } from "./AddTileDialog";
6
+ import { AddTileDialog, type ViewPreview } from "./AddTileDialog";
9
7
  import type { PackageCatalog } from "./catalog";
8
+ import { duplicateBlocked } from "./addTileToDocument";
10
9
  import { isQueryTile } from "./document";
11
10
  import { DrillDialog } from "./DrillDialog";
12
11
  import { FilterDialog } from "./FilterDialog";
13
12
  import { TileMenu } from "./TileMenu";
14
- import type { ConversionConfirm } from "./useConversionConfirm";
13
+ import { tileDisplayTitle } from "./tileDisplayTitle";
15
14
  import type { useControlBindings } from "./useControlBindings";
16
15
  import type { ReportEditorHandle } from "./useReportEditor";
17
16
  import type { useTileEditing } from "./useTileEditing";
18
17
 
19
18
  /**
20
19
  * Every window the builder opens, each driven by state its hooks hold: the
21
- * filter window, a tile's menu, the clickable-cells window, the conversion
22
- * question, the unsaved-changes guard and the add-tile picker.
20
+ * filter window, a tile's menu, the clickable-cells window, the
21
+ * unsaved-changes guard and the add-tile picker.
23
22
  */
24
23
  export function BuilderDialogs({
25
24
  editor,
@@ -30,8 +29,9 @@ export function BuilderDialogs({
30
29
  tiles,
31
30
  drillSource,
32
31
  setDrillSource,
33
- confirmConversion,
34
32
  exitDialog,
33
+ renderViewPreview,
34
+ takenGivenNames,
35
35
  }: {
36
36
  editor: ReportEditorHandle;
37
37
  catalog: PackageCatalog | undefined;
@@ -42,11 +42,14 @@ export function BuilderDialogs({
42
42
  /** The source whose clickable cells are being edited, if any. */
43
43
  drillSource: string | undefined;
44
44
  setDrillSource: (source: string | undefined) => void;
45
- confirmConversion: ConversionConfirm | undefined;
46
45
  exitDialog: ComponentProps<typeof UnsavedChangesDialog>;
46
+ renderViewPreview?: (view: ViewPreview) => ReactNode;
47
+ takenGivenNames?: readonly string[];
47
48
  }) {
48
49
  const { filterDialog, setFilterDialog } = bindings;
49
50
  const { menu, setMenu } = tiles;
51
+ // The tile Clickable cells was opened from, for its window to name.
52
+ const [drillTile, setDrillTile] = useState<string | undefined>();
50
53
  // The catalog's view behind the tile whose menu is open, for the charts the
51
54
  // picker may offer: a reference tile's base view, else a view of the tile's own name.
52
55
  const menuAt =
@@ -74,6 +77,7 @@ export function BuilderDialogs({
74
77
  ? { control: filterDialog.control }
75
78
  : {})}
76
79
  available={bindings.available}
80
+ {...(takenGivenNames ? { takenNames: takenGivenNames } : {})}
77
81
  {...(catalog ? { fieldsFor: bindings.fieldsFor } : {})}
78
82
  onClose={() => setFilterDialog(undefined)}
79
83
  onApply={bindings.applyFilter}
@@ -94,20 +98,24 @@ export function BuilderDialogs({
94
98
  draft.tiles[at] = next;
95
99
  });
96
100
  }}
97
- onRemove={() => {
98
- if (menu !== undefined) tiles.removeTile(menu.index);
101
+ view={menuView}
102
+ onDuplicate={() => {
103
+ if (menu) tiles.duplicate(menu.index);
99
104
  }}
100
- {...(editor.document.tiles.length === 1 &&
101
- editor.saved.tiles.length > 0
102
- ? {
103
- removeBlocked: "A saved report needs at least one tile.",
104
- }
105
+ {...(menuTile && duplicateBlocked(menuTile) !== undefined
106
+ ? { duplicateBlocked: duplicateBlocked(menuTile) }
105
107
  : {})}
106
- view={menuView}
107
108
  {...((editor.document.sources.find(
108
109
  (s) => s.name === menuTile?.source,
109
110
  )?.dimensions?.length ?? 0) > 0
110
- ? { onDrills: () => setDrillSource(menuTile?.source) }
111
+ ? {
112
+ onDrills: () => {
113
+ setDrillTile(
114
+ menuTile ? tileDisplayTitle(menuTile) : undefined,
115
+ );
116
+ setDrillSource(menuTile?.source);
117
+ },
118
+ }
111
119
  : {})}
112
120
  />
113
121
  <DrillDialog
@@ -116,6 +124,7 @@ export function BuilderDialogs({
116
124
  source={editor.document.sources.find((s) => s.name === drillSource)}
117
125
  givenNames={bindings.controlList.map((c) => c.name)}
118
126
  dashboards={dashboards ?? []}
127
+ {...(drillTile ? { tileLabel: drillTile } : {})}
119
128
  onClose={() => setDrillSource(undefined)}
120
129
  onApply={(drills) =>
121
130
  editor.update((draft) => {
@@ -128,27 +137,6 @@ export function BuilderDialogs({
128
137
  })
129
138
  }
130
139
  />
131
- <AppDialog
132
- open={confirmConversion !== undefined}
133
- onClose={() => confirmConversion?.stop()}
134
- title="Convert this report?"
135
- description="Saving rewrites this report in the tile layout. The builder cannot take that back; the file's history in your repository can."
136
- actions={
137
- <>
138
- <Button onClick={() => confirmConversion?.stop()}>
139
- Cancel
140
- </Button>
141
- <Button
142
- variant="contained"
143
- onClick={() => confirmConversion?.go()}
144
- >
145
- Convert and save
146
- </Button>
147
- </>
148
- }
149
- >
150
- {null}
151
- </AppDialog>
152
140
  <UnsavedChangesDialog {...exitDialog} />
153
141
  <AddTileDialog
154
142
  open={tiles.addingTile}
@@ -158,6 +146,7 @@ export function BuilderDialogs({
158
146
  onClose={tiles.closeAdd}
159
147
  onAdd={tiles.addTile}
160
148
  onAddText={tiles.addText}
149
+ {...(renderViewPreview ? { renderPreview: renderViewPreview } : {})}
161
150
  />
162
151
  </>
163
152
  );
@@ -5,12 +5,9 @@ import { DragDropProvider } from "@dnd-kit/react";
5
5
  import AddIcon from "@mui/icons-material/Add";
6
6
  import { Box, Button } from "@mui/material";
7
7
  import type { ReactNode, RefObject } from "react";
8
- import {
9
- DashboardGrid,
10
- GRID_GAP_PX,
11
- NOTEBOOK_GAP_PX,
12
- } from "../Dashboard/DashboardGrid";
8
+ import { DashboardGrid, GRID_GAP_PX } from "../Dashboard/DashboardGrid";
13
9
  import type { TileChrome, TileHeadingSlots } from "../Dashboard/TileCard";
10
+ import type { LayoutRules } from "../Report/layoutRules";
14
11
  import {
15
12
  isQueryTile,
16
13
  isTextTile,
@@ -38,15 +35,16 @@ export function BuilderGrid({
38
35
  reorder,
39
36
  resizing,
40
37
  gridBox,
41
- columns,
42
- notebook,
43
- chrome,
38
+ defaultSpan = 1,
39
+ rules,
44
40
  canAdd,
45
41
  selected,
46
42
  flash,
47
43
  menuIndex,
48
44
  onSelect,
49
45
  onOpenMenu,
46
+ onRemove,
47
+ removeBlocked,
50
48
  openAdd,
51
49
  editTile,
52
50
  renderTile,
@@ -55,9 +53,10 @@ export function BuilderGrid({
55
53
  reorder: ReturnType<typeof useTileReorder>;
56
54
  resizing: ReturnType<typeof useTileResize>;
57
55
  gridBox: RefObject<HTMLDivElement | null>;
58
- columns: number;
59
- notebook: boolean;
60
- chrome: TileChrome;
56
+ /** The span a tile with no `# colspan` is drawn at: as wide as the reader draws it. */
57
+ defaultSpan?: number;
58
+ /** How the document arranges tiles: columns, widths, inserting between. */
59
+ rules: LayoutRules;
61
60
  /** Whether there is a catalog to add a tile from. */
62
61
  canAdd: boolean;
63
62
  selected: number | undefined;
@@ -66,6 +65,10 @@ export function BuilderGrid({
66
65
  menuIndex: number | undefined;
67
66
  onSelect: (index: number) => void;
68
67
  onOpenMenu: (anchor: HTMLElement, index: number) => void;
68
+ /** Take a tile off the report. */
69
+ onRemove: (index: number) => void;
70
+ /** Why no tile can be removed now; set, each × says so instead. */
71
+ removeBlocked?: string;
69
72
  openAdd: (at?: number) => void;
70
73
  editTile: (key: string, change: (tile: DashboardTile) => void) => void;
71
74
  renderTile?: (
@@ -75,17 +78,21 @@ export function BuilderGrid({
75
78
  ) => ReactNode;
76
79
  }) {
77
80
  const { dragging, preview, onDragStart, onDragOver, onDragEnd } = reorder;
81
+ const { columns } = rules;
78
82
  const { resize, startResize, onResize, endResize } = resizing;
79
83
  // What the grid lays out: the document, except mid-gesture, where it is
80
84
  // the preview — the tile being resized at its previewed width, or the tiles
81
85
  // in their previewed order. So the row reflows under the pointer exactly as
82
86
  // it will once the edit lands.
83
- const shown =
87
+ const drawn = (tile: DashboardTile): DashboardTile =>
88
+ tile.colspan === undefined ? { ...tile, colspan: defaultSpan } : tile;
89
+ const shown = (
84
90
  resize !== undefined
85
91
  ? editor.document.tiles.map((each, index) =>
86
92
  index === resize.index ? { ...each, colspan: resize.span } : each,
87
93
  )
88
- : (preview ?? editor.document.tiles);
94
+ : (preview ?? editor.document.tiles)
95
+ ).map(drawn);
89
96
  // And, while a drag is live, the empty end of every row as a drop target.
90
97
  // While an edge is dragged too: narrowing a tile frees columns its row-mate
91
98
  // does not take, and an undrawn hole there read as a broken layout rather
@@ -106,14 +113,14 @@ export function BuilderGrid({
106
113
  onDragEnd={onDragEnd}
107
114
  >
108
115
  <Box ref={gridBox} sx={{ position: "relative" }}>
109
- {!notebook && (dragging || resize !== undefined) && (
116
+ {rules.widths && (dragging || resize !== undefined) && (
110
117
  <GridGuides columns={columns} />
111
118
  )}
112
119
 
113
120
  <DashboardGrid
114
121
  tiles={entries}
115
122
  columns={columns}
116
- rowGapPx={chrome === "none" ? NOTEBOOK_GAP_PX : GRID_GAP_PX}
123
+ rowGapPx={GRID_GAP_PX}
117
124
  keyOf={(entry) =>
118
125
  entry.kind === "gap"
119
126
  ? gapId(entry.after)
@@ -130,18 +137,19 @@ export function BuilderGrid({
130
137
  selected={index === selected}
131
138
  flash={tileKey(each) === flash}
132
139
  menuOpen={menuIndex === index}
133
- bare={chrome === "none"}
140
+ // Prose has no card, in either layout.
141
+ bare={isTextTile(each)}
134
142
  // Not on the last tile: the "Add tile" under the
135
143
  // list adds there already, and the two drew on top
136
144
  // of each other.
137
- {...(notebook &&
145
+ {...(rules.insertBetween &&
138
146
  canAdd &&
139
147
  index < editor.document.tiles.length - 1
140
148
  ? {
141
149
  onInsertAfter: () => openAdd(index + 1),
142
150
  }
143
151
  : {})}
144
- {...(columns > 1 && resizable(each)
152
+ {...(rules.widths && resizable(each)
145
153
  ? {
146
154
  resizing: resize?.index === index,
147
155
  width: {
@@ -163,11 +171,12 @@ export function BuilderGrid({
163
171
  : {})}
164
172
  onSelect={() => onSelect(index)}
165
173
  onOpenMenu={(anchor) => onOpenMenu(anchor, index)}
174
+ onRemove={() => onRemove(index)}
175
+ {...(removeBlocked ? { removeBlocked } : {})}
166
176
  >
167
177
  {isTextTile(each) ? (
168
178
  <TextTileBody
169
179
  tile={each}
170
- chrome={chrome}
171
180
  onChange={(markdown) =>
172
181
  editTile(tileKey(each), (tile) => {
173
182
  if (isTextTile(tile))
@@ -175,19 +184,12 @@ export function BuilderGrid({
175
184
  })
176
185
  }
177
186
  />
178
- ) : renderTile && !editor.pendingOpen ? (
179
- // Until the conversion is saved the package has none of its views to run.
180
- renderTile(each, heading(each), chrome)
187
+ ) : renderTile ? (
188
+ renderTile(each, heading(each), "card")
181
189
  ) : (
182
190
  <TilePlaceholder
183
191
  tile={each}
184
- chrome={chrome}
185
192
  heading={heading(each)}
186
- {...(editor.pendingOpen
187
- ? {
188
- note: "Preview appears after you Save",
189
- }
190
- : {})}
191
193
  />
192
194
  )}
193
195
  </TileFrame>
@@ -196,7 +198,7 @@ export function BuilderGrid({
196
198
  />
197
199
  </Box>
198
200
  </DragDropProvider>
199
- {notebook && canAdd && !empty && (
201
+ {rules.insertBetween && canAdd && !empty && (
200
202
  <Button
201
203
  size="small"
202
204
  startIcon={<AddIcon />}
@@ -1,106 +1,94 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import { Box, Stack, Typography } from "@mui/material";
4
+ import { Box } from "@mui/material";
5
5
  import type { ReactNode } from "react";
6
- import { BARE_DESCRIPTION_MARGIN_PX } from "../Dashboard/DashboardGrid";
7
- import { TileCard, type TileChrome } from "../Dashboard/TileCard";
8
6
  import { usePublisherTheme } from "../../theme/ThemeContext";
7
+ import { ReportHeader, TextTileFrame } from "../Report/ReportPage";
9
8
  import { InlineMarkdown } from "./InlineMarkdown";
10
9
  import { InlineText } from "./InlineText";
11
10
  import { selectionSx } from "./TileFrame";
12
11
  import type { ReportEditorHandle } from "./useReportEditor";
13
12
 
13
+ /** How far the description's selection ring stands off its text. */
14
+ const DESCRIPTION_RING_OFFSET_PX = 12;
15
+
14
16
  /**
15
- * The document's title, with the builder's actions on its line, and its
16
- * description beneath: both edited where they stand, as the reader sees them.
17
+ * The reader's {@link ReportHeader}, with its title and description edited
18
+ * where they stand and the builder's actions on the title's line: the same
19
+ * header in the same place, so editing a page does not move it.
17
20
  */
18
21
  export function BuilderHeader({
19
22
  editor,
20
23
  documentSlug,
21
- chrome,
22
24
  actions,
23
25
  descriptionSelected,
24
26
  selectDescription,
25
27
  }: {
26
28
  editor: ReportEditorHandle;
27
- /** Kept for callers; the title reads the same in either layout. */
28
- notebook?: boolean;
29
29
  /** The name a reader's view titles an untitled document with. */
30
30
  documentSlug: string | undefined;
31
- chrome: TileChrome;
32
31
  actions: ReactNode;
33
32
  descriptionSelected: boolean;
34
33
  selectDescription: () => void;
35
34
  }) {
36
35
  const { theme } = usePublisherTheme();
37
36
  return (
38
- <>
39
- <Stack direction="row" sx={{ alignItems: "center", gap: 2 }}>
40
- <Typography
41
- variant="h5"
42
- // The host theme's h5 weight, as the reader's title takes it.
43
- sx={{ flex: 1, minWidth: 0 }}
44
- >
45
- <InlineText
46
- value={editor.document.title}
47
- placeholder={
48
- // What a reader's view falls back to: the file's own name.
49
- documentSlug ?? "Untitled report"
50
- }
51
- ariaLabel="Report title"
52
- onCommit={(next) =>
53
- editor.update((draft) => {
54
- draft.title = next;
55
- })
56
- }
57
- />
58
- </Typography>
59
- {/* Overhangs the title's line rather than heightening it, so
60
- the title sits where the reader's view puts it. */}
61
- <Box sx={{ my: "-4px" }}>{actions}</Box>
62
- </Stack>
63
- {/* The description, drawn as a text block is in this document — a card
64
- on a dashboard, bare on a notebook, as the reader draws it —
65
- lifting on hover and selected as a tile is: one selection on the
66
- page, tile or description. */}
67
- <Box
68
- role="group"
69
- aria-label="Description"
70
- aria-current={descriptionSelected}
71
- onPointerDown={selectDescription}
72
- onFocus={selectDescription}
73
- sx={
74
- chrome === "none"
75
- ? { my: `${BARE_DESCRIPTION_MARGIN_PX}px` }
76
- : undefined
77
- }
78
- >
79
- <TileCard
80
- chrome={chrome}
81
- kind="text"
82
- sx={{
83
- // Anchors the ring a bare description draws around itself.
84
- position: "relative",
85
- overflow: "visible",
86
- ...selectionSx(theme, {
87
- selected: descriptionSelected,
88
- bare: chrome === "none",
89
- }),
90
- }}
37
+ <ReportHeader
38
+ actions={actions}
39
+ title={
40
+ <InlineText
41
+ value={editor.document.title}
42
+ placeholder={
43
+ // What a reader's view falls back to: the file's own name.
44
+ documentSlug ?? "Untitled report"
45
+ }
46
+ ariaLabel="Report title"
47
+ onCommit={(next) =>
48
+ editor.update((draft) => {
49
+ draft.title = next;
50
+ })
51
+ }
52
+ />
53
+ }
54
+ description={
55
+ // Selected as a tile is: one selection on the page, tile or
56
+ // description.
57
+ <Box
58
+ role="group"
59
+ aria-label="Description"
60
+ aria-current={descriptionSelected}
61
+ onPointerDown={selectDescription}
62
+ onFocus={selectDescription}
91
63
  >
92
- <InlineMarkdown
93
- markdown={editor.document.description ?? ""}
94
- placeholder="Add a description"
95
- onCommit={(next) =>
96
- editor.update((draft) => {
97
- if (next.trim() === "") delete draft.description;
98
- else draft.description = next;
99
- })
100
- }
101
- />
102
- </TileCard>
103
- </Box>
104
- </>
64
+ <TextTileFrame
65
+ sx={{
66
+ // Anchors the ring the bare description draws around itself.
67
+ position: "relative",
68
+ overflow: "visible",
69
+ // Wider than a grid tile's ring: the description is not in
70
+ // the grid, so its ring is not held inside a gutter, and
71
+ // a paragraph needs more room round it than a tile's prose.
72
+ ...selectionSx(theme, {
73
+ selected: descriptionSelected,
74
+ bare: true,
75
+ ringOffset: DESCRIPTION_RING_OFFSET_PX,
76
+ }),
77
+ }}
78
+ >
79
+ <InlineMarkdown
80
+ markdown={editor.document.description ?? ""}
81
+ placeholder="Add a description"
82
+ onCommit={(next) =>
83
+ editor.update((draft) => {
84
+ if (next.trim() === "") delete draft.description;
85
+ else draft.description = next;
86
+ })
87
+ }
88
+ />
89
+ </TextTileFrame>
90
+ </Box>
91
+ }
92
+ />
105
93
  );
106
94
  }
@@ -19,6 +19,86 @@ import type { ReactNode, Ref } from "react";
19
19
  import type { SavesTo } from "./documentSession";
20
20
  import { SecondaryButton } from "../buttons";
21
21
  import { MOD } from "./useBuilderShortcuts";
22
+ import { edgeColor, hoverEdgeColor } from "../controlTokens";
23
+ import { DEFAULT_UI, type ReportUi } from "../../theme/ui";
24
+ import { usePublisherTheme } from "../../theme/ThemeContext";
25
+
26
+ /**
27
+ * The toolbar's controls at the report surfaces' one size, set here rather
28
+ * than left to the host theme: the row was five shapes (a 29px square toggle,
29
+ * a text link, round 37px icons, a 37px pill), because each control took a
30
+ * different library default.
31
+ */
32
+ export const controlSx = (
33
+ edge: string,
34
+ hoverEdge: string,
35
+ ui: ReportUi = DEFAULT_UI,
36
+ ) =>
37
+ ({
38
+ height: ui.size.control,
39
+ minHeight: ui.size.control,
40
+ px: 1.5,
41
+ borderRadius: ui.radius.control,
42
+ boxShadow: "none",
43
+ ...ui.type.control,
44
+ "&:hover": { boxShadow: "none" },
45
+ "& .MuiButton-startIcon": { mr: 0.5, "& svg": { fontSize: 18 } },
46
+ // Outlined in the report's one edge, as the segmented control, the
47
+ // filter buttons and the tiles are, rather than the host's button grey.
48
+ "&.MuiButton-outlined": {
49
+ borderColor: edge,
50
+ "&:hover": { borderColor: hoverEdge },
51
+ },
52
+ }) as const;
53
+
54
+ export const iconControlSx = (ui: ReportUi = DEFAULT_UI) =>
55
+ ({
56
+ width: ui.size.control,
57
+ height: ui.size.control,
58
+ borderRadius: ui.radius.control,
59
+ "& svg": { fontSize: 18 },
60
+ }) as const;
61
+
62
+ /** Short rules between groups: the height of a label, not of the row. */
63
+ export const dividerSx = {
64
+ height: 20,
65
+ alignSelf: "center",
66
+ mx: 0.5,
67
+ my: 0,
68
+ } as const;
69
+
70
+ /**
71
+ * A segmented control, built as an outlined button group: the same edge,
72
+ * height, radius and padding as "+ Tile" beside it, each segment the full
73
+ * height of the control with a rule between them, and the chosen one tinted
74
+ * edge to edge. An inset chip inside the outline read as a control within a
75
+ * control, a size smaller than the button next to it.
76
+ */
77
+ export const segmentedSx = (edge: string, ui: ReportUi = DEFAULT_UI) =>
78
+ ({
79
+ height: ui.size.control,
80
+ boxSizing: "border-box",
81
+ borderRadius: ui.radius.control,
82
+ border: `1px solid ${edge}`,
83
+ overflow: "hidden",
84
+ bgcolor: "background.paper",
85
+ "& .MuiToggleButton-root": {
86
+ border: "none",
87
+ borderRadius: "0 !important",
88
+ m: "0 !important",
89
+ px: 1.5,
90
+ py: 0,
91
+ height: "100%",
92
+ ...ui.type.control,
93
+ color: "text.secondary",
94
+ "& + .MuiToggleButton-root": { borderLeft: `1px solid ${edge}` },
95
+ "&:hover": { bgcolor: "action.hover" },
96
+ "&.Mui-selected, &.Mui-selected:hover": {
97
+ bgcolor: "action.selected",
98
+ color: "text.primary",
99
+ },
100
+ },
101
+ }) as const;
22
102
 
23
103
  /** Where Save puts the document, in the words under the button. */
24
104
  export const SAVE_TARGET: Record<SavesTo, string> = {
@@ -83,6 +163,9 @@ export function BuilderToolbar({
83
163
  layout,
84
164
  onLayoutChange,
85
165
  }: BuilderToolbarProps) {
166
+ const { theme } = usePublisherTheme();
167
+ const edge = edgeColor(theme.cardBorder);
168
+ const hoverEdge = hoverEdgeColor(theme.cardBorder, theme.tileTitle);
86
169
  return (
87
170
  <Stack
88
171
  direction="row"
@@ -108,7 +191,7 @@ export function BuilderToolbar({
108
191
  onChange={(_event, next: "grid" | "linear" | null) => {
109
192
  if (next && next !== layout) onLayoutChange(next);
110
193
  }}
111
- sx={{ "& .MuiToggleButton-root": { py: 0.25, px: 1 } }}
194
+ sx={segmentedSx(edge, theme.ui)}
112
195
  >
113
196
  <ToggleButton value="linear" aria-label="Linear layout">
114
197
  Linear
@@ -118,24 +201,24 @@ export function BuilderToolbar({
118
201
  </ToggleButton>
119
202
  </ToggleButtonGroup>
120
203
  </Tooltip>
121
- <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
204
+ <Divider orientation="vertical" sx={dividerSx} />
122
205
  </>
123
206
  )}
124
207
  {/* What the page is made of. */}
125
208
  {onAddTile && (
126
209
  <Button
210
+ variant="outlined"
127
211
  startIcon={<AddIcon />}
128
212
  onClick={onAddTile}
129
213
  aria-label="Add tile"
214
+ sx={controlSx(edge, hoverEdge, theme.ui)}
130
215
  >
131
216
  Tile
132
217
  </Button>
133
218
  )}
134
219
 
135
220
  {/* What happens to a change: take it back, or put it down. */}
136
- {onAddTile && (
137
- <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
138
- )}
221
+ {onAddTile && <Divider orientation="vertical" sx={dividerSx} />}
139
222
  <Tooltip title={`Undo (${MOD}Z)`}>
140
223
  {/* A span, because a disabled button dispatches no events and a
141
224
  tooltip on one would never show. */}
@@ -144,7 +227,7 @@ export function BuilderToolbar({
144
227
  aria-label="Undo"
145
228
  disabled={!canUndo}
146
229
  onClick={onUndo}
147
- sx={{ width: 37, height: 37 }}
230
+ sx={iconControlSx(theme.ui)}
148
231
  >
149
232
  <UndoIcon fontSize="small" />
150
233
  </IconButton>
@@ -156,7 +239,7 @@ export function BuilderToolbar({
156
239
  aria-label="Redo"
157
240
  disabled={!canRedo}
158
241
  onClick={onRedo}
159
- sx={{ width: 37, height: 37 }}
242
+ sx={iconControlSx(theme.ui)}
160
243
  >
161
244
  <RedoIcon fontSize="small" />
162
245
  </IconButton>
@@ -165,7 +248,7 @@ export function BuilderToolbar({
165
248
  {/* The host's own actions, then Save, which keeps the builder open,
166
249
  then Close only when the host opted into it with `onExit`. */}
167
250
  {(actions || onSave || onExit) && (
168
- <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
251
+ <Divider orientation="vertical" sx={dividerSx} />
169
252
  )}
170
253
  {actions}
171
254
  {onSave ? (
@@ -184,7 +267,10 @@ export function BuilderToolbar({
184
267
  onClick={onSave}
185
268
  // Wide enough for the longest of the three labels, so
186
269
  // the row does not reflow as the state cycles.
187
- sx={{ minWidth: 124 }}
270
+ sx={{
271
+ ...controlSx(edge, hoverEdge, theme.ui),
272
+ minWidth: 88,
273
+ }}
188
274
  >
189
275
  {saving ? "Saving…" : dirty ? "Save" : "Saved"}
190
276
  </Button>