@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,17 +2,25 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import AddIcon from "@mui/icons-material/Add";
5
- import DragIndicatorIcon from "@mui/icons-material/DragIndicator";
6
- import MoreVertIcon from "@mui/icons-material/MoreVert";
7
- import { Box, IconButton, Typography } from "@mui/material";
8
- import type { ReactNode } from "react";
5
+ import { Box, IconButton, SvgIcon, Typography } from "@mui/material";
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";
9
10
  import { usePublisherTheme } from "../../theme/ThemeContext";
10
- import { GRID_GAP_PX } from "../Dashboard/DashboardGrid";
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";
11
17
  import {
12
18
  TileCard,
13
19
  TileHeading,
20
+ type TileChrome,
14
21
  type TileHeadingSlots,
15
22
  } from "../Dashboard/TileCard";
23
+ import { tileDisplayTitle } from "./tileDisplayTitle";
16
24
  import {
17
25
  tileKey,
18
26
  tileLabel,
@@ -20,11 +28,11 @@ import {
20
28
  type QueryTile,
21
29
  } from "./document";
22
30
  import { gapId } from "./layout";
23
- import { GapDroppable, TileSortable } from "./sortable";
31
+ import { GapDroppable, NO_DRAG, TileSortable } from "./sortable";
24
32
 
25
33
  /**
26
- * Everything the builder draws AROUND a tile: the selection outline, the grip,
27
- * the menu button and, in a notebook, the insert button. 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
28
36
  * itself is `children` — the host's real `DashboardTile`, or a placeholder
29
37
  * saying what the tile will run.
30
38
  */
@@ -34,9 +42,15 @@ export function TileFrame({
34
42
  selected,
35
43
  flash = false,
36
44
  menuOpen,
45
+ bare = false,
37
46
  onInsertAfter,
38
47
  onSelect,
39
48
  onOpenMenu,
49
+ resizing = false,
50
+ width,
51
+ onResizeStart,
52
+ onResizeMove,
53
+ onResizeEnd,
40
54
  children,
41
55
  }: {
42
56
  tile: DashboardTile;
@@ -46,16 +60,34 @@ export function TileFrame({
46
60
  flash?: boolean;
47
61
  /** Whether this tile's menu is open, which keeps its button showing. */
48
62
  menuOpen: boolean;
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;
49
69
  /** Offers a "+" on the bottom edge that adds a tile after this one; set where tiles stack in one column. */
50
70
  onInsertAfter?: () => void;
51
71
  onSelect: () => void;
52
72
  onOpenMenu: (anchor: HTMLElement) => 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
+ };
53
85
  children: ReactNode;
54
86
  }) {
55
87
  const { theme } = usePublisherTheme();
56
88
  return (
57
89
  <TileSortable id={tileKey(tile)} index={index}>
58
- {({ ref, handleRef, isDragSource }) => (
90
+ {({ ref, handleRef }) => (
59
91
  <Box
60
92
  ref={ref}
61
93
  onClick={onSelect}
@@ -65,12 +97,18 @@ export function TileFrame({
65
97
  onPointerDown={(event) => {
66
98
  if (event.button === 0) onSelect();
67
99
  }}
100
+ // A named group, so the name is announced: a label on a plain
101
+ // element is not.
102
+ role="group"
68
103
  aria-label={`Tile ${tile.name}`}
69
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}
70
108
  data-tile-key={tileKey(tile)}
71
109
  data-flash={flash || undefined}
72
110
  sx={{
73
- // Anchors the grip, menu and insert buttons to
111
+ // Anchors the menu, edge and insert buttons to
74
112
  // this tile.
75
113
  position: "relative",
76
114
  // Same again: this wrapper sits BETWEEN
@@ -90,24 +128,8 @@ export function TileFrame({
90
128
  // a scrollbar — still wins over its own
91
129
  // pixels.
92
130
  cursor: "grab",
93
- borderRadius: 1,
94
- // An outline rather than a border, and
95
- // outside the tile rather than on it: the
96
- // tile already has an edge of its own, and
97
- // an outline neither doubles that edge nor
98
- // takes up space, so selecting a tile
99
- // cannot shift the layout being arranged.
100
- outline: selected
101
- ? `2px solid ${theme.drillLink}`
102
- : `2px solid transparent`,
103
- outlineOffset: 2,
104
- ...(flash && {
105
- outlineColor: theme.drillLink,
106
- boxShadow: `0 0 0 6px color-mix(in srgb, ${theme.drillLink} 25%, transparent)`,
107
- }),
108
- transition:
109
- "outline-color 120ms, opacity 120ms, box-shadow 120ms",
110
- // The handles, grip and menu are invisible
131
+ ...selectionSx(theme, { selected, flash, bare }),
132
+ // The edge handle and menu are invisible
111
133
  // until wanted, and wanted is: the pointer
112
134
  // over the tile, or the tile selected. A
113
135
  // hover rule on the WRAPPER, so all three
@@ -129,70 +151,41 @@ export function TileFrame({
129
151
  "&&[data-dnd-dragging]": {
130
152
  opacity: 1,
131
153
  outline: "none",
132
- boxShadow: "0 12px 32px rgba(0, 0, 0, 0.22)",
154
+ boxShadow: theme.shadow.drag,
133
155
  },
134
156
  "&&[data-dnd-placeholder]": {
135
157
  opacity: 0.45,
136
- outline: `2px dashed ${theme.drillLink}`,
158
+ outline: `2px dashed ${theme.accent}`,
137
159
  boxShadow: "none",
138
160
  },
139
161
  "&:hover .builder-affordance, &:focus-within .builder-affordance":
140
162
  { opacity: 1 },
141
- // A hovered tile lifts, as a card does in any
142
- // builder's edit mode: the one card that
143
- // will respond to the pointer, told apart
144
- // from the ones that will not.
145
- "&:hover": {
146
- outlineColor: selected
147
- ? theme.drillLink
148
- : theme.cardBorder,
149
- 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 },
150
166
  },
151
167
  }}
152
168
  >
153
169
  {children}
154
170
 
155
- {/* The grip. On every tile, including an
156
- inherited one — order is this file's
157
- `tiles=[…]` array, not anything on the view.
158
- The whole card starts a pointer drag; the grip
159
- is the sign of it and the library's HANDLE,
160
- where keyboard focus and the screen-reader
161
- instructions land: Space picks the tile up,
162
- 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. */}
163
175
  <Box
164
176
  ref={handleRef}
165
- className="builder-affordance"
166
177
  aria-label={`Move ${tileLabel(tile)}`}
167
178
  sx={{
168
179
  position: "absolute",
169
- top: "2px",
170
- left: "2px",
171
- display: "grid",
172
- placeItems: "center",
173
- width: "22px",
174
- height: "22px",
175
- borderRadius: "4px",
176
- cursor: "grab",
177
- touchAction: "none",
178
- zIndex: 2,
179
- color: theme.tileTitle,
180
- bgcolor: theme.tile,
181
- opacity: isDragSource || selected ? 0.9 : 0,
182
- transition: "opacity 120ms",
183
- "&:hover": { opacity: 1 },
184
- "&:active": { cursor: "grabbing" },
185
- "&:focus-visible": {
186
- opacity: 1,
187
- outline: `2px solid ${theme.drillLink}`,
188
- outlineOffset: 1,
189
- },
180
+ width: "1px",
181
+ height: "1px",
182
+ overflow: "hidden",
183
+ clipPath: "inset(50%)",
184
+ whiteSpace: "nowrap",
190
185
  }}
191
- >
192
- <DragIndicatorIcon sx={{ fontSize: 16 }} />
193
- </Box>
186
+ />
194
187
 
195
- {/* The tile's menu: its chart, width and drill-through.
188
+ {/* The tile's menu: its chart and drill-through.
196
189
  A press here is never the start of a drag: the
197
190
  sensor refuses to activate from a button. */}
198
191
  <IconButton
@@ -205,24 +198,113 @@ export function TileFrame({
205
198
  }}
206
199
  sx={{
207
200
  position: "absolute",
208
- top: "2px",
209
- right: "2px",
210
- width: 22,
211
- height: 22,
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,
212
212
  zIndex: 2,
213
213
  color: theme.tileTitle,
214
214
  bgcolor: theme.tile,
215
215
  opacity: selected || menuOpen ? 0.9 : 0,
216
- transition: "opacity 120ms",
216
+ transition: `opacity ${MOTION_FAST}`,
217
+ ...reducedMotionSx,
217
218
  "&:hover": {
218
219
  opacity: 1,
219
220
  bgcolor: theme.tile,
220
221
  },
221
222
  }}
222
223
  >
223
- <MoreVertIcon sx={{ fontSize: 16 }} />
224
+ <SpreadDotsIcon />
224
225
  </IconButton>
225
226
 
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 && (
232
+ <Box
233
+ className="builder-affordance"
234
+ {...{ [NO_DRAG]: "" }}
235
+ role="separator"
236
+ tabIndex={width ? 0 : -1}
237
+ aria-orientation="vertical"
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
+ }}
265
+ onPointerDown={onResizeStart}
266
+ onPointerMove={onResizeMove}
267
+ onPointerUp={onResizeEnd}
268
+ onPointerCancel={onResizeEnd}
269
+ onClick={(event) => event.stopPropagation()}
270
+ sx={{
271
+ position: "absolute",
272
+ top: 0,
273
+ bottom: 0,
274
+ // Straddles the edge, so the target is a usable width
275
+ // without eating into the tile's content.
276
+ right: "-5px",
277
+ width: "10px",
278
+ cursor: "col-resize",
279
+ touchAction: "none",
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,
286
+ "&:hover": { opacity: 1 },
287
+ "&:focus-visible": {
288
+ opacity: 1,
289
+ outline: `2px solid ${theme.accent}`,
290
+ outlineOffset: 1,
291
+ borderRadius: "3px",
292
+ },
293
+ "&::after": {
294
+ content: '""',
295
+ position: "absolute",
296
+ top: "50%",
297
+ left: "50%",
298
+ transform: "translate(-50%, -50%)",
299
+ width: "4px",
300
+ height: "28px",
301
+ borderRadius: "2px",
302
+ bgcolor: theme.accent,
303
+ },
304
+ }}
305
+ />
306
+ )}
307
+
226
308
  {onInsertAfter && (
227
309
  <IconButton
228
310
  className="builder-affordance"
@@ -234,17 +316,21 @@ export function TileFrame({
234
316
  }}
235
317
  sx={{
236
318
  position: "absolute",
237
- bottom: "-18px",
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`,
238
323
  left: "50%",
239
324
  transform: "translateX(-50%)",
240
- width: 20,
241
- height: 20,
325
+ width: 24,
326
+ height: 24,
242
327
  zIndex: 3,
243
328
  color: theme.tileTitle,
244
329
  bgcolor: theme.tile,
245
330
  border: theme.cardBorder,
246
331
  opacity: 0,
247
- transition: "opacity 120ms",
332
+ transition: `opacity ${MOTION_FAST}`,
333
+ ...reducedMotionSx,
248
334
  "&:hover, &:focus-visible": {
249
335
  opacity: 1,
250
336
  bgcolor: theme.tile,
@@ -260,6 +346,67 @@ export function TileFrame({
260
346
  );
261
347
  }
262
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
+
263
410
  /**
264
411
  * No host-supplied tile: say what this one will run, so the surface is still
265
412
  * legible without a server.
@@ -268,17 +415,20 @@ export function TilePlaceholder({
268
415
  tile,
269
416
  heading,
270
417
  note,
418
+ chrome = "card",
271
419
  }: {
272
420
  tile: QueryTile;
273
421
  heading?: TileHeadingSlots;
274
422
  /** Why there is no preview, in place of an empty body. */
275
423
  note?: string;
424
+ /** The document's tile chrome, as the reader draws it. */
425
+ chrome?: TileChrome;
276
426
  }) {
277
427
  const { theme } = usePublisherTheme();
278
428
  return (
279
- <TileCard sx={{ minHeight: 140 }}>
429
+ <TileCard chrome={chrome}>
280
430
  <TileHeading
281
- title={heading?.title ?? tile.label ?? tile.name}
431
+ title={heading?.title ?? tileDisplayTitle(tile)}
282
432
  subtitle={heading ? heading.subtitle : tile.subtitle}
283
433
  />
284
434
  {note && (
@@ -308,17 +458,18 @@ export function GapTarget({ after }: { after: string }) {
308
458
  sx={{
309
459
  minHeight: 48,
310
460
  borderRadius: 1,
311
- border: `1px dashed ${theme.drillLink}`,
461
+ border: `1px dashed ${theme.accent}`,
312
462
  // Tinted with the same hue as the dashed edge, so the fill
313
463
  // and the border read as one affordance lighting up. It was
314
464
  // `theme.tile`, the CARD colour, which is the one value
315
465
  // guaranteed to match whatever this sits on: a near-no-op
316
466
  // before the card went white, and an exact one after.
317
467
  bgcolor: isDropTarget
318
- ? `color-mix(in srgb, ${theme.drillLink} 12%, transparent)`
468
+ ? `color-mix(in srgb, ${theme.accent} 12%, transparent)`
319
469
  : "transparent",
320
470
  opacity: isDropTarget ? 0.95 : 0.4,
321
- transition: "opacity 120ms, background-color 120ms",
471
+ transition: `opacity ${MOTION_FAST}, background-color ${MOTION_FAST}`,
472
+ ...reducedMotionSx,
322
473
  }}
323
474
  />
324
475
  )}
@@ -349,10 +500,10 @@ export function GridGuides({ columns }: { columns: number }) {
349
500
  <Box
350
501
  key={column}
351
502
  sx={{
352
- borderLeft: `1px dashed ${theme.drillLink}`,
503
+ borderLeft: `1px dashed ${theme.accent}`,
353
504
  borderRight:
354
505
  column === columns - 1
355
- ? `1px dashed ${theme.drillLink}`
506
+ ? `1px dashed ${theme.accent}`
356
507
  : "none",
357
508
  opacity: 0.35,
358
509
  }}
@@ -361,3 +512,17 @@ export function GridGuides({ columns }: { columns: number }) {
361
512
  </Box>
362
513
  );
363
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
+ }