@malloy-publisher/sdk 0.9.1 → 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 (410) hide show
  1. package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-DwB0-9Yx.es.js} +219 -210
  2. package/dist/RenderedResult-hKjFEqaN.cjs.js +141 -0
  3. package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-CcSrGaRN.es.js} +1473 -1326
  4. package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +143 -58
  6. package/dist/builder/index.es.js +12179 -9318
  7. package/dist/builder-entry.d.ts +5 -1
  8. package/dist/client/api.d.ts +247 -56
  9. package/dist/client/configuration.d.ts +1 -1
  10. package/dist/client/index.cjs.js +1 -1
  11. package/dist/client/index.d.ts +1 -1
  12. package/dist/client/index.es.js +94 -88
  13. package/dist/client-entry.d.ts +2 -0
  14. package/dist/components/ApiErrorDisplay.d.ts +11 -0
  15. package/dist/components/AppDialog.d.ts +6 -6
  16. package/dist/components/Dashboard/Dashboard.d.ts +8 -15
  17. package/dist/components/Dashboard/DashboardGrid.d.ts +38 -6
  18. package/dist/components/Dashboard/DashboardTile.d.ts +21 -2
  19. package/dist/components/Dashboard/DashboardView.d.ts +71 -0
  20. package/dist/components/Dashboard/TileCard.d.ts +30 -5
  21. package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
  22. package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
  23. package/dist/components/Dashboard/index.d.ts +5 -1
  24. package/dist/components/Dashboard/telemetry.d.ts +16 -3
  25. package/dist/components/Dashboard/textSource.d.ts +19 -0
  26. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +15 -9
  27. package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
  28. package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
  29. package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
  30. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +23 -15
  31. package/dist/components/DashboardBuilder/ChartPicker.d.ts +31 -0
  32. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +56 -21
  33. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +44 -5
  34. package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
  35. package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
  36. package/dist/components/DashboardBuilder/FilterStrip.d.ts +8 -4
  37. package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
  38. package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
  39. package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
  40. package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
  41. package/dist/components/DashboardBuilder/TextTileBody.d.ts +10 -0
  42. package/dist/components/DashboardBuilder/TileFrame.d.ts +51 -12
  43. package/dist/components/DashboardBuilder/TileMenu.d.ts +12 -6
  44. package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
  45. package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
  46. package/dist/components/DashboardBuilder/catalog.d.ts +4 -18
  47. package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
  48. package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
  49. package/dist/components/DashboardBuilder/controls.d.ts +2 -2
  50. package/dist/components/DashboardBuilder/document.d.ts +42 -26
  51. package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
  52. package/dist/components/DashboardBuilder/imports.d.ts +19 -0
  53. package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
  54. package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
  55. package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
  56. package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
  57. package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
  58. package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
  59. package/dist/components/DashboardBuilder/preview.d.ts +24 -4
  60. package/dist/components/DashboardBuilder/readDocument.d.ts +6 -1
  61. package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
  62. package/dist/components/DashboardBuilder/sortable.d.ts +16 -0
  63. package/dist/components/DashboardBuilder/spliceDocument.d.ts +15 -13
  64. package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
  65. package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
  66. package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
  67. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
  68. package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
  69. package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
  70. package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
  71. package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
  72. package/dist/components/DashboardBuilder/useBuilderSession.d.ts +86 -0
  73. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
  74. package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
  75. package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
  76. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +19 -55
  77. package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
  78. package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
  79. package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
  80. package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
  81. package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
  82. package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
  83. package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
  84. package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
  85. package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
  86. package/dist/components/DashboardBuilder/useTileResize.d.ts +6 -3
  87. package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
  88. package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
  89. package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
  90. package/dist/components/DocumentCreate/events.d.ts +10 -0
  91. package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
  92. package/dist/components/DocumentCreate/guards.d.ts +12 -0
  93. package/dist/components/DocumentCreate/index.d.ts +6 -0
  94. package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
  95. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
  96. package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
  97. package/dist/components/Loading.d.ts +13 -0
  98. package/dist/components/NarrowEditGate.d.ts +8 -0
  99. package/dist/components/Notebook/Notebook.d.ts +1 -1
  100. package/dist/components/Notebook/NotebookCell.d.ts +1 -5
  101. package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
  102. package/dist/components/Package/Package.d.ts +17 -1
  103. package/dist/components/Package/documentLocation.d.ts +28 -0
  104. package/dist/components/Package/index.d.ts +5 -1
  105. package/dist/components/Package/useDocumentLocation.d.ts +12 -0
  106. package/dist/components/PackageSection.d.ts +2 -2
  107. package/dist/components/Prose.d.ts +1 -1
  108. package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
  109. package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
  110. package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
  111. package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
  112. package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
  113. package/dist/components/ServerProvider.d.ts +2 -1
  114. package/dist/components/UnsavedChangesDialog.d.ts +9 -0
  115. package/dist/components/given/GivensPanel.d.ts +2 -2
  116. package/dist/components/given/paramCodec.d.ts +8 -1
  117. package/dist/components/index.d.ts +3 -2
  118. package/dist/components/styles.d.ts +4 -4
  119. package/dist/hooks/givenValue.d.ts +6 -0
  120. package/dist/hooks/index.d.ts +2 -0
  121. package/dist/hooks/useCompiledDocument.d.ts +23 -0
  122. package/dist/hooks/useDocumentControls.d.ts +6 -1
  123. package/dist/hooks/useNarrowScreen.d.ts +4 -0
  124. package/dist/hooks/useNearViewport.d.ts +16 -0
  125. package/dist/hooks/useQueryResult.d.ts +2 -0
  126. package/dist/hooks/useQueryWithApiError.d.ts +7 -2
  127. package/dist/hooks/useSettled.d.ts +14 -0
  128. package/dist/hooks/useSuggestOptions.d.ts +9 -2
  129. package/dist/index.cjs.js +23 -24
  130. package/dist/index.es.js +9041 -7002
  131. package/dist/text/index.cjs.js +1 -0
  132. package/dist/text/index.d.ts +2 -0
  133. package/dist/text/index.es.js +6 -0
  134. package/dist/text-entry-BJwltZiy.cjs.js +7 -0
  135. package/dist/text-entry-CA0LZ1xL.es.js +196 -0
  136. package/dist/text-entry.d.ts +2 -0
  137. package/dist/theme/accent.d.ts +29 -0
  138. package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
  139. package/dist/theme/index.d.ts +3 -0
  140. package/dist/theme/keys.d.ts +1 -1
  141. package/dist/theme/motion.d.ts +31 -0
  142. package/dist/theme/readChartAnnotations.d.ts +1 -1
  143. package/dist/theme/resolveTheme.d.ts +4 -4
  144. package/dist/theme/types.d.ts +33 -5
  145. package/dist/{Dashboard-H1kJlDFo.es.js → useCompiledDocument-BU6d8FPp.es.js} +17904 -19057
  146. package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
  147. package/dist/utils/clock.d.ts +2 -0
  148. package/dist/utils/malloyText.d.ts +104 -0
  149. package/package.json +20 -11
  150. package/src/builder-entry.ts +36 -0
  151. package/src/client-entry.ts +8 -0
  152. package/src/clientEntry.spec.ts +17 -0
  153. package/src/components/ApiErrorDisplay.tsx +37 -18
  154. package/src/components/AppDialog.tsx +8 -7
  155. package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
  156. package/src/components/Dashboard/Dashboard.tsx +29 -280
  157. package/src/components/Dashboard/DashboardGrid.tsx +87 -8
  158. package/src/components/Dashboard/DashboardTile.spec.tsx +121 -2
  159. package/src/components/Dashboard/DashboardTile.tsx +121 -30
  160. package/src/components/Dashboard/DashboardView.spec.tsx +368 -0
  161. package/src/components/Dashboard/DashboardView.tsx +428 -0
  162. package/src/components/Dashboard/RowsDialog.tsx +4 -3
  163. package/src/components/Dashboard/TileCard.tsx +60 -11
  164. package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
  165. package/src/components/Dashboard/TileFilterTag.tsx +78 -0
  166. package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
  167. package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
  168. package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
  169. package/src/components/Dashboard/index.ts +13 -1
  170. package/src/components/Dashboard/telemetry.ts +17 -5
  171. package/src/components/Dashboard/textSource.spec.ts +36 -0
  172. package/src/components/Dashboard/textSource.ts +39 -0
  173. package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
  174. package/src/components/DashboardBuilder/AddTileDialog.tsx +124 -138
  175. package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
  176. package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
  177. package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
  178. package/src/components/DashboardBuilder/BuilderToolbar.tsx +111 -80
  179. package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
  180. package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
  181. package/src/components/DashboardBuilder/ChartPicker.tsx +156 -0
  182. package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
  183. package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +183 -0
  184. package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +373 -0
  185. package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +310 -0
  186. package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +105 -0
  187. package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +117 -0
  188. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +146 -108
  189. package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +179 -0
  190. package/src/components/DashboardBuilder/DashboardBuilder.tsx +330 -512
  191. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +55 -25
  192. package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +142 -0
  193. package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
  194. package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +310 -0
  195. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +39 -13
  196. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +9 -26
  197. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +102 -25
  198. package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
  199. package/src/components/DashboardBuilder/DashboardEditor.tsx +252 -780
  200. package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
  201. package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
  202. package/src/components/DashboardBuilder/FilterDialog.tsx +23 -11
  203. package/src/components/DashboardBuilder/FilterStrip.tsx +130 -70
  204. package/src/components/DashboardBuilder/InlineMarkdown.tsx +182 -0
  205. package/src/components/DashboardBuilder/InlineText.tsx +112 -0
  206. package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
  207. package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
  208. package/src/components/DashboardBuilder/TextTileBody.tsx +31 -0
  209. package/src/components/DashboardBuilder/TileFrame.tsx +302 -163
  210. package/src/components/DashboardBuilder/TileMenu.tsx +125 -97
  211. package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
  212. package/src/components/DashboardBuilder/annotationText.ts +17 -0
  213. package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
  214. package/src/components/DashboardBuilder/artifactTagParity.spec.ts +46 -0
  215. package/src/components/DashboardBuilder/builderReport.ts +74 -0
  216. package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
  217. package/src/components/DashboardBuilder/catalog.spec.ts +2 -44
  218. package/src/components/DashboardBuilder/catalog.ts +61 -57
  219. package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
  220. package/src/components/DashboardBuilder/changedTile.ts +28 -0
  221. package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
  222. package/src/components/DashboardBuilder/chartLine.ts +121 -0
  223. package/src/components/DashboardBuilder/controls.spec.ts +21 -10
  224. package/src/components/DashboardBuilder/controls.ts +22 -8
  225. package/src/components/DashboardBuilder/document.ts +53 -5
  226. package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
  227. package/src/components/DashboardBuilder/documentSession.ts +258 -0
  228. package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
  229. package/src/components/DashboardBuilder/imports.spec.ts +61 -0
  230. package/src/components/DashboardBuilder/imports.ts +93 -0
  231. package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
  232. package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
  233. package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
  234. package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
  235. package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
  236. package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
  237. package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
  238. package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
  239. package/src/components/DashboardBuilder/malloyTree.ts +159 -7
  240. package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
  241. package/src/components/DashboardBuilder/newDashboard.ts +30 -3
  242. package/src/components/DashboardBuilder/openDraft.ts +52 -0
  243. package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
  244. package/src/components/DashboardBuilder/preview.spec.ts +159 -12
  245. package/src/components/DashboardBuilder/preview.ts +83 -9
  246. package/src/components/DashboardBuilder/readDocument.spec.ts +174 -26
  247. package/src/components/DashboardBuilder/readDocument.ts +137 -45
  248. package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
  249. package/src/components/DashboardBuilder/readForEditor.ts +52 -0
  250. package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
  251. package/src/components/DashboardBuilder/sortable.spec.ts +89 -0
  252. package/src/components/DashboardBuilder/sortable.tsx +11 -10
  253. package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
  254. package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
  255. package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
  256. package/src/components/DashboardBuilder/spliceDocument.ts +768 -131
  257. package/src/components/DashboardBuilder/spliceResult.ts +15 -0
  258. package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
  259. package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
  260. package/src/components/DashboardBuilder/tagParse.ts +103 -0
  261. package/src/components/DashboardBuilder/telemetry.ts +47 -0
  262. package/src/components/DashboardBuilder/testing/artifactTagParity.json +253 -0
  263. package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
  264. package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
  265. package/src/components/DashboardBuilder/testing/inline.ts +25 -0
  266. package/src/components/DashboardBuilder/testing/resize.ts +48 -0
  267. package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
  268. package/src/components/DashboardBuilder/textTiles.spec.ts +760 -0
  269. package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
  270. package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
  271. package/src/components/DashboardBuilder/useBuilderSession.spec.ts +250 -0
  272. package/src/components/DashboardBuilder/useBuilderSession.ts +255 -0
  273. package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +97 -0
  274. package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
  275. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +45 -9
  276. package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
  277. package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
  278. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
  279. package/src/components/DashboardBuilder/useDashboardEditor.ts +57 -181
  280. package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
  281. package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
  282. package/src/components/DashboardBuilder/useDraft.ts +15 -2
  283. package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
  284. package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
  285. package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
  286. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
  287. package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
  288. package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
  289. package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
  290. package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
  291. package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
  292. package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
  293. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
  294. package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
  295. package/src/components/DashboardBuilder/useTileResize.spec.tsx +30 -5
  296. package/src/components/DashboardBuilder/useTileResize.ts +31 -8
  297. package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
  298. package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
  299. package/src/components/DocumentCreate/canRetry.ts +19 -0
  300. package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
  301. package/src/components/DocumentCreate/createDocument.ts +159 -0
  302. package/src/components/DocumentCreate/documentPath.ts +40 -0
  303. package/src/components/DocumentCreate/events.ts +15 -0
  304. package/src/components/DocumentCreate/exportedSources.ts +25 -0
  305. package/src/components/DocumentCreate/guards.ts +45 -0
  306. package/src/components/DocumentCreate/index.ts +27 -0
  307. package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
  308. package/src/components/DocumentCreate/newNotebook.ts +44 -0
  309. package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
  310. package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
  311. package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
  312. package/src/components/Environment/Environment.tsx +0 -10
  313. package/src/components/Loading.tsx +14 -0
  314. package/src/components/Model/Model.tsx +16 -9
  315. package/src/components/Model/ModelExplorer.spec.tsx +2 -2
  316. package/src/components/Model/ModelExplorer.tsx +2 -2
  317. package/src/components/Model/SourcesExplorer.tsx +2 -4
  318. package/src/components/NarrowEditGate.spec.tsx +73 -0
  319. package/src/components/NarrowEditGate.tsx +29 -0
  320. package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
  321. package/src/components/Notebook/Notebook.tsx +72 -29
  322. package/src/components/Notebook/NotebookCell.tsx +90 -215
  323. package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
  324. package/src/components/Package/NewDocumentDialog.tsx +401 -0
  325. package/src/components/Package/Package.artifacts.spec.tsx +186 -0
  326. package/src/components/Package/Package.create.spec.tsx +401 -0
  327. package/src/components/Package/Package.notebooks.spec.tsx +18 -0
  328. package/src/components/Package/Package.tsx +396 -177
  329. package/src/components/Package/documentLocation.spec.ts +81 -0
  330. package/src/components/Package/documentLocation.ts +55 -0
  331. package/src/components/Package/index.ts +14 -1
  332. package/src/components/Package/useDocumentLocation.ts +59 -0
  333. package/src/components/PackageSection.tsx +2 -2
  334. package/src/components/Prose.spec.tsx +37 -0
  335. package/src/components/Prose.tsx +35 -5
  336. package/src/components/RenderedResult/RenderedResult.tsx +23 -8
  337. package/src/components/RenderedResult/ResultContainer.tsx +51 -13
  338. package/src/components/RenderedResult/ResultPanel.tsx +24 -5
  339. package/src/components/RenderedResult/loadRenderer.ts +42 -0
  340. package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
  341. package/src/components/RenderedResult/resultSizing.ts +14 -3
  342. package/src/components/ServerProvider.tsx +2 -1
  343. package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
  344. package/src/components/UnsavedChangesDialog.tsx +49 -0
  345. package/src/components/given/GivenInput.spec.tsx +5 -5
  346. package/src/components/given/GivenInput.tsx +46 -38
  347. package/src/components/given/GivensPanel.spec.tsx +6 -6
  348. package/src/components/given/GivensPanel.tsx +5 -11
  349. package/src/components/given/paramCodec.ts +27 -1
  350. package/src/components/index.ts +3 -2
  351. package/src/components/styles.ts +4 -5
  352. package/src/hooks/givenValue.ts +9 -0
  353. package/src/hooks/index.ts +7 -0
  354. package/src/hooks/useCompiledDocument.spec.tsx +86 -0
  355. package/src/hooks/useCompiledDocument.ts +59 -0
  356. package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
  357. package/src/hooks/useDocumentControls.ts +13 -1
  358. package/src/hooks/useNarrowScreen.ts +21 -0
  359. package/src/hooks/useNearViewport.spec.tsx +150 -0
  360. package/src/hooks/useNearViewport.ts +102 -0
  361. package/src/hooks/useQueryResult.ts +23 -1
  362. package/src/hooks/useQueryWithApiError.ts +10 -3
  363. package/src/hooks/useRawQueryData.ts +3 -1
  364. package/src/hooks/useSettled.spec.ts +41 -0
  365. package/src/hooks/useSettled.ts +27 -0
  366. package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
  367. package/src/hooks/useSuggestOptions.ts +42 -10
  368. package/src/mainEntry.spec.ts +145 -0
  369. package/src/text-entry.ts +12 -0
  370. package/src/textEntry.spec.ts +112 -0
  371. package/src/theme/accent.spec.ts +116 -0
  372. package/src/theme/accent.ts +148 -0
  373. package/src/theme/buildTableCssVars.spec.ts +24 -0
  374. package/src/theme/buildTableCssVars.ts +1 -2
  375. package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
  376. package/src/theme/buildVegaThemeOverride.ts +5 -5
  377. package/src/theme/defaults.ts +34 -0
  378. package/src/theme/index.ts +9 -0
  379. package/src/theme/keys.ts +6 -0
  380. package/src/theme/motion.ts +44 -0
  381. package/src/theme/readChartAnnotations.spec.ts +18 -0
  382. package/src/theme/readChartAnnotations.ts +1 -1
  383. package/src/theme/resolveTheme.spec.ts +73 -0
  384. package/src/theme/resolveTheme.ts +61 -20
  385. package/src/theme/types.ts +30 -5
  386. package/src/utils/clock.spec.ts +12 -0
  387. package/src/utils/clock.ts +6 -0
  388. package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +48 -0
  389. package/src/utils/malloyText.ts +368 -0
  390. package/src/utils/queryClient.ts +8 -0
  391. package/vite.config.ts +4 -0
  392. package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
  393. package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
  394. package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
  395. package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
  396. package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
  397. package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -15
  398. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -20
  399. package/dist/components/DashboardBuilder/diff.d.ts +0 -35
  400. package/dist/components/DashboardBuilder/malloyText.d.ts +0 -64
  401. package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
  402. package/src/components/Dashboard/DashboardBar.tsx +0 -88
  403. package/src/components/Dashboard/ExploreDialog.tsx +0 -89
  404. package/src/components/DashboardBuilder/DiffDialog.tsx +0 -122
  405. package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -168
  406. package/src/components/DashboardBuilder/diff.spec.ts +0 -44
  407. package/src/components/DashboardBuilder/diff.ts +0 -93
  408. package/src/components/DashboardBuilder/malloyText.ts +0 -214
  409. package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
  410. package/src/components/Package/NewDashboardDialog.tsx +0 -265
@@ -1,20 +1,38 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import DragIndicatorIcon from "@mui/icons-material/DragIndicator";
5
- import MoreVertIcon from "@mui/icons-material/MoreVert";
6
- import { Box, IconButton, Typography } from "@mui/material";
4
+ import AddIcon from "@mui/icons-material/Add";
5
+ import { Box, IconButton, SvgIcon, Typography } from "@mui/material";
7
6
  import type { PointerEvent, ReactNode } from "react";
7
+ import type { Theme } from "@mui/material";
8
+ import type { SystemStyleObject } from "@mui/system";
9
+ import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
8
10
  import { usePublisherTheme } from "../../theme/ThemeContext";
9
- import { GRID_GAP_PX } from "../Dashboard/DashboardGrid";
10
- import { TileCard, TileHeading } from "../Dashboard/TileCard";
11
- import { tileKey, type DashboardTile } from "./document";
11
+ import type { ResolvedTheme } from "../../theme/types";
12
+ import {
13
+ BARE_RING_OFFSET_PX,
14
+ GRID_GAP_PX,
15
+ NOTEBOOK_GAP_PX,
16
+ } from "../Dashboard/DashboardGrid";
17
+ import {
18
+ TileCard,
19
+ TileHeading,
20
+ type TileChrome,
21
+ type TileHeadingSlots,
22
+ } from "../Dashboard/TileCard";
23
+ import { tileDisplayTitle } from "./tileDisplayTitle";
24
+ import {
25
+ tileKey,
26
+ tileLabel,
27
+ type DashboardTile,
28
+ type QueryTile,
29
+ } from "./document";
12
30
  import { gapId } from "./layout";
13
- import { GapDroppable, TileSortable } from "./sortable";
31
+ import { GapDroppable, NO_DRAG, TileSortable } from "./sortable";
14
32
 
15
33
  /**
16
- * Everything the builder draws AROUND a tile: the selection outline, the grip,
17
- * the menu button, the resize badge and the handle at the right edge. The tile
34
+ * Everything the builder draws AROUND a tile: the selection outline, the menu
35
+ * button, the handle at the right edge and, in a notebook, the insert button. The tile
18
36
  * itself is `children` — the host's real `DashboardTile`, or a placeholder
19
37
  * saying what the tile will run.
20
38
  */
@@ -22,11 +40,14 @@ export function TileFrame({
22
40
  tile,
23
41
  index,
24
42
  selected,
43
+ flash = false,
25
44
  menuOpen,
26
- resizeSpan,
27
- columns,
45
+ bare = false,
46
+ onInsertAfter,
28
47
  onSelect,
29
48
  onOpenMenu,
49
+ resizing = false,
50
+ width,
30
51
  onResizeStart,
31
52
  onResizeMove,
32
53
  onResizeEnd,
@@ -35,22 +56,38 @@ export function TileFrame({
35
56
  tile: DashboardTile;
36
57
  index: number;
37
58
  selected: boolean;
59
+ /** Briefly lit: the tile an undo or redo just changed. */
60
+ flash?: boolean;
38
61
  /** Whether this tile's menu is open, which keeps its button showing. */
39
62
  menuOpen: boolean;
40
- /** The width being previewed while THIS tile is resized. */
41
- resizeSpan: number | undefined;
42
- columns: number;
63
+ /**
64
+ * The tile has no card (a notebook's): its ring is drawn clear of the
65
+ * content and its menu sits on the ring's top edge, so neither touches the
66
+ * text, and the tile reads where the reader draws it.
67
+ */
68
+ bare?: boolean;
69
+ /** Offers a "+" on the bottom edge that adds a tile after this one; set where tiles stack in one column. */
70
+ onInsertAfter?: () => void;
43
71
  onSelect: () => void;
44
72
  onOpenMenu: (anchor: HTMLElement) => void;
45
- onResizeStart: (event: PointerEvent<HTMLDivElement>) => void;
46
- onResizeMove: (event: PointerEvent<HTMLDivElement>) => void;
47
- onResizeEnd: (event: PointerEvent<HTMLDivElement>) => void;
73
+ /** This tile's edge is being dragged. */
74
+ resizing?: boolean;
75
+ /** Dragging the right edge sets the width; absent, the tile has no edge handle (one column, or tags the file does not own). */
76
+ onResizeStart?: (event: PointerEvent<HTMLDivElement>) => void;
77
+ onResizeMove?: (event: PointerEvent<HTMLDivElement>) => void;
78
+ onResizeEnd?: (event: PointerEvent<HTMLDivElement>) => void;
79
+ /** The tile's width and the grid's, and a step of one column: the edge's keyboard route. */
80
+ width?: {
81
+ span: number;
82
+ columns: number;
83
+ onStep: (to: number) => void;
84
+ };
48
85
  children: ReactNode;
49
86
  }) {
50
87
  const { theme } = usePublisherTheme();
51
88
  return (
52
89
  <TileSortable id={tileKey(tile)} index={index}>
53
- {({ ref, handleRef, isDragSource }) => (
90
+ {({ ref, handleRef }) => (
54
91
  <Box
55
92
  ref={ref}
56
93
  onClick={onSelect}
@@ -60,10 +97,18 @@ export function TileFrame({
60
97
  onPointerDown={(event) => {
61
98
  if (event.button === 0) onSelect();
62
99
  }}
100
+ // A named group, so the name is announced: a label on a plain
101
+ // element is not.
102
+ role="group"
63
103
  aria-label={`Tile ${tile.name}`}
64
104
  aria-current={selected}
105
+ // Keyboard focus anywhere in the tile selects it, as a press
106
+ // does, so the arrow-key nudge and the menu follow the keyboard.
107
+ onFocus={onSelect}
108
+ data-tile-key={tileKey(tile)}
109
+ data-flash={flash || undefined}
65
110
  sx={{
66
- // Anchors the resize and drag handles to
111
+ // Anchors the menu, edge and insert buttons to
67
112
  // this tile.
68
113
  position: "relative",
69
114
  // Same again: this wrapper sits BETWEEN
@@ -83,20 +128,8 @@ export function TileFrame({
83
128
  // a scrollbar — still wins over its own
84
129
  // pixels.
85
130
  cursor: "grab",
86
- borderRadius: 1,
87
- // An outline rather than a border, and
88
- // outside the tile rather than on it: the
89
- // tile already has an edge of its own, and
90
- // an outline neither doubles that edge nor
91
- // takes up space, so selecting a tile
92
- // cannot shift the layout being arranged.
93
- outline: selected
94
- ? `2px solid ${theme.drillLink}`
95
- : `2px solid transparent`,
96
- outlineOffset: 2,
97
- transition:
98
- "outline-color 120ms, opacity 120ms, box-shadow 120ms",
99
- // The handles, grip and menu are invisible
131
+ ...selectionSx(theme, { selected, flash, bare }),
132
+ // The edge handle and menu are invisible
100
133
  // until wanted, and wanted is: the pointer
101
134
  // over the tile, or the tile selected. A
102
135
  // hover rule on the WRAPPER, so all three
@@ -118,168 +151,145 @@ export function TileFrame({
118
151
  "&&[data-dnd-dragging]": {
119
152
  opacity: 1,
120
153
  outline: "none",
121
- boxShadow: "0 12px 32px rgba(0, 0, 0, 0.22)",
154
+ boxShadow: theme.shadow.drag,
122
155
  },
123
156
  "&&[data-dnd-placeholder]": {
124
157
  opacity: 0.45,
125
- outline: `2px dashed ${theme.drillLink}`,
158
+ outline: `2px dashed ${theme.accent}`,
126
159
  boxShadow: "none",
127
160
  },
128
161
  "&:hover .builder-affordance, &:focus-within .builder-affordance":
129
162
  { opacity: 1 },
130
- // A hovered tile lifts, as a card does in any
131
- // builder's edit mode: the one card that
132
- // will respond to the pointer, told apart
133
- // from the ones that will not.
134
- "&:hover": {
135
- outlineColor: selected
136
- ? theme.drillLink
137
- : theme.cardBorder,
138
- boxShadow: "0 2px 10px rgba(0, 0, 0, 0.10)",
163
+ // No hover on a touch screen: the affordances stand.
164
+ "@media (hover: none)": {
165
+ "& .builder-affordance": { opacity: 1 },
139
166
  },
140
167
  }}
141
168
  >
142
169
  {children}
143
170
 
144
- {/* The grip. On every tile, including an
145
- inherited one — order is this file's
146
- `tiles=[…]` array, not anything on the view.
147
- The whole card starts a pointer drag; the grip
148
- is the sign of it and the library's HANDLE,
149
- where keyboard focus and the screen-reader
150
- instructions land: Space picks the tile up,
151
- the arrows move it, Escape puts it back. */}
171
+ {/* The library's HANDLE, where keyboard focus and the
172
+ screen-reader instructions land: Space picks the tile up, the
173
+ arrows move it, Escape puts it back. Visually hidden: a pointer
174
+ drags the whole card, and the open hand over it says so. */}
152
175
  <Box
153
176
  ref={handleRef}
177
+ aria-label={`Move ${tileLabel(tile)}`}
178
+ sx={{
179
+ position: "absolute",
180
+ width: "1px",
181
+ height: "1px",
182
+ overflow: "hidden",
183
+ clipPath: "inset(50%)",
184
+ whiteSpace: "nowrap",
185
+ }}
186
+ />
187
+
188
+ {/* The tile's menu: its chart and drill-through.
189
+ A press here is never the start of a drag: the
190
+ sensor refuses to activate from a button. */}
191
+ <IconButton
154
192
  className="builder-affordance"
155
- aria-label={`Move ${tile.label ?? tile.name}`}
193
+ size="small"
194
+ aria-label={`Settings for ${tileLabel(tile)}`}
195
+ onClick={(event) => {
196
+ event.stopPropagation();
197
+ onOpenMenu(event.currentTarget);
198
+ }}
156
199
  sx={{
157
200
  position: "absolute",
158
- top: "2px",
159
- left: "2px",
160
- display: "grid",
161
- placeItems: "center",
162
- width: "22px",
163
- height: "22px",
164
- borderRadius: "4px",
165
- cursor: "grab",
166
- touchAction: "none",
201
+ // A tab on the tile's top edge, the same on a card and
202
+ // on bare content: centred on the card's border, or on
203
+ // a bare tile's ring, so it never covers the tile's title
204
+ // or text.
205
+ top: `${-((bare ? BARE_RING_OFFSET_PX + 1 : 0) + 12)}px`,
206
+ right: bare ? 0 : "12px",
207
+ border: theme.cardBorder,
208
+ borderRadius: 1,
209
+ // A 24px hit target at least, whatever the glyph.
210
+ width: 28,
211
+ height: 24,
167
212
  zIndex: 2,
168
213
  color: theme.tileTitle,
169
214
  bgcolor: theme.tile,
170
- opacity: isDragSource || selected ? 0.9 : 0,
171
- transition: "opacity 120ms",
172
- "&:hover": { opacity: 1 },
173
- "&:active": { cursor: "grabbing" },
174
- "&:focus-visible": {
215
+ opacity: selected || menuOpen ? 0.9 : 0,
216
+ transition: `opacity ${MOTION_FAST}`,
217
+ ...reducedMotionSx,
218
+ "&:hover": {
175
219
  opacity: 1,
176
- outline: `2px solid ${theme.drillLink}`,
177
- outlineOffset: 1,
220
+ bgcolor: theme.tile,
178
221
  },
179
222
  }}
180
223
  >
181
- <DragIndicatorIcon sx={{ fontSize: 16 }} />
182
- </Box>
183
-
184
- {/* The tile's menu: its title and subtitle.
185
- Hidden while a resize badge sits in the same
186
- corner. A press here is never the start of a
187
- drag: the sensor refuses to activate from a
188
- button. */}
189
- {resizeSpan === undefined && (
190
- <IconButton
191
- className="builder-affordance"
192
- size="small"
193
- aria-label={`Settings for ${tile.label ?? tile.name}`}
194
- onClick={(event) => {
195
- event.stopPropagation();
196
- onOpenMenu(event.currentTarget);
197
- }}
198
- sx={{
199
- position: "absolute",
200
- top: "2px",
201
- right: "2px",
202
- width: 22,
203
- height: 22,
204
- zIndex: 2,
205
- color: theme.tileTitle,
206
- bgcolor: theme.tile,
207
- opacity: selected || menuOpen ? 0.9 : 0,
208
- transition: "opacity 120ms",
209
- "&:hover": {
210
- opacity: 1,
211
- bgcolor: theme.tile,
212
- },
213
- }}
214
- >
215
- <MoreVertIcon sx={{ fontSize: 16 }} />
216
- </IconButton>
217
- )}
218
-
219
- {/* A tile's width and share of the dashboard,
220
- reported while you drag it, as the best builders do.
221
- Height is not ours to show, but the span and
222
- its share are exactly what a flow grid leaves
223
- you guessing at. */}
224
- {resizeSpan !== undefined && (
225
- <Box
226
- aria-hidden
227
- sx={{
228
- position: "absolute",
229
- top: "6px",
230
- right: "6px",
231
- px: 0.75,
232
- py: 0.25,
233
- borderRadius: "4px",
234
- bgcolor: theme.drillLink,
235
- color: theme.tile,
236
- fontSize: 11,
237
- fontVariantNumeric: "tabular-nums",
238
- zIndex: 4,
239
- pointerEvents: "none",
240
- }}
241
- >
242
- {resizeSpan} of {columns} ·{" "}
243
- {Math.round((resizeSpan / columns) * 100)}%
244
- </Box>
245
- )}
224
+ <SpreadDotsIcon />
225
+ </IconButton>
246
226
 
247
- {/* The right edge, draggable — but only on a
248
- tile whose tags this file owns. An inherited
249
- tile's tags live on the model's view, which
250
- the builder does not write, so a drag here
251
- could not be saved. Its own pointer handling
252
- stops the press reaching the sortable, and
253
- the sensor refuses a separator regardless. */}
254
- {tile.declaration.kind !== "inherited" && (
227
+ {/* The right edge, which sets the width: dragged, or focused and
228
+ stepped with the arrow keys a column at a time (Home and End go
229
+ to one column and the full grid). Marked so the move sensor
230
+ never takes a press on it. */}
231
+ {onResizeStart && (
255
232
  <Box
256
233
  className="builder-affordance"
234
+ {...{ [NO_DRAG]: "" }}
257
235
  role="separator"
236
+ tabIndex={width ? 0 : -1}
258
237
  aria-orientation="vertical"
259
- aria-label={`Resize ${tile.label ?? tile.name}`}
238
+ aria-label={`Width of ${tileLabel(tile)}`}
239
+ {...(width
240
+ ? {
241
+ "aria-valuenow": width.span,
242
+ "aria-valuemin": 1,
243
+ "aria-valuemax": width.columns,
244
+ "aria-valuetext": `${width.span} of ${width.columns} columns`,
245
+ }
246
+ : {})}
247
+ onKeyDown={(event) => {
248
+ if (!width) return;
249
+ const to =
250
+ event.key === "ArrowRight"
251
+ ? width.span + 1
252
+ : event.key === "ArrowLeft"
253
+ ? width.span - 1
254
+ : event.key === "Home"
255
+ ? 1
256
+ : event.key === "End"
257
+ ? width.columns
258
+ : undefined;
259
+ if (to === undefined) return;
260
+ // The builder's own arrow-key nudge must not step it again.
261
+ event.preventDefault();
262
+ event.stopPropagation();
263
+ width.onStep(Math.min(Math.max(to, 1), width.columns));
264
+ }}
260
265
  onPointerDown={onResizeStart}
261
266
  onPointerMove={onResizeMove}
262
267
  onPointerUp={onResizeEnd}
263
268
  onPointerCancel={onResizeEnd}
269
+ onClick={(event) => event.stopPropagation()}
264
270
  sx={{
265
271
  position: "absolute",
266
272
  top: 0,
267
273
  bottom: 0,
268
- // Straddles the edge, so the target
269
- // is a usable width without eating
270
- // into the tile's content.
274
+ // Straddles the edge, so the target is a usable width
275
+ // without eating into the tile's content.
271
276
  right: "-5px",
272
277
  width: "10px",
273
278
  cursor: "col-resize",
274
279
  touchAction: "none",
275
- zIndex: 1,
276
- // Invisible until wanted: a rule down
277
- // every tile edge would read as a
278
- // table, and the tile already draws
279
- // an edge of its own.
280
- opacity: resizeSpan !== undefined || selected ? 1 : 0,
281
- transition: "opacity 120ms",
280
+ zIndex: 2,
281
+ // Invisible until wanted: a rule down every tile edge
282
+ // would read as a table.
283
+ opacity: resizing || selected ? 1 : 0,
284
+ transition: `opacity ${MOTION_FAST}`,
285
+ ...reducedMotionSx,
282
286
  "&:hover": { opacity: 1 },
287
+ "&:focus-visible": {
288
+ opacity: 1,
289
+ outline: `2px solid ${theme.accent}`,
290
+ outlineOffset: 1,
291
+ borderRadius: "3px",
292
+ },
283
293
  "&::after": {
284
294
  content: '""',
285
295
  position: "absolute",
@@ -289,29 +299,143 @@ export function TileFrame({
289
299
  width: "4px",
290
300
  height: "28px",
291
301
  borderRadius: "2px",
292
- bgcolor: theme.drillLink,
302
+ bgcolor: theme.accent,
293
303
  },
294
304
  }}
295
305
  />
296
306
  )}
307
+
308
+ {onInsertAfter && (
309
+ <IconButton
310
+ className="builder-affordance"
311
+ size="small"
312
+ aria-label={`Insert tile after ${tileLabel(tile)}`}
313
+ onClick={(event) => {
314
+ event.stopPropagation();
315
+ onInsertAfter();
316
+ }}
317
+ sx={{
318
+ position: "absolute",
319
+ // Centred in the gap below the tile, not on its edge: on
320
+ // a one-line notebook text tile, an edge-centred button
321
+ // covered the middle of the text it sits under.
322
+ bottom: `-${(bare ? NOTEBOOK_GAP_PX : GRID_GAP_PX) / 2 + 12}px`,
323
+ left: "50%",
324
+ transform: "translateX(-50%)",
325
+ width: 24,
326
+ height: 24,
327
+ zIndex: 3,
328
+ color: theme.tileTitle,
329
+ bgcolor: theme.tile,
330
+ border: theme.cardBorder,
331
+ opacity: 0,
332
+ transition: `opacity ${MOTION_FAST}`,
333
+ ...reducedMotionSx,
334
+ "&:hover, &:focus-visible": {
335
+ opacity: 1,
336
+ bgcolor: theme.tile,
337
+ },
338
+ }}
339
+ >
340
+ <AddIcon sx={{ fontSize: 14 }} />
341
+ </IconButton>
342
+ )}
297
343
  </Box>
298
344
  )}
299
345
  </TileSortable>
300
346
  );
301
347
  }
302
348
 
349
+ /** How far the selection ring stands outside what it selects: its 2px offset plus its 2px width. */
350
+ export const SELECTION_RING_PX = 4;
351
+
352
+ /**
353
+ * The builder's selection look, for anything a person can select — a tile,
354
+ * the description: an outline outside the element (so selecting moves no
355
+ * layout), solid in the accent when selected, lifting on hover the way a card
356
+ * does in any builder's edit mode, and a brief halo when an undo or redo just
357
+ * changed it. One definition, so the description selects exactly as a tile.
358
+ */
359
+ export const selectionSx = (
360
+ theme: ResolvedTheme,
361
+ {
362
+ selected,
363
+ flash = false,
364
+ bare = false,
365
+ }: { selected: boolean; flash?: boolean; bare?: boolean },
366
+ ): SystemStyleObject<Theme> => {
367
+ const ring = selected || flash ? theme.accent : "transparent";
368
+ const hoverRing = selected
369
+ ? theme.accent
370
+ : theme.cardBorder.replace(/^1px solid /, "");
371
+ const transition = `outline-color ${MOTION_FAST}, border-color ${MOTION_FAST}, opacity ${MOTION_FAST}, box-shadow ${MOTION_FAST}`;
372
+ if (bare)
373
+ // Bare content has no padding of its own, so the ring stands off it by
374
+ // the clear space a card's text has, without moving the text from where
375
+ // the reader draws it. Drawn as its own layer rather than an offset
376
+ // outline: an outline's corners grow by the offset, and the ring would
377
+ // read rounder than every card on the page. No lift: there is no
378
+ // surface to lift, only the ring.
379
+ return {
380
+ borderRadius: 1,
381
+ "&::before": {
382
+ content: '""',
383
+ position: "absolute",
384
+ inset: `${-BARE_RING_OFFSET_PX}px`,
385
+ borderRadius: 1,
386
+ border: `2px solid ${ring}`,
387
+ pointerEvents: "none",
388
+ transition,
389
+ ...reducedMotionSx,
390
+ },
391
+ "&:hover::before": { borderColor: hoverRing },
392
+ };
393
+ // A card carries its own padding, so its ring hugs its edge.
394
+ return {
395
+ borderRadius: 1,
396
+ outline: `2px solid ${ring}`,
397
+ outlineOffset: 2,
398
+ ...(flash && {
399
+ boxShadow: `0 0 0 6px color-mix(in srgb, ${theme.accent} 25%, transparent)`,
400
+ }),
401
+ transition,
402
+ ...reducedMotionSx,
403
+ "&:hover": {
404
+ outlineColor: hoverRing,
405
+ boxShadow: theme.shadow.lift,
406
+ },
407
+ };
408
+ };
409
+
303
410
  /**
304
411
  * No host-supplied tile: say what this one will run, so the surface is still
305
412
  * legible without a server.
306
413
  */
307
- export function TilePlaceholder({ tile }: { tile: DashboardTile }) {
414
+ export function TilePlaceholder({
415
+ tile,
416
+ heading,
417
+ note,
418
+ chrome = "card",
419
+ }: {
420
+ tile: QueryTile;
421
+ heading?: TileHeadingSlots;
422
+ /** Why there is no preview, in place of an empty body. */
423
+ note?: string;
424
+ /** The document's tile chrome, as the reader draws it. */
425
+ chrome?: TileChrome;
426
+ }) {
308
427
  const { theme } = usePublisherTheme();
309
428
  return (
310
- <TileCard sx={{ minHeight: 140 }}>
429
+ <TileCard chrome={chrome}>
311
430
  <TileHeading
312
- title={tile.label ?? tile.name}
313
- subtitle={tile.subtitle}
431
+ title={heading?.title ?? tileDisplayTitle(tile)}
432
+ subtitle={heading ? heading.subtitle : tile.subtitle}
314
433
  />
434
+ {note && (
435
+ <Typography variant="body2" sx={{ color: theme.tileTitle, py: 2 }}>
436
+ {note}
437
+ </Typography>
438
+ )}
315
439
  <Typography
316
440
  variant="caption"
317
441
  sx={{ display: "block", color: theme.tileTitle, opacity: 0.7 }}
@@ -334,17 +458,18 @@ export function GapTarget({ after }: { after: string }) {
334
458
  sx={{
335
459
  minHeight: 48,
336
460
  borderRadius: 1,
337
- border: `1px dashed ${theme.drillLink}`,
461
+ border: `1px dashed ${theme.accent}`,
338
462
  // Tinted with the same hue as the dashed edge, so the fill
339
463
  // and the border read as one affordance lighting up. It was
340
464
  // `theme.tile`, the CARD colour, which is the one value
341
465
  // guaranteed to match whatever this sits on: a near-no-op
342
466
  // before the card went white, and an exact one after.
343
467
  bgcolor: isDropTarget
344
- ? `color-mix(in srgb, ${theme.drillLink} 12%, transparent)`
468
+ ? `color-mix(in srgb, ${theme.accent} 12%, transparent)`
345
469
  : "transparent",
346
470
  opacity: isDropTarget ? 0.95 : 0.4,
347
- transition: "opacity 120ms, background-color 120ms",
471
+ transition: `opacity ${MOTION_FAST}, background-color ${MOTION_FAST}`,
472
+ ...reducedMotionSx,
348
473
  }}
349
474
  />
350
475
  )}
@@ -375,10 +500,10 @@ export function GridGuides({ columns }: { columns: number }) {
375
500
  <Box
376
501
  key={column}
377
502
  sx={{
378
- borderLeft: `1px dashed ${theme.drillLink}`,
503
+ borderLeft: `1px dashed ${theme.accent}`,
379
504
  borderRight:
380
505
  column === columns - 1
381
- ? `1px dashed ${theme.drillLink}`
506
+ ? `1px dashed ${theme.accent}`
382
507
  : "none",
383
508
  opacity: 0.35,
384
509
  }}
@@ -387,3 +512,17 @@ export function GridGuides({ columns }: { columns: number }) {
387
512
  </Box>
388
513
  );
389
514
  }
515
+
516
+ /**
517
+ * The tile menu's ⋯, with its dots spread wider than the stock icon's so it
518
+ * reads as three dots rather than a dash at this size.
519
+ */
520
+ function SpreadDotsIcon() {
521
+ return (
522
+ <SvgIcon sx={{ fontSize: 18 }} viewBox="0 0 24 24">
523
+ <circle cx="3.5" cy="12" r="2" />
524
+ <circle cx="12" cy="12" r="2" />
525
+ <circle cx="20.5" cy="12" r="2" />
526
+ </SvgIcon>
527
+ );
528
+ }