@malloy-publisher/sdk 0.9.1 → 0.9.2

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 (292) hide show
  1. package/dist/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
  2. package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
  3. package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
  4. package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
  5. package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
  6. package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
  7. package/dist/builder/index.cjs.js +146 -58
  8. package/dist/builder/index.es.js +9076 -6479
  9. package/dist/builder-entry.d.ts +4 -0
  10. package/dist/client/api.d.ts +77 -47
  11. package/dist/client/configuration.d.ts +1 -1
  12. package/dist/client/index.cjs.js +1 -1
  13. package/dist/client/index.d.ts +1 -1
  14. package/dist/client/index.es.js +84 -82
  15. package/dist/components/Dashboard/Dashboard.d.ts +8 -15
  16. package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
  17. package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
  18. package/dist/components/Dashboard/DashboardView.d.ts +36 -0
  19. package/dist/components/Dashboard/TileCard.d.ts +15 -4
  20. package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
  21. package/dist/components/Dashboard/index.d.ts +3 -0
  22. package/dist/components/Dashboard/telemetry.d.ts +15 -3
  23. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
  24. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
  25. package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
  26. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
  27. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
  28. package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
  29. package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
  30. package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
  31. package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
  32. package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
  33. package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
  34. package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
  35. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
  36. package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
  37. package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
  38. package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
  39. package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
  40. package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
  41. package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
  42. package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
  43. package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
  44. package/dist/components/DashboardBuilder/controls.d.ts +2 -2
  45. package/dist/components/DashboardBuilder/document.d.ts +42 -26
  46. package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
  47. package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
  48. package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
  49. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
  50. package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
  51. package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
  52. package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
  53. package/dist/components/DashboardBuilder/preview.d.ts +24 -4
  54. package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
  55. package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
  56. package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
  57. package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
  58. package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
  59. package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
  60. package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
  61. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
  62. package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
  63. package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
  64. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
  65. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
  66. package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
  67. package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
  68. package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
  69. package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
  70. package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
  71. package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
  72. package/dist/components/DocumentCreate/events.d.ts +10 -0
  73. package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
  74. package/dist/components/DocumentCreate/guards.d.ts +12 -0
  75. package/dist/components/DocumentCreate/index.d.ts +6 -0
  76. package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
  77. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
  78. package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
  79. package/dist/components/NarrowEditGate.d.ts +8 -0
  80. package/dist/components/Notebook/Notebook.d.ts +1 -1
  81. package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
  82. package/dist/components/Package/Package.d.ts +1 -0
  83. package/dist/components/Package/documentLocation.d.ts +28 -0
  84. package/dist/components/Package/index.d.ts +4 -0
  85. package/dist/components/Package/useDocumentLocation.d.ts +12 -0
  86. package/dist/components/PackageSection.d.ts +2 -2
  87. package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
  88. package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
  89. package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
  90. package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
  91. package/dist/components/ServerProvider.d.ts +2 -1
  92. package/dist/components/UnsavedChangesDialog.d.ts +9 -0
  93. package/dist/components/given/GivensPanel.d.ts +2 -2
  94. package/dist/components/index.d.ts +2 -0
  95. package/dist/hooks/index.d.ts +1 -0
  96. package/dist/hooks/useNarrowScreen.d.ts +4 -0
  97. package/dist/hooks/useQueryResult.d.ts +2 -0
  98. package/dist/hooks/useSettled.d.ts +14 -0
  99. package/dist/index.cjs.js +23 -24
  100. package/dist/index.es.js +9714 -7072
  101. package/dist/text/index.cjs.js +1 -0
  102. package/dist/text/index.d.ts +2 -0
  103. package/dist/text/index.es.js +6 -0
  104. package/dist/text-entry-BJwltZiy.cjs.js +7 -0
  105. package/dist/text-entry-CbbBcZl8.es.js +196 -0
  106. package/dist/text-entry.d.ts +2 -0
  107. package/dist/utils/clock.d.ts +2 -0
  108. package/package.json +10 -1
  109. package/src/builder-entry.ts +35 -0
  110. package/src/components/Dashboard/Dashboard.tsx +27 -278
  111. package/src/components/Dashboard/DashboardGrid.tsx +68 -7
  112. package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
  113. package/src/components/Dashboard/DashboardTile.tsx +31 -4
  114. package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
  115. package/src/components/Dashboard/DashboardView.tsx +352 -0
  116. package/src/components/Dashboard/RowsDialog.tsx +1 -1
  117. package/src/components/Dashboard/TileCard.tsx +44 -10
  118. package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
  119. package/src/components/Dashboard/TileFilterTag.tsx +78 -0
  120. package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
  121. package/src/components/Dashboard/index.ts +3 -0
  122. package/src/components/Dashboard/telemetry.ts +16 -5
  123. package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
  124. package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
  125. package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
  126. package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
  127. package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
  128. package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
  129. package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
  130. package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
  131. package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
  132. package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
  133. package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
  134. package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
  135. package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
  136. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
  137. package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
  138. package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
  139. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
  140. package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
  141. package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
  142. package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
  143. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
  144. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
  145. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
  146. package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
  147. package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
  148. package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
  149. package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
  150. package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
  151. package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
  152. package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
  153. package/src/components/DashboardBuilder/InlineText.tsx +106 -0
  154. package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
  155. package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
  156. package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
  157. package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
  158. package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
  159. package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
  160. package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
  161. package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
  162. package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
  163. package/src/components/DashboardBuilder/annotationText.ts +17 -0
  164. package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
  165. package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
  166. package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
  167. package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
  168. package/src/components/DashboardBuilder/catalog.ts +61 -21
  169. package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
  170. package/src/components/DashboardBuilder/changedTile.ts +28 -0
  171. package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
  172. package/src/components/DashboardBuilder/chartLine.ts +121 -0
  173. package/src/components/DashboardBuilder/controls.spec.ts +21 -10
  174. package/src/components/DashboardBuilder/controls.ts +22 -8
  175. package/src/components/DashboardBuilder/document.ts +53 -5
  176. package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
  177. package/src/components/DashboardBuilder/documentSession.ts +257 -0
  178. package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
  179. package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
  180. package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
  181. package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
  182. package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
  183. package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
  184. package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
  185. package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
  186. package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
  187. package/src/components/DashboardBuilder/malloyText.ts +181 -27
  188. package/src/components/DashboardBuilder/malloyTree.ts +155 -7
  189. package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
  190. package/src/components/DashboardBuilder/newDashboard.ts +30 -3
  191. package/src/components/DashboardBuilder/openDraft.ts +52 -0
  192. package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
  193. package/src/components/DashboardBuilder/preview.spec.ts +159 -12
  194. package/src/components/DashboardBuilder/preview.ts +83 -9
  195. package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
  196. package/src/components/DashboardBuilder/readDocument.ts +130 -44
  197. package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
  198. package/src/components/DashboardBuilder/readForEditor.ts +47 -0
  199. package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
  200. package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
  201. package/src/components/DashboardBuilder/sortable.tsx +2 -12
  202. package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
  203. package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
  204. package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
  205. package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
  206. package/src/components/DashboardBuilder/spliceResult.ts +15 -0
  207. package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
  208. package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
  209. package/src/components/DashboardBuilder/tagParse.ts +103 -0
  210. package/src/components/DashboardBuilder/telemetry.ts +47 -0
  211. package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
  212. package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
  213. package/src/components/DashboardBuilder/testing/inline.ts +25 -0
  214. package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
  215. package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
  216. package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
  217. package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
  218. package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
  219. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
  220. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
  221. package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
  222. package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
  223. package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
  224. package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
  225. package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
  226. package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
  227. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
  228. package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
  229. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
  230. package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
  231. package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
  232. package/src/components/DocumentCreate/canRetry.ts +19 -0
  233. package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
  234. package/src/components/DocumentCreate/createDocument.ts +159 -0
  235. package/src/components/DocumentCreate/documentPath.ts +40 -0
  236. package/src/components/DocumentCreate/events.ts +15 -0
  237. package/src/components/DocumentCreate/exportedSources.ts +25 -0
  238. package/src/components/DocumentCreate/guards.ts +45 -0
  239. package/src/components/DocumentCreate/index.ts +27 -0
  240. package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
  241. package/src/components/DocumentCreate/newNotebook.ts +44 -0
  242. package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
  243. package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
  244. package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
  245. package/src/components/Model/ModelExplorer.spec.tsx +2 -2
  246. package/src/components/Model/SourcesExplorer.tsx +2 -4
  247. package/src/components/NarrowEditGate.spec.tsx +73 -0
  248. package/src/components/NarrowEditGate.tsx +29 -0
  249. package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
  250. package/src/components/Notebook/Notebook.tsx +66 -27
  251. package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
  252. package/src/components/Package/NewDocumentDialog.tsx +401 -0
  253. package/src/components/Package/Package.artifacts.spec.tsx +190 -0
  254. package/src/components/Package/Package.create.spec.tsx +380 -0
  255. package/src/components/Package/Package.notebooks.spec.tsx +18 -0
  256. package/src/components/Package/Package.tsx +366 -171
  257. package/src/components/Package/documentLocation.spec.ts +81 -0
  258. package/src/components/Package/documentLocation.ts +55 -0
  259. package/src/components/Package/index.ts +13 -0
  260. package/src/components/Package/useDocumentLocation.ts +59 -0
  261. package/src/components/PackageSection.tsx +2 -2
  262. package/src/components/RenderedResult/RenderedResult.tsx +18 -1
  263. package/src/components/RenderedResult/ResultContainer.tsx +44 -11
  264. package/src/components/RenderedResult/ResultPanel.tsx +4 -0
  265. package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
  266. package/src/components/RenderedResult/resultSizing.ts +14 -3
  267. package/src/components/ServerProvider.tsx +2 -1
  268. package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
  269. package/src/components/UnsavedChangesDialog.tsx +49 -0
  270. package/src/components/given/GivensPanel.spec.tsx +6 -6
  271. package/src/components/given/GivensPanel.tsx +3 -3
  272. package/src/components/index.ts +2 -0
  273. package/src/hooks/index.ts +3 -0
  274. package/src/hooks/useNarrowScreen.ts +21 -0
  275. package/src/hooks/useQueryResult.ts +16 -0
  276. package/src/hooks/useSettled.spec.ts +41 -0
  277. package/src/hooks/useSettled.ts +27 -0
  278. package/src/mainEntry.spec.ts +145 -0
  279. package/src/text-entry.ts +12 -0
  280. package/src/textEntry.spec.ts +118 -0
  281. package/src/utils/clock.spec.ts +12 -0
  282. package/src/utils/clock.ts +6 -0
  283. package/vite.config.ts +4 -0
  284. package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
  285. package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
  286. package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
  287. package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
  288. package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
  289. package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
  290. package/src/components/DashboardBuilder/useTileResize.ts +0 -110
  291. package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
  292. package/src/components/Package/NewDashboardDialog.tsx +0 -265
@@ -0,0 +1,25 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { render, screen } from "@testing-library/react";
5
+ import { describe, expect, it } from "bun:test";
6
+ import { DiffDialog } from "./DiffDialog";
7
+
8
+ describe("DiffDialog", () => {
9
+ it("marks a removed line with its sign and no strikethrough", () => {
10
+ render(
11
+ <DiffDialog
12
+ open
13
+ before={"keep\nold line\n"}
14
+ after={"keep\nnew line\n"}
15
+ onClose={() => {}}
16
+ />,
17
+ );
18
+ const removed = screen.getByText(/old line/);
19
+ expect(removed.textContent).toContain("− old line");
20
+ expect(getComputedStyle(removed).textDecorationLine).not.toBe(
21
+ "line-through",
22
+ );
23
+ expect(screen.getByText(/new line/).textContent).toContain("+ new line");
24
+ });
25
+ });
@@ -7,25 +7,16 @@ import { usePublisherTheme } from "../../theme/ThemeContext";
7
7
  import { foldUnchanged, lineDiff } from "./diff";
8
8
  import { AppDialog } from "../AppDialog";
9
9
 
10
- /**
11
- * What a save will do to the file, before it does it.
12
- *
13
- * Shown for a STRUCTURAL save — a tile added or removed — because those move
14
- * declarations and the comments beside them, and the file is git-native: a
15
- * diff is the idiom its authors already read. A property edit never needs
16
- * this; it changes one tag on one line.
17
- */
10
+ /** What the last save changed in the file, read-only: the file is git-native, and a diff is the idiom its authors already read. */
18
11
  export function DiffDialog({
19
12
  open,
20
13
  before,
21
14
  after,
22
- onConfirm,
23
15
  onClose,
24
16
  }: {
25
17
  open: boolean;
26
18
  before: string;
27
19
  after: string;
28
- onConfirm: () => void;
29
20
  onClose: () => void;
30
21
  }) {
31
22
  const { theme } = usePublisherTheme();
@@ -40,12 +31,11 @@ export function DiffDialog({
40
31
  open={open}
41
32
  onClose={onClose}
42
33
  maxWidth="md"
43
- title="Review the change to the file"
34
+ title="The change to the file"
44
35
  description={
45
36
  <>
46
- A tile was added or removed, which moves declarations. Lines the
47
- builder does not own — comments, other Malloy — are left where
48
- they were; check they still read right.{" "}
37
+ What the last save wrote. Lines the builder does not own, such as
38
+ comments and other Malloy, are left where they were.{" "}
49
39
  <Box
50
40
  component="span"
51
41
  sx={{ fontVariantNumeric: "tabular-nums" }}
@@ -54,14 +44,7 @@ export function DiffDialog({
54
44
  </Box>
55
45
  </>
56
46
  }
57
- actions={
58
- <>
59
- <Button onClick={onClose}>Keep editing</Button>
60
- <Button variant="contained" onClick={onConfirm}>
61
- Save this
62
- </Button>
63
- </>
64
- }
47
+ actions={<Button onClick={onClose}>Close</Button>}
65
48
  >
66
49
  <Box
67
50
  component="pre"
@@ -102,8 +85,6 @@ export function DiffDialog({
102
85
  : line.kind === "del"
103
86
  ? "rgba(168, 41, 31, 0.14)"
104
87
  : "transparent",
105
- textDecoration:
106
- line.kind === "del" ? "line-through" : "none",
107
88
  opacity: line.kind === "del" ? 0.8 : 1,
108
89
  }}
109
90
  >
@@ -120,7 +120,7 @@ export function DrillDialog({
120
120
  <AppDialog
121
121
  open={open}
122
122
  onClose={onClose}
123
- title="Clickable cells"
123
+ title="Drill-through"
124
124
  description="A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens."
125
125
  actions={
126
126
  <>
@@ -27,7 +27,13 @@ import {
27
27
  type ControlKind,
28
28
  type MappingRow,
29
29
  } from "./controls";
30
- import type { DashboardDocument, DashboardTile, LocalGiven } from "./document";
30
+ import {
31
+ isQueryTile,
32
+ type DashboardDocument,
33
+ type DashboardTile,
34
+ type LocalGiven,
35
+ type QueryTile,
36
+ } from "./document";
31
37
  import { AppDialog } from "../AppDialog";
32
38
 
33
39
  /**
@@ -70,7 +76,7 @@ export interface FilterDialogProps {
70
76
  * source the host has no catalog for, in which case any name is accepted
71
77
  * for it and nothing is searched.
72
78
  */
73
- fieldsFor?: (tile: DashboardTile) => readonly CatalogField[] | undefined;
79
+ fieldsFor?: (tile: QueryTile) => readonly CatalogField[] | undefined;
74
80
  onClose: () => void;
75
81
  /**
76
82
  * Bind a control. `declare` is set when the control is new to this file, or
@@ -170,7 +176,7 @@ function FieldPicker({
170
176
  * situations, and saying "from the model" about the second one is untrue.
171
177
  */
172
178
  const unbindable = (tile: DashboardTile | undefined) =>
173
- tile?.declaration.kind === "opaque"
179
+ tile && isQueryTile(tile) && tile.declaration.kind === "opaque"
174
180
  ? {
175
181
  label: "Not bindable",
176
182
  reason: `Its body is ${tile.declaration.why}, so a filter has no single place to go.`,
@@ -477,6 +483,7 @@ export function FilterDialog({
477
483
  </Stack>
478
484
  <Stack sx={{ gap: perTile ? 1 : 0 }}>
479
485
  {document.tiles.map((tile, index) => {
486
+ if (!isQueryTile(tile)) return null;
480
487
  const row = rows[index];
481
488
  const title = tile.label ?? tile.name;
482
489
  const problem = perTile ? rowProblems[index] : undefined;
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import AddIcon from "@mui/icons-material/Add";
5
+ import CancelIcon from "@mui/icons-material/Cancel";
5
6
  import FilterListIcon from "@mui/icons-material/FilterList";
6
7
  import { Box, Chip, Stack, Tooltip, Typography } from "@mui/material";
7
8
  import type { ReactNode } from "react";
@@ -9,6 +10,9 @@ import { SecondaryButton } from "../buttons";
9
10
  import { usePublisherTheme } from "../../theme/ThemeContext";
10
11
  import type { BuilderControl } from "./controls";
11
12
 
13
+ /** The `DashboardBar` is this tall and sticky; the strip pins just below it. */
14
+ const TOOLBAR_HEIGHT_PX = 49;
15
+
12
16
  /**
13
17
  * The strip under the header where the dashboard's controls are configured —
14
18
  * the ONE place: a chip per control opens its window, and "Add filter"
@@ -20,6 +24,7 @@ export function FilterStrip({
20
24
  unknownFieldsOf,
21
25
  onEdit,
22
26
  onAdd,
27
+ onRemove,
23
28
  children,
24
29
  }: {
25
30
  controls: BuilderControl[];
@@ -28,6 +33,8 @@ export function FilterStrip({
28
33
  unknownFieldsOf: (name: string, type: string | undefined) => string[];
29
34
  onEdit: (control: BuilderControl) => void;
30
35
  onAdd: () => void;
36
+ /** Take a control off the dashboard, as its window's Remove does. */
37
+ onRemove: (name: string) => void;
31
38
  /** The host's live control row. */
32
39
  children?: ReactNode;
33
40
  }) {
@@ -36,12 +43,21 @@ export function FilterStrip({
36
43
  <>
37
44
  {/* The filter band, as every dashboard builder has one. The header is the
38
45
  dashboard's controls as this FILE has them: a chip per control,
39
- which opens its window — the one place a control is edited, bound
40
- or removed, so the consequences are in view when it happens. A ×
41
- on the chip was a second place, with none of them. The live control row the caller
46
+ which opens its window; the × on a chip removes it, as the window's
47
+ Remove does. The live control row the caller
42
48
  passes in sits directly under, showing the same controls as a
43
49
  reader gets them — from the saved file. */}
44
- <Stack sx={{ gap: 1 }}>
50
+ <Stack
51
+ sx={{
52
+ gap: 1,
53
+ position: "sticky",
54
+ // Under the toolbar, which pins at the top of the same scroller.
55
+ top: TOOLBAR_HEIGHT_PX,
56
+ zIndex: 4,
57
+ bgcolor: theme.background,
58
+ pb: 1,
59
+ }}
60
+ >
45
61
  <Stack
46
62
  direction="row"
47
63
  aria-label="Filters"
@@ -97,6 +113,12 @@ export function FilterStrip({
97
113
  : "outlined"
98
114
  }
99
115
  onClick={() => onEdit(control)}
116
+ onDelete={() => onRemove(control.name)}
117
+ deleteIcon={
118
+ <CancelIcon
119
+ aria-label={`Remove filter ${control.name}`}
120
+ />
121
+ }
100
122
  sx={{
101
123
  // Faint when nothing binds it: declared, but not yet a
102
124
  // control a reader would see.
@@ -0,0 +1,184 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Box, Button, Stack, TextField, Typography } from "@mui/material";
5
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
+ import { usePublisherTheme } from "../../theme/ThemeContext";
7
+ import { Prose, type ProseVariant } from "../Prose";
8
+ import { useReportOpenDraft } from "./openDraft";
9
+ import { markdownProblem } from "./spliceDocument";
10
+ import { useDraft } from "./useDraft";
11
+
12
+ /**
13
+ * Markdown that is edited where it is read: it draws as prose, a click on it
14
+ * opens a textarea, and what was typed commits once, when the field closes.
15
+ *
16
+ * Escape and Cmd or Ctrl+Enter are Done, which holds on a draft the writer
17
+ * would refuse and says why; leaving the field commits, so the closed prose
18
+ * keeps saying what Save will refuse. Links stay inert: a click on one is not
19
+ * a way out of the builder, and not an edit either.
20
+ */
21
+ export function InlineMarkdown({
22
+ markdown,
23
+ placeholder,
24
+ onCommit,
25
+ variant = "document",
26
+ }: {
27
+ markdown: string;
28
+ /** Shown in place of empty prose. */
29
+ placeholder: string;
30
+ /** Called once per edit, with the new text, only when it differs from `markdown`. */
31
+ onCommit: (next: string) => void;
32
+ variant?: ProseVariant;
33
+ }) {
34
+ const { theme } = usePublisherTheme();
35
+ const [editing, setEditing] = useState(false);
36
+ // One object per value, or the draft would reset on every render while open.
37
+ const value = useMemo(
38
+ () => (editing ? { text: markdown } : undefined),
39
+ [editing, markdown],
40
+ );
41
+ const { draft, patch, close, discard } = useDraft<{ text: string }>(
42
+ value,
43
+ editing,
44
+ (next) => onCommit(next.text),
45
+ () => setEditing(false),
46
+ );
47
+ const draftDirty = editing && draft !== undefined && draft.text !== markdown;
48
+ const refused =
49
+ draft !== undefined && draft.text !== markdown
50
+ ? markdownProblem(draft.text)
51
+ : undefined;
52
+ useReportOpenDraft(draftDirty, () => {
53
+ if (refused !== undefined) return false;
54
+ close();
55
+ return true;
56
+ });
57
+ const actions = useRef<HTMLDivElement>(null);
58
+ const caretPlaced = useRef(false);
59
+ useEffect(() => {
60
+ if (!editing) caretPlaced.current = false;
61
+ }, [editing]);
62
+ const placeCaret = useCallback((field: HTMLTextAreaElement | null) => {
63
+ if (!field || caretPlaced.current) return;
64
+ caretPlaced.current = true;
65
+ field.setSelectionRange(field.value.length, field.value.length);
66
+ }, []);
67
+
68
+ if (!editing || draft === undefined) {
69
+ // A blur commits an invalid draft, so the closed prose keeps saying what the writer will refuse at Save.
70
+ const closedProblem = markdown.trim()
71
+ ? markdownProblem(markdown)
72
+ : undefined;
73
+ return (
74
+ <Box
75
+ role="button"
76
+ tabIndex={0}
77
+ onClick={(event) => {
78
+ if ((event.target as Element).closest("a"))
79
+ event.preventDefault();
80
+ else setEditing(true);
81
+ }}
82
+ onKeyDown={(event) => {
83
+ if (event.target !== event.currentTarget) return;
84
+ if (event.key !== "Enter" && event.key !== " ") return;
85
+ event.preventDefault();
86
+ setEditing(true);
87
+ }}
88
+ sx={{
89
+ cursor: "text",
90
+ minHeight: 24,
91
+ borderRadius: "2px",
92
+ "&:hover, &:focus-visible": {
93
+ outline: "1px dashed currentColor",
94
+ },
95
+ }}
96
+ >
97
+ {markdown.trim() ? (
98
+ <Prose variant={variant}>{markdown}</Prose>
99
+ ) : (
100
+ <Typography
101
+ variant="body2"
102
+ sx={{ color: theme.tileTitle, opacity: 0.6 }}
103
+ >
104
+ {placeholder}
105
+ </Typography>
106
+ )}
107
+ {closedProblem && (
108
+ <Typography variant="caption" color="error" role="alert">
109
+ {closedProblem}
110
+ </Typography>
111
+ )}
112
+ </Box>
113
+ );
114
+ }
115
+
116
+ // An untouched text is left as it was, so only a changed draft is held to the writer's rules.
117
+ const problem =
118
+ draft.text !== markdown ? markdownProblem(draft.text) : undefined;
119
+ const finish = () => {
120
+ if (problem === undefined) close();
121
+ };
122
+ return (
123
+ <Stack spacing={1}>
124
+ <TextField
125
+ multiline
126
+ autoFocus
127
+ minRows={3}
128
+ maxRows={14}
129
+ fullWidth
130
+ value={draft.text}
131
+ placeholder={placeholder}
132
+ error={problem !== undefined}
133
+ helperText={problem}
134
+ inputRef={placeCaret}
135
+ inputProps={{ "aria-label": "Markdown" }}
136
+ onChange={(event) =>
137
+ patch((next) => {
138
+ next.text = event.target.value;
139
+ })
140
+ }
141
+ onKeyDown={(event) => {
142
+ if (event.key === "Escape") finish();
143
+ else if (
144
+ event.key === "Enter" &&
145
+ (event.metaKey || event.ctrlKey)
146
+ ) {
147
+ event.preventDefault();
148
+ finish();
149
+ }
150
+ }}
151
+ // Moving to Done or Cancel is not leaving the edit.
152
+ onBlur={(event) => {
153
+ if (
154
+ event.relatedTarget instanceof Node &&
155
+ actions.current?.contains(event.relatedTarget)
156
+ )
157
+ return;
158
+ close();
159
+ }}
160
+ />
161
+ <Stack ref={actions} direction="row" spacing={1}>
162
+ <Button
163
+ size="small"
164
+ variant="outlined"
165
+ disabled={problem !== undefined}
166
+ onClick={finish}
167
+ >
168
+ Done
169
+ </Button>
170
+ <Button
171
+ size="small"
172
+ // Keeps focus in the field, whose blur would otherwise commit the draft Cancel is dropping.
173
+ onMouseDown={(event) => event.preventDefault()}
174
+ onClick={() => {
175
+ discard();
176
+ setEditing(false);
177
+ }}
178
+ >
179
+ Cancel
180
+ </Button>
181
+ </Stack>
182
+ </Stack>
183
+ );
184
+ }
@@ -0,0 +1,106 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Box, InputBase } from "@mui/material";
5
+ import { useRef, useState, type KeyboardEvent } from "react";
6
+ import { useReportOpenDraft } from "./openDraft";
7
+
8
+ /**
9
+ * A single line of text that is edited where it is read: a click opens a field,
10
+ * Enter or leaving it commits, Escape puts the old text back.
11
+ *
12
+ * The display is a real button, so it is a tab stop that Enter and Space open,
13
+ * and the drag sensor refuses a press that starts on one: opening an editor can
14
+ * never be the start of a move.
15
+ */
16
+ export function InlineText({
17
+ value,
18
+ placeholder,
19
+ ariaLabel,
20
+ onCommit,
21
+ faintWhenEmpty = false,
22
+ }: {
23
+ value: string;
24
+ /** Shown in place of an empty value. */
25
+ placeholder: string;
26
+ /** Names the field while it is open. */
27
+ ariaLabel: string;
28
+ /** Called once per edit, with the new text, only when it differs from `value`. */
29
+ onCommit: (next: string) => void;
30
+ /** Draws an empty value faintly, and only while its tile is hovered or focused. */
31
+ faintWhenEmpty?: boolean;
32
+ }) {
33
+ const [draft, setDraft] = useState<string | undefined>(undefined);
34
+ // A cancelled edit unmounts the field, and a browser may report that as a blur.
35
+ const cancelled = useRef(false);
36
+
37
+ const commit = () => {
38
+ if (cancelled.current || draft === undefined) return;
39
+ setDraft(undefined);
40
+ if (draft !== value) onCommit(draft);
41
+ };
42
+ useReportOpenDraft(draft !== undefined && draft !== value, () => {
43
+ commit();
44
+ return true;
45
+ });
46
+ const open = () => {
47
+ cancelled.current = false;
48
+ setDraft(value);
49
+ };
50
+
51
+ if (draft === undefined) {
52
+ const faint = value === "" && faintWhenEmpty;
53
+ return (
54
+ <Box
55
+ component="button"
56
+ type="button"
57
+ className={faint ? "builder-affordance" : undefined}
58
+ onClick={open}
59
+ onKeyDown={(event: KeyboardEvent) => {
60
+ if (event.key !== "Enter" && event.key !== " ") return;
61
+ event.preventDefault();
62
+ open();
63
+ }}
64
+ sx={{
65
+ all: "unset",
66
+ boxSizing: "border-box",
67
+ font: "inherit",
68
+ color: "inherit",
69
+ cursor: "text",
70
+ display: "inline-block",
71
+ maxWidth: "100%",
72
+ borderRadius: "2px",
73
+ opacity: faint ? 0 : 1,
74
+ fontStyle: faint ? "italic" : undefined,
75
+ "&:hover, &:focus-visible": {
76
+ outline: "1px dashed currentColor",
77
+ },
78
+ }}
79
+ >
80
+ {value === "" ? placeholder : value}
81
+ </Box>
82
+ );
83
+ }
84
+ return (
85
+ <InputBase
86
+ autoFocus
87
+ fullWidth
88
+ value={draft}
89
+ placeholder={placeholder}
90
+ inputProps={{ "aria-label": ariaLabel }}
91
+ onFocus={(event) => event.target.select()}
92
+ onChange={(event) => setDraft(event.target.value)}
93
+ onKeyDown={(event) => {
94
+ if (event.key === "Enter" && !event.nativeEvent.isComposing)
95
+ commit();
96
+ else if (event.key === "Escape") {
97
+ cancelled.current = true;
98
+ setDraft(undefined);
99
+ }
100
+ }}
101
+ onBlur={commit}
102
+ // The field takes its type from the line it replaces.
103
+ sx={{ font: "inherit", color: "inherit", p: 0, "& input": { p: 0 } }}
104
+ />
105
+ );
106
+ }
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { DashboardEditor, type DashboardEditorProps } from "./DashboardEditor";
5
+
6
+ /** The props a host passed the notebook editor before notebooks opened in the one builder. */
7
+ export type NotebookEditorProps = (
8
+ | {
9
+ /** `publisher://environments/{env}/packages/{pkg}`, optionally `?versionId=`. */
10
+ resourceUri: string;
11
+ /** The notebook's slug: `overview` for `notebooks/overview.malloy`. */
12
+ notebook: string;
13
+ }
14
+ | {
15
+ environmentName: string;
16
+ packageName: string;
17
+ /** The notebook's slug: `overview` for `notebooks/overview.malloy`. */
18
+ notebookName: string;
19
+ }
20
+ ) &
21
+ Pick<DashboardEditorProps, "onExit" | "onEvent" | "onDirtyChange" | "path">;
22
+
23
+ /** `DashboardEditor` opened on a notebook, under the name hosts already import. */
24
+ export function NotebookEditor(props: NotebookEditorProps) {
25
+ const { onExit, onEvent, onDirtyChange, path } = props;
26
+ const target =
27
+ "resourceUri" in props
28
+ ? { resourceUri: props.resourceUri, dashboard: props.notebook }
29
+ : {
30
+ environmentName: props.environmentName,
31
+ packageName: props.packageName,
32
+ dashboardName: props.notebookName,
33
+ };
34
+ return (
35
+ <DashboardEditor
36
+ {...target}
37
+ kind="notebook"
38
+ {...(onExit ? { onExit } : {})}
39
+ {...(onEvent ? { onEvent } : {})}
40
+ {...(onDirtyChange ? { onDirtyChange } : {})}
41
+ {...(path !== undefined ? { path } : {})}
42
+ />
43
+ );
44
+ }
@@ -0,0 +1,113 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Alert, Box, Button } from "@mui/material";
5
+ import { DiffDialog } from "./DiffDialog";
6
+ import type { LastSave } from "./useDocumentEditor";
7
+
8
+ export interface SaveNoticeProps {
9
+ /** The save the notice offers to take back; absent once that offer is withdrawn. */
10
+ lastSave?: LastSave & { removedComments?: string[] };
11
+ /** What the document's parts are called, singular: "tile" or "cell". */
12
+ unit: string;
13
+ /** How many parts the document had before the save and after it. */
14
+ moved: { before: number; after: number } | undefined;
15
+ canUndoSave: boolean;
16
+ /** An Undo save just landed and the offer is gone. */
17
+ undone: boolean;
18
+ /** The read-only viewer of the saved change is open. */
19
+ viewing: boolean;
20
+ onView: (open: boolean) => void;
21
+ onUndoSave: () => Promise<void> | void;
22
+ }
23
+
24
+ const plural = (count: number, unit: string) =>
25
+ `${count} ${unit}${count === 1 ? "" : "s"}`;
26
+
27
+ /** What the save did to the file, as facts the author can check before moving on. */
28
+ function facts(
29
+ { lastSave, unit, moved }: SaveNoticeProps,
30
+ comments: string[],
31
+ ): string[] {
32
+ if (!lastSave) return [];
33
+ const lines: string[] = [];
34
+ const change = moved ? moved.after - moved.before : 0;
35
+ if (change === 1) lines.push(`Added a ${unit}`);
36
+ else if (change > 1) lines.push(`Added ${plural(change, unit)}`);
37
+ else if (change < 0) lines.push(`Removed ${plural(-change, unit)}`);
38
+ else if (lastSave.structural) lines.push(`Changed the ${unit}s in the file`);
39
+ else lines.push("Saved your edits");
40
+ if (comments.length > 0)
41
+ lines.push(
42
+ `Removed ${plural(comments.length, "comment")} with their ${unit}s`,
43
+ );
44
+ if (lastSave.clearsHistory) lines.push("Undo history was cleared");
45
+ return lines;
46
+ }
47
+
48
+ /**
49
+ * What a save just did, with the way back: View change shows the file's diff
50
+ * read-only, Undo save writes the file back as it was. Stays until an edit
51
+ * withdraws the offer or the next save replaces it; nothing else hides it.
52
+ */
53
+ export function SaveNotice(props: SaveNoticeProps) {
54
+ const { lastSave, canUndoSave, undone, viewing, onView, onUndoSave } = props;
55
+ if (undone)
56
+ return (
57
+ <Alert severity="info" role="status">
58
+ Save undone. Your edits are back and unsaved.
59
+ </Alert>
60
+ );
61
+ if (!lastSave) return null;
62
+ const comments = lastSave.removedComments ?? [];
63
+ return (
64
+ <>
65
+ <Alert
66
+ severity="success"
67
+ role="status"
68
+ action={
69
+ <>
70
+ <Button
71
+ color="inherit"
72
+ size="small"
73
+ onClick={() => onView(true)}
74
+ >
75
+ View change
76
+ </Button>
77
+ <Button
78
+ color="inherit"
79
+ size="small"
80
+ disabled={!canUndoSave}
81
+ onClick={() => void onUndoSave()}
82
+ >
83
+ Undo save
84
+ </Button>
85
+ </>
86
+ }
87
+ >
88
+ {facts(props, comments).join(". ")}.
89
+ {comments.length > 0 && (
90
+ <Box
91
+ component="span"
92
+ aria-label="Comments removed with their cell"
93
+ sx={{
94
+ display: "block",
95
+ whiteSpace: "pre",
96
+ fontFamily: "monospace",
97
+ fontSize: 12,
98
+ mt: 0.5,
99
+ }}
100
+ >
101
+ {comments.join("\n")}
102
+ </Box>
103
+ )}
104
+ </Alert>
105
+ <DiffDialog
106
+ open={viewing}
107
+ before={lastSave.before}
108
+ after={lastSave.after}
109
+ onClose={() => onView(false)}
110
+ />
111
+ </>
112
+ );
113
+ }