@malloy-publisher/sdk 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/dist/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
  2. package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
  3. package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
  4. package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +112 -115
  6. package/dist/builder/index.es.js +11766 -11502
  7. package/dist/builder-entry.d.ts +1 -1
  8. package/dist/client/api.d.ts +170 -9
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +93 -89
  11. package/dist/client-entry.d.ts +2 -0
  12. package/dist/components/ApiErrorDisplay.d.ts +11 -0
  13. package/dist/components/AppDialog.d.ts +6 -6
  14. package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
  15. package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
  16. package/dist/components/Dashboard/DashboardView.d.ts +38 -3
  17. package/dist/components/Dashboard/TileCard.d.ts +16 -2
  18. package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
  19. package/dist/components/Dashboard/index.d.ts +3 -2
  20. package/dist/components/Dashboard/telemetry.d.ts +2 -1
  21. package/dist/components/Dashboard/textSource.d.ts +19 -0
  22. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
  23. package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
  24. package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
  25. package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
  26. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
  27. package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
  28. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
  29. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
  30. package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
  31. package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
  32. package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
  33. package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
  34. package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
  35. package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
  36. package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
  37. package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
  38. package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
  39. package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
  40. package/dist/components/DashboardBuilder/imports.d.ts +19 -0
  41. package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
  42. package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
  43. package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
  44. package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
  45. package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
  46. package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
  47. package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
  48. package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
  49. package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
  50. package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
  51. package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
  52. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
  53. package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
  54. package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
  55. package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
  56. package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
  57. package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
  58. package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
  59. package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
  60. package/dist/components/Loading.d.ts +13 -0
  61. package/dist/components/Notebook/NotebookCell.d.ts +1 -5
  62. package/dist/components/Package/Package.d.ts +16 -1
  63. package/dist/components/Package/index.d.ts +1 -1
  64. package/dist/components/Prose.d.ts +1 -1
  65. package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
  66. package/dist/components/given/paramCodec.d.ts +8 -1
  67. package/dist/components/index.d.ts +1 -2
  68. package/dist/components/styles.d.ts +4 -4
  69. package/dist/hooks/givenValue.d.ts +6 -0
  70. package/dist/hooks/index.d.ts +1 -0
  71. package/dist/hooks/useCompiledDocument.d.ts +23 -0
  72. package/dist/hooks/useDocumentControls.d.ts +6 -1
  73. package/dist/hooks/useNearViewport.d.ts +16 -0
  74. package/dist/hooks/useQueryWithApiError.d.ts +7 -2
  75. package/dist/hooks/useSuggestOptions.d.ts +9 -2
  76. package/dist/index.cjs.js +14 -14
  77. package/dist/index.es.js +9760 -10363
  78. package/dist/text/index.es.js +1 -1
  79. package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
  80. package/dist/text-entry.d.ts +1 -1
  81. package/dist/theme/accent.d.ts +29 -0
  82. package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
  83. package/dist/theme/index.d.ts +3 -0
  84. package/dist/theme/keys.d.ts +1 -1
  85. package/dist/theme/motion.d.ts +31 -0
  86. package/dist/theme/readChartAnnotations.d.ts +1 -1
  87. package/dist/theme/resolveTheme.d.ts +4 -4
  88. package/dist/theme/types.d.ts +33 -5
  89. package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
  90. package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
  91. package/package.json +11 -11
  92. package/src/builder-entry.ts +1 -0
  93. package/src/client-entry.ts +8 -0
  94. package/src/clientEntry.spec.ts +17 -0
  95. package/src/components/ApiErrorDisplay.tsx +37 -18
  96. package/src/components/AppDialog.tsx +8 -7
  97. package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
  98. package/src/components/Dashboard/Dashboard.tsx +2 -2
  99. package/src/components/Dashboard/DashboardGrid.tsx +23 -5
  100. package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
  101. package/src/components/Dashboard/DashboardTile.tsx +95 -31
  102. package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
  103. package/src/components/Dashboard/DashboardView.tsx +165 -89
  104. package/src/components/Dashboard/RowsDialog.tsx +3 -2
  105. package/src/components/Dashboard/TileCard.tsx +17 -2
  106. package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
  107. package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
  108. package/src/components/Dashboard/index.ts +11 -2
  109. package/src/components/Dashboard/telemetry.ts +2 -1
  110. package/src/components/Dashboard/textSource.spec.ts +36 -0
  111. package/src/components/Dashboard/textSource.ts +39 -0
  112. package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
  113. package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
  114. package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
  115. package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
  116. package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
  117. package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
  118. package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
  119. package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
  120. package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
  121. package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
  122. package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
  123. package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
  124. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
  125. package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
  126. package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
  127. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
  128. package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
  129. package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
  130. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
  131. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
  132. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
  133. package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
  134. package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
  135. package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
  136. package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
  137. package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
  138. package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
  139. package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
  140. package/src/components/DashboardBuilder/InlineText.tsx +23 -17
  141. package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
  142. package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
  143. package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
  144. package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
  145. package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
  146. package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
  147. package/src/components/DashboardBuilder/builderReport.ts +74 -0
  148. package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
  149. package/src/components/DashboardBuilder/catalog.ts +0 -36
  150. package/src/components/DashboardBuilder/controls.spec.ts +1 -1
  151. package/src/components/DashboardBuilder/controls.ts +1 -1
  152. package/src/components/DashboardBuilder/documentSession.ts +3 -2
  153. package/src/components/DashboardBuilder/imports.spec.ts +61 -0
  154. package/src/components/DashboardBuilder/imports.ts +93 -0
  155. package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
  156. package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
  157. package/src/components/DashboardBuilder/malloyTree.ts +5 -1
  158. package/src/components/DashboardBuilder/newDashboard.ts +1 -1
  159. package/src/components/DashboardBuilder/preview.ts +1 -1
  160. package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
  161. package/src/components/DashboardBuilder/readDocument.ts +10 -4
  162. package/src/components/DashboardBuilder/readForEditor.ts +7 -2
  163. package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
  164. package/src/components/DashboardBuilder/sortable.tsx +11 -0
  165. package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
  166. package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
  167. package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
  168. package/src/components/DashboardBuilder/testing/inline.ts +1 -1
  169. package/src/components/DashboardBuilder/testing/resize.ts +48 -0
  170. package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
  171. package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
  172. package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
  173. package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
  174. package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
  175. package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
  176. package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
  177. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
  178. package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
  179. package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
  180. package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
  181. package/src/components/DashboardBuilder/useDraft.ts +15 -2
  182. package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
  183. package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
  184. package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
  185. package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
  186. package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
  187. package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
  188. package/src/components/DashboardBuilder/useTileResize.ts +133 -0
  189. package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
  190. package/src/components/DocumentCreate/guards.ts +1 -1
  191. package/src/components/Environment/Environment.tsx +0 -10
  192. package/src/components/Loading.tsx +14 -0
  193. package/src/components/Model/Model.tsx +16 -9
  194. package/src/components/Model/ModelExplorer.tsx +2 -2
  195. package/src/components/Notebook/Notebook.tsx +6 -2
  196. package/src/components/Notebook/NotebookCell.tsx +90 -215
  197. package/src/components/Package/Package.artifacts.spec.tsx +8 -12
  198. package/src/components/Package/Package.create.spec.tsx +22 -1
  199. package/src/components/Package/Package.tsx +51 -27
  200. package/src/components/Package/index.ts +1 -1
  201. package/src/components/Prose.spec.tsx +37 -0
  202. package/src/components/Prose.tsx +35 -5
  203. package/src/components/RenderedResult/RenderedResult.tsx +5 -7
  204. package/src/components/RenderedResult/ResultContainer.tsx +7 -2
  205. package/src/components/RenderedResult/ResultPanel.tsx +20 -5
  206. package/src/components/RenderedResult/loadRenderer.ts +42 -0
  207. package/src/components/given/GivenInput.spec.tsx +5 -5
  208. package/src/components/given/GivenInput.tsx +46 -38
  209. package/src/components/given/GivensPanel.tsx +2 -8
  210. package/src/components/given/paramCodec.ts +27 -1
  211. package/src/components/index.ts +1 -2
  212. package/src/components/styles.ts +4 -5
  213. package/src/hooks/givenValue.ts +9 -0
  214. package/src/hooks/index.ts +4 -0
  215. package/src/hooks/useCompiledDocument.spec.tsx +86 -0
  216. package/src/hooks/useCompiledDocument.ts +59 -0
  217. package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
  218. package/src/hooks/useDocumentControls.ts +13 -1
  219. package/src/hooks/useNearViewport.spec.tsx +150 -0
  220. package/src/hooks/useNearViewport.ts +102 -0
  221. package/src/hooks/useQueryResult.ts +7 -1
  222. package/src/hooks/useQueryWithApiError.ts +10 -3
  223. package/src/hooks/useRawQueryData.ts +3 -1
  224. package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
  225. package/src/hooks/useSuggestOptions.ts +42 -10
  226. package/src/text-entry.ts +1 -1
  227. package/src/textEntry.spec.ts +2 -8
  228. package/src/theme/accent.spec.ts +116 -0
  229. package/src/theme/accent.ts +148 -0
  230. package/src/theme/buildTableCssVars.spec.ts +24 -0
  231. package/src/theme/buildTableCssVars.ts +1 -2
  232. package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
  233. package/src/theme/buildVegaThemeOverride.ts +5 -5
  234. package/src/theme/defaults.ts +34 -0
  235. package/src/theme/index.ts +9 -0
  236. package/src/theme/keys.ts +6 -0
  237. package/src/theme/motion.ts +44 -0
  238. package/src/theme/readChartAnnotations.spec.ts +18 -0
  239. package/src/theme/readChartAnnotations.ts +1 -1
  240. package/src/theme/resolveTheme.spec.ts +73 -0
  241. package/src/theme/resolveTheme.ts +61 -20
  242. package/src/theme/types.ts +30 -5
  243. package/src/utils/queryClient.ts +8 -0
  244. package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
  245. package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
  246. package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
  247. package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
  248. package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
  249. package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
  250. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
  251. package/dist/components/DashboardBuilder/diff.d.ts +0 -35
  252. package/src/components/Dashboard/DashboardBar.tsx +0 -88
  253. package/src/components/Dashboard/ExploreDialog.tsx +0 -89
  254. package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
  255. package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
  256. package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
  257. package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
  258. package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
  259. package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
  260. package/src/components/DashboardBuilder/diff.spec.ts +0 -44
  261. package/src/components/DashboardBuilder/diff.ts +0 -93
  262. /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
  263. /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
  264. /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
@@ -2,25 +2,20 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import AddIcon from "@mui/icons-material/Add";
5
- import TuneIcon from "@mui/icons-material/Tune";
6
5
  import CheckIcon from "@mui/icons-material/Check";
7
- import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
8
6
  import RedoIcon from "@mui/icons-material/Redo";
9
7
  import UndoIcon from "@mui/icons-material/Undo";
10
8
  import {
11
9
  Box,
12
10
  Button,
13
- Chip,
14
11
  Divider,
15
12
  IconButton,
13
+ Stack,
16
14
  Tooltip,
17
- Typography,
18
15
  } from "@mui/material";
19
16
  import type { ReactNode, Ref } from "react";
20
- import { usePublisherTheme } from "../../theme/ThemeContext";
21
- import { SecondaryButton } from "../buttons";
22
- import { DashboardBar } from "../Dashboard/DashboardBar";
23
17
  import type { SavesTo } from "./documentSession";
18
+ import { SecondaryButton } from "../buttons";
24
19
  import { MOD } from "./useBuilderShortcuts";
25
20
 
26
21
  /** Where Save puts the document, in the words under the button. */
@@ -31,17 +26,13 @@ export const SAVE_TARGET: Record<SavesTo, string> = {
31
26
  };
32
27
 
33
28
  /**
34
- * The edit bar across the top of the builder: that you are editing on the
35
- * left, what you can do about it on the right, in the same {@link DashboardBar}
36
- * the reader's view uses, so switching modes swaps the contents of one bar
37
- * rather than replacing one bar with a different one.
29
+ * The builder's actions, as one row with no bar of its own, at the right of
30
+ * the page title's line.
38
31
  *
39
- * The right-hand controls are grouped by what they do, separated rather than
40
- * run together: change the page (a tile, its settings), take a change back or
41
- * put it down (undo, redo, save), and leave (Done, where the reader's view has
42
- * Edit). Sticky, so undo and save stay in reach on a long dashboard; the
43
- * reader's own header (title and description) stays in the page below it
44
- * rather than being repeated here.
32
+ * Grouped by what they do, separated rather than run together: change the page
33
+ * (a tile), take a change back (undo, redo), and keep it (Save,
34
+ * which saves in place: the builder stays open, and leaving is the page's
35
+ * own navigation).
45
36
  */
46
37
  export interface BuilderToolbarProps {
47
38
  canUndo: boolean;
@@ -52,20 +43,21 @@ export interface BuilderToolbarProps {
52
43
  saving: boolean;
53
44
  /** Absent when the builder has nowhere to save: no Save, no unsaved marker. */
54
45
  onSave?: () => void;
55
- /** Where Save writes, shown under the button. */
46
+ /** Where Save writes, shown in its tooltip. */
56
47
  savesTo?: SavesTo;
57
48
  /** The backend's own words for where Save writes; replaces the generic line for `savesTo`. */
58
49
  saveLabel?: string;
59
50
  /** The Save button, so focus can return to it after an Undo save. */
60
51
  saveButton?: Ref<HTMLButtonElement>;
61
- /** The host's own extra actions, beside Done. */
52
+ /** The host's own extra actions, beside Save. */
62
53
  actions?: ReactNode;
63
- /** Leave editing: draws "Close" at the right edge. Absent, no such button. */
64
- onExit?: () => void;
65
54
  /** Open the add-tile picker. Absent when the host passed no catalog to pick from. */
66
55
  onAddTile?: () => void;
67
- /** Open the page's settings, anchored to the button that asked. Absent, no Settings button. */
68
- onSettings?: (anchor: HTMLElement) => void;
56
+ /**
57
+ * Leave the builder: draws Close after Save, for a host that opts in. The
58
+ * Console leaves from its own header and passes nothing.
59
+ */
60
+ onExit?: () => void;
69
61
  }
70
62
 
71
63
  export function BuilderToolbar({
@@ -80,37 +72,21 @@ export function BuilderToolbar({
80
72
  saveLabel,
81
73
  saveButton,
82
74
  actions,
83
- onExit,
84
75
  onAddTile,
85
- onSettings,
76
+ onExit,
86
77
  }: BuilderToolbarProps) {
87
- const { theme } = usePublisherTheme();
88
78
  return (
89
- <DashboardBar
90
- left={
91
- <Chip
92
- // The app's theme makes every chip small; this one stands in a
93
- // row of buttons, so it says otherwise and takes their height
94
- // and type size. One size across the bar, or the state reads as
95
- // a label that shrank away from the controls.
96
- size="medium"
97
- variant="outlined"
98
- icon={<EditOutlinedIcon sx={{ fontSize: 20 }} />}
99
- label="Editing"
100
- sx={{
101
- height: 37,
102
- fontSize: "0.875rem",
103
- fontWeight: 500,
104
- // The app's own chip: the page's edge and its secondary
105
- // text, not a filled blue badge borrowed from the drill
106
- // link, which read as a notification rather than a state.
107
- border: theme.border,
108
- color: theme.tileTitle,
109
- "& .MuiChip-icon": { color: "inherit" },
110
- "& .MuiChip-label": { fontSize: "0.875rem" },
111
- }}
112
- />
113
- }
79
+ <Stack
80
+ direction="row"
81
+ aria-label="Builder actions"
82
+ sx={{
83
+ alignItems: "center",
84
+ gap: 0.5,
85
+ // A button's label never wraps onto a second line; the filter
86
+ // chips beside the row give way first.
87
+ flexShrink: 0,
88
+ "& .MuiButton-root": { whiteSpace: "nowrap" },
89
+ }}
114
90
  >
115
91
  {/* What the page is made of. */}
116
92
  {onAddTile && (
@@ -122,17 +98,11 @@ export function BuilderToolbar({
122
98
  Tile
123
99
  </Button>
124
100
  )}
125
- {onSettings && (
126
- <Button
127
- startIcon={<TuneIcon />}
128
- onClick={(event) => onSettings(event.currentTarget)}
129
- >
130
- Settings
131
- </Button>
132
- )}
133
101
 
134
102
  {/* What happens to a change: take it back, or put it down. */}
135
- <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
103
+ {onAddTile && (
104
+ <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
105
+ )}
136
106
  <Tooltip title={`Undo (${MOD}Z)`}>
137
107
  {/* A span, because a disabled button dispatches no events and a
138
108
  tooltip on one would never show. */}
@@ -159,61 +129,64 @@ export function BuilderToolbar({
159
129
  </IconButton>
160
130
  </span>
161
131
  </Tooltip>
162
- {onSave && (
163
- <>
164
- <Box
165
- sx={{
166
- display: "flex",
167
- flexDirection: "column",
168
- alignItems: "center",
169
- }}
170
- >
171
- <Tooltip title={dirty ? `Save (${MOD}S)` : ""}>
172
- <span>
173
- <Button
174
- ref={saveButton}
175
- variant={dirty ? "contained" : "outlined"}
176
- disabled={!dirty || saving}
177
- onClick={onSave}
178
- // Wide enough for the longest of the three labels, so
179
- // the bar does not reflow as the state cycles.
180
- sx={{ minWidth: 124 }}
181
- >
182
- {/* Says what will happen, then that it is happening,
183
- then what did. One tick in the bar, on "Done
184
- editing"; here the word carries the state. */}
185
- {saving
186
- ? "Saving…"
187
- : dirty
188
- ? "Save changes"
189
- : "Saved"}
190
- </Button>
191
- </span>
192
- </Tooltip>
193
- <Typography
194
- variant="caption"
195
- sx={{ fontSize: 11, lineHeight: 1.2, opacity: 0.7 }}
132
+ {/* The host's own actions, then Save, which keeps the builder open,
133
+ then Close only when the host opted into it with `onExit`. */}
134
+ {(actions || onSave || onExit) && (
135
+ <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
136
+ )}
137
+ {actions}
138
+ {onSave ? (
139
+ <Tooltip
140
+ title={
141
+ dirty
142
+ ? `Save (${MOD}S) · ${saveLabel ?? SAVE_TARGET[savesTo]}`
143
+ : (saveLabel ?? SAVE_TARGET[savesTo])
144
+ }
145
+ >
146
+ <span>
147
+ <Button
148
+ ref={saveButton}
149
+ variant={dirty ? "contained" : "outlined"}
150
+ disabled={!dirty || saving}
151
+ onClick={onSave}
152
+ // Wide enough for the longest of the three labels, so
153
+ // the row does not reflow as the state cycles.
154
+ sx={{ minWidth: 124 }}
196
155
  >
197
- {saveLabel ?? SAVE_TARGET[savesTo]}
198
- </Typography>
199
- </Box>
200
- </>
156
+ {saving ? "Saving…" : dirty ? "Save" : "Saved"}
157
+ </Button>
158
+ </span>
159
+ </Tooltip>
160
+ ) : null}
161
+ {onSave && (
162
+ // The save state, said aloud: the button's face changes, which a
163
+ // screen reader does not announce on its own.
164
+ <Box
165
+ component="span"
166
+ aria-live="polite"
167
+ sx={{
168
+ position: "absolute",
169
+ width: "1px",
170
+ height: "1px",
171
+ overflow: "hidden",
172
+ clipPath: "inset(50%)",
173
+ whiteSpace: "nowrap",
174
+ }}
175
+ >
176
+ {saving
177
+ ? "Saving"
178
+ : dirty
179
+ ? "Unsaved changes"
180
+ : "All changes saved"}
181
+ </Box>
201
182
  )}
202
-
203
- {/* Leaving, where the reader's view has Edit. */}
204
- {(actions || onExit) && (
205
- <>
206
- <Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
207
- {actions}
208
- {onExit && (
209
- <SecondaryButton
210
- label="Close"
211
- icon={<CheckIcon />}
212
- onClick={onExit}
213
- />
214
- )}
215
- </>
183
+ {onExit && (
184
+ <SecondaryButton
185
+ label="Close"
186
+ icon={<CheckIcon />}
187
+ onClick={onExit}
188
+ />
216
189
  )}
217
- </DashboardBar>
190
+ </Stack>
218
191
  );
219
192
  }
@@ -88,6 +88,7 @@ export function ChartPicker({
88
88
  disabledReason,
89
89
  onOpen,
90
90
  onChange,
91
+ variant = "standard",
91
92
  }: {
92
93
  state: ChartState;
93
94
  /** The catalog's view this cell runs, when it is one the catalog knows. */
@@ -100,6 +101,8 @@ export function ChartPicker({
100
101
  /** The choices are being looked at, which is when a host may fetch what it needs to offer more. */
101
102
  onOpen?: () => void;
102
103
  onChange: (next: ChartState) => void;
104
+ /** The field's look: underlined in a compact menu, outlined beside a dialog's other fields. */
105
+ variant?: "standard" | "outlined";
103
106
  }) {
104
107
  const choices = chartChoices(view, state, viewStatus);
105
108
  const reasonId = useId();
@@ -107,7 +110,7 @@ export function ChartPicker({
107
110
  <TextField
108
111
  select
109
112
  size="small"
110
- variant="standard"
113
+ variant={variant}
111
114
  label="Viz type"
112
115
  value={state}
113
116
  disabled={disabledReason !== undefined}
@@ -92,7 +92,7 @@ describe("DashboardBuilder: charts", () => {
92
92
  choose("a by_cat", "Line");
93
93
  closeMenu();
94
94
  fireEvent.click(
95
- screen.getByRole("button", { name: "Save changes", hidden: true }),
95
+ screen.getByRole("button", { name: "Save", hidden: true }),
96
96
  );
97
97
  await waitFor(() => expect(written).toBeDefined());
98
98
  expect(written).toContain(
@@ -110,7 +110,7 @@ describe("DashboardBuilder: charts", () => {
110
110
  choose("a by_cat", "From the view");
111
111
  closeMenu();
112
112
  const save = screen.queryByRole("button", {
113
- name: "Save changes",
113
+ name: "Save",
114
114
  hidden: true,
115
115
  });
116
116
  expect(save === null || (save as HTMLButtonElement).disabled).toBe(true);
@@ -133,9 +133,9 @@ describe("DashboardBuilder: charts", () => {
133
133
  ).toBe("true");
134
134
  expect(screen.getByText(/is not one the builder models/)).toBeDefined();
135
135
  closeMenu();
136
- editInline("by_brand", "Tile title", "Brands");
136
+ editInline("By brand", "Tile title", "Brands");
137
137
  fireEvent.click(
138
- screen.getByRole("button", { name: "Save changes", hidden: true }),
138
+ screen.getByRole("button", { name: "Save", hidden: true }),
139
139
  );
140
140
  await waitFor(() => expect(written).toBeDefined());
141
141
  expect(written).toContain(" # bar_chart { size=spark }\n");
@@ -180,7 +180,7 @@ describe("DashboardBuilder: charts", () => {
180
180
  choose("new tile", "Big value");
181
181
  fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
182
182
  fireEvent.click(
183
- screen.getByRole("button", { name: "Save changes", hidden: true }),
183
+ screen.getByRole("button", { name: "Save", hidden: true }),
184
184
  );
185
185
  await waitFor(() => expect(written).toBeDefined());
186
186
  expect(written).toContain(
@@ -28,9 +28,9 @@ source: a is scoped_orders extend {
28
28
 
29
29
  const mount = async (
30
30
  options: {
31
- onExit?: () => void;
32
31
  onSave?: (source: string) => Promise<void> | void;
33
32
  onDirtyChange?: (dirty: boolean) => void;
33
+ onExit?: () => void;
34
34
  } = {},
35
35
  ) => {
36
36
  const document = await openDocument(SOURCE);
@@ -38,8 +38,8 @@ const mount = async (
38
38
  <DashboardBuilder
39
39
  source={SOURCE}
40
40
  document={document}
41
- {...(options.onExit ? { onExit: options.onExit } : {})}
42
41
  {...(options.onSave ? { onSave: options.onSave } : {})}
42
+ {...(options.onExit ? { onExit: options.onExit } : {})}
43
43
  {...(options.onDirtyChange
44
44
  ? { onDirtyChange: options.onDirtyChange }
45
45
  : {})}
@@ -57,79 +57,35 @@ const retitle = () => {
57
57
  const shortcut = (key: string) =>
58
58
  fireEvent.keyDown(window, { key, ctrlKey: true, metaKey: true });
59
59
 
60
- const dialogs = () => screen.getAllByRole("dialog", { hidden: true });
61
-
62
- const settleTick = () => act(async () => {});
63
-
64
60
  afterEach(cleanup);
65
61
 
66
62
  describe("DashboardBuilder: leaving", () => {
67
- it("renders no Close without an onExit", async () => {
68
- await mount();
69
- expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
70
- });
71
-
72
- it("exits at once when nothing is unsaved", async () => {
73
- const onExit = mock(() => {});
74
- await mount({ onExit });
75
- fireEvent.click(button("Close"));
76
- expect(onExit).toHaveBeenCalledTimes(1);
77
- });
78
-
79
- it("asks first when there are edits, and Keep editing stays", async () => {
80
- const onExit = mock(() => {});
81
- await mount({ onExit, onSave: async () => {} });
82
- retitle();
83
- fireEvent.click(button("Close"));
84
- expect(screen.getByRole("dialog")).toBeDefined();
85
- fireEvent.click(button("Keep editing"));
86
- expect(onExit).not.toHaveBeenCalled();
87
- });
88
-
89
- it("Discard changes exits without saving", async () => {
90
- const onExit = mock(() => {});
91
- const onSave = mock(async () => {});
92
- await mount({ onExit, onSave });
63
+ it("draws Save and no Close when it can save", async () => {
64
+ await mount({ onSave: async () => {} });
65
+ expect(button("Saved").hasAttribute("disabled")).toBe(true);
93
66
  retitle();
94
- fireEvent.click(button("Close"));
95
- fireEvent.click(button("Discard changes"));
96
- expect(onExit).toHaveBeenCalledTimes(1);
97
- expect(onSave).not.toHaveBeenCalled();
67
+ expect(button("Save")).toBeDefined();
68
+ expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
98
69
  });
99
70
 
100
- it("Save and exit saves, then exits", async () => {
101
- const onExit = mock(() => {});
71
+ it("Save saves in place and stays in the builder", async () => {
102
72
  const onSave = mock(async () => {});
103
- await mount({ onExit, onSave });
73
+ await mount({ onSave });
104
74
  retitle();
105
- fireEvent.click(button("Close"));
106
- fireEvent.click(button("Save and exit"));
107
- await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
75
+ fireEvent.click(button("Save"));
76
+ await waitFor(() => expect(button("Saved")).toBeDefined());
108
77
  expect(onSave).toHaveBeenCalledTimes(1);
109
78
  });
110
79
 
111
80
  it("stays open when the save fails", async () => {
112
- const onExit = mock(() => {});
113
81
  const onSave = mock(async () => {
114
82
  throw new Error("nope");
115
83
  });
116
- await mount({ onExit, onSave });
84
+ await mount({ onSave });
117
85
  retitle();
118
- fireEvent.click(button("Close"));
119
- fireEvent.click(button("Save and exit"));
86
+ fireEvent.click(button("Save"));
120
87
  await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
121
88
  await screen.findByText(/nope/);
122
- expect(onExit).not.toHaveBeenCalled();
123
- });
124
-
125
- it("offers no Save and exit when the builder cannot save", async () => {
126
- await mount({ onExit: () => {} });
127
- retitle();
128
- fireEvent.click(button("Close"));
129
- expect(
130
- screen.queryByRole("button", { name: "Save and exit" }),
131
- ).toBeNull();
132
- expect(button("Discard changes")).toBeDefined();
133
89
  });
134
90
 
135
91
  it("reports clean when it unmounts dirty", async () => {
@@ -144,48 +100,83 @@ describe("DashboardBuilder: leaving", () => {
144
100
 
145
101
  const removeTile = () => {
146
102
  fireEvent.click(screen.getByLabelText("Settings for By category"));
147
- fireEvent.click(screen.getByRole("button", { name: "Remove tile" }));
103
+ fireEvent.click(screen.getByRole("button", { name: "Delete" }));
148
104
  };
149
105
 
150
106
  describe("DashboardBuilder: leaving with a structural edit", () => {
151
- it("ignores save, undo and redo shortcuts while the exit dialog is open", async () => {
107
+ it("Save writes a structural edit at once, once, and stays open", async () => {
152
108
  const onSave = mock(async () => {});
153
- await mount({ onExit: () => {}, onSave });
109
+ await mount({ onSave });
154
110
  removeTile();
155
- fireEvent.click(button("Close"));
156
- shortcut("s");
157
- shortcut("z");
158
- await settleTick();
159
- expect(dialogs()).toHaveLength(1);
160
- expect(onSave).not.toHaveBeenCalled();
161
- });
162
-
163
- it("Save and exit writes a structural edit at once, saving once and exiting once", async () => {
164
- const onExit = mock(() => {});
165
- const onSave = mock(async () => {});
166
- await mount({ onExit, onSave });
167
- removeTile();
168
- fireEvent.click(button("Close"));
169
- fireEvent.click(button("Save and exit"));
170
- await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
111
+ fireEvent.click(button("Save"));
112
+ await waitFor(() => expect(button("Saved")).toBeDefined());
171
113
  expect(onSave).toHaveBeenCalledTimes(1);
172
114
  });
173
115
 
174
- it("waits out a save already in flight, then exits without saving twice", async () => {
175
- const onExit = mock(() => {});
116
+ it("holds the button through a save in flight, so a second press cannot write twice", async () => {
176
117
  let finish = () => {};
177
118
  const onSave = mock(
178
119
  () => new Promise<void>((resolve) => (finish = resolve)),
179
120
  );
180
- await mount({ onExit, onSave });
121
+ await mount({ onSave });
181
122
  retitle();
182
- fireEvent.click(button("Save changes"));
123
+ shortcut("s");
183
124
  await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
125
+ expect(button("Saving…").hasAttribute("disabled")).toBe(true);
126
+ fireEvent.click(button("Saving…"));
127
+ await act(async () => finish());
128
+ await screen.findByRole("button", { name: "Saved" });
129
+ expect(onSave).toHaveBeenCalledTimes(1);
130
+ });
131
+ });
132
+
133
+ describe("DashboardBuilder: a host's opt-in Close", () => {
134
+ it("draws no Close unless the host passes onExit", async () => {
135
+ await mount({ onSave: async () => {} });
136
+ expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
137
+ });
138
+
139
+ it("draws Close beside Save, and leaves at once when nothing is unsaved", async () => {
140
+ const onExit = mock(() => {});
141
+ await mount({ onSave: async () => {}, onExit });
142
+ expect(button("Saved")).toBeDefined();
184
143
  fireEvent.click(button("Close"));
185
- fireEvent.click(button("Save and exit"));
186
- await settleTick();
144
+ expect(onExit).toHaveBeenCalledTimes(1);
145
+ });
146
+
147
+ it("asks first when there are edits, and Keep editing stays", async () => {
148
+ const onExit = mock(() => {});
149
+ await mount({ onSave: async () => {}, onExit });
150
+ retitle();
151
+ fireEvent.click(button("Close"));
152
+ fireEvent.click(
153
+ await screen.findByRole("button", { name: "Keep editing" }),
154
+ );
187
155
  expect(onExit).not.toHaveBeenCalled();
188
- await act(async () => finish());
156
+ });
157
+
158
+ it("Discard changes leaves without saving", async () => {
159
+ const onExit = mock(() => {});
160
+ const onSave = mock(async () => {});
161
+ await mount({ onSave, onExit });
162
+ retitle();
163
+ fireEvent.click(button("Close"));
164
+ fireEvent.click(
165
+ await screen.findByRole("button", { name: "Discard changes" }),
166
+ );
167
+ expect(onExit).toHaveBeenCalledTimes(1);
168
+ expect(onSave).not.toHaveBeenCalled();
169
+ });
170
+
171
+ it("Save and exit saves, then leaves", async () => {
172
+ const onExit = mock(() => {});
173
+ const onSave = mock(async () => {});
174
+ await mount({ onSave, onExit });
175
+ retitle();
176
+ fireEvent.click(button("Close"));
177
+ fireEvent.click(
178
+ await screen.findByRole("button", { name: "Save and exit" }),
179
+ );
189
180
  await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
190
181
  expect(onSave).toHaveBeenCalledTimes(1);
191
182
  });