@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
@@ -0,0 +1,102 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { useCallback, useEffect, useRef, useState } from "react";
5
+
6
+ /** How far above or below the viewport an element counts as near, in pixels: a screen or so of scroll. */
7
+ export const NEAR_VIEWPORT_MARGIN_PX = 600;
8
+
9
+ const observerUnavailable = () => typeof IntersectionObserver === "undefined";
10
+
11
+ /**
12
+ * The element that scrolls `node`, or null for the viewport. A host that
13
+ * scrolls its page inside a box (the Console does) clips a tile by that box,
14
+ * so a margin on the viewport would never be reached: the look-ahead has to be
15
+ * measured on the box itself.
16
+ */
17
+ function scrollRootOf(node: Element): Element | null {
18
+ for (let at = node.parentElement; at; at = at.parentElement) {
19
+ const { overflowY } = getComputedStyle(at);
20
+ if (
21
+ (overflowY === "auto" || overflowY === "scroll") &&
22
+ at.scrollHeight > at.clientHeight
23
+ )
24
+ return at;
25
+ }
26
+ return null;
27
+ }
28
+
29
+ /**
30
+ * Whether an element has come near the viewport, latched: once true it stays
31
+ * true, so scrolling a tile away again never takes back what it has run.
32
+ *
33
+ * Returns a callback ref for the element and the flag. Where there is no
34
+ * `IntersectionObserver` (server rendering, a test DOM) the flag starts true,
35
+ * so gating on it never leaves something waiting for an observer that will not
36
+ * come.
37
+ *
38
+ * For work that costs: a dashboard tile's query runs against a warehouse that
39
+ * bills for it, and a long dashboard used to run every tile on mount, however
40
+ * far below the fold.
41
+ */
42
+ export function useNearViewport<T extends Element = HTMLElement>(
43
+ marginPx: number = NEAR_VIEWPORT_MARGIN_PX,
44
+ ): [ref: (node: T | null) => void, near: boolean] {
45
+ const [near, setNear] = useState(observerUnavailable);
46
+ const nearRef = useRef(near);
47
+ const observerRef = useRef<IntersectionObserver | null>(null);
48
+
49
+ const ref = useCallback(
50
+ (node: T | null) => {
51
+ observerRef.current?.disconnect();
52
+ observerRef.current = null;
53
+ if (!node || nearRef.current || observerUnavailable()) return;
54
+ // Already near when it mounts, as everything above the fold is: open
55
+ // now, in the commit that attached it, rather than a frame later when
56
+ // the observer first reports.
57
+ const rect = node.getBoundingClientRect();
58
+ const root = scrollRootOf(node);
59
+ const bounds = root?.getBoundingClientRect() ?? {
60
+ top: 0,
61
+ bottom: window.innerHeight || document.documentElement.clientHeight,
62
+ };
63
+ if (
64
+ rect.bottom >= bounds.top - marginPx &&
65
+ rect.top <= bounds.bottom + marginPx
66
+ ) {
67
+ nearRef.current = true;
68
+ setNear(true);
69
+ return;
70
+ }
71
+ const observer = new IntersectionObserver(
72
+ (entries) => {
73
+ if (!entries.some((entry) => entry.isIntersecting)) return;
74
+ nearRef.current = true;
75
+ observer.disconnect();
76
+ setNear(true);
77
+ },
78
+ { root, rootMargin: `${marginPx}px 0px` },
79
+ );
80
+ observer.observe(node);
81
+ observerRef.current = observer;
82
+ },
83
+ [marginPx],
84
+ );
85
+
86
+ useEffect(() => () => observerRef.current?.disconnect(), []);
87
+
88
+ // Printing lays out the whole page at once with nobody scrolling: every
89
+ // tile has to have run by then.
90
+ useEffect(() => {
91
+ if (near || typeof window === "undefined") return;
92
+ const open = () => {
93
+ nearRef.current = true;
94
+ observerRef.current?.disconnect();
95
+ setNear(true);
96
+ };
97
+ window.addEventListener("beforeprint", open);
98
+ return () => window.removeEventListener("beforeprint", open);
99
+ }, [near]);
100
+
101
+ return [ref, near];
102
+ }
@@ -76,7 +76,11 @@ export function useQueryResult(
76
76
  const { apiClients } = useServer();
77
77
  return useQueryWithApiError({
78
78
  queryKey: queryResultKey(spec),
79
- queryFn: () =>
79
+ // The signal cancels a run the page no longer wants: a tile whose givens
80
+ // changed under it, or one that unmounted. react-query reverts a
81
+ // cancelled query to its previous state rather than to an error, so an
82
+ // abort never reaches `ResultPanel`'s failed state.
83
+ queryFn: ({ signal }) =>
80
84
  apiClients.models.executeQueryModel(
81
85
  spec.environmentName,
82
86
  spec.packageName,
@@ -88,6 +92,8 @@ export function useQueryResult(
88
92
  givens: spec.givens,
89
93
  versionId: spec.versionId,
90
94
  },
95
+ undefined,
96
+ { signal },
91
97
  ),
92
98
  enabled,
93
99
  ...CHART_RESULT_QUERY_OPTIONS,
@@ -2,6 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import {
5
+ type QueryFunctionContext,
6
+ type QueryKey,
5
7
  useMutation,
6
8
  UseMutationOptions,
7
9
  UseMutationResult,
@@ -17,7 +19,12 @@ import { globalQueryClient } from "../utils/queryClient";
17
19
  export { globalQueryClient };
18
20
  export function useQueryWithApiError<TData = unknown, TError = ApiError>(
19
21
  options: Omit<UseQueryOptions<TData, TError>, "throwOnError" | "retry"> & {
20
- queryFn: () => Promise<TData>;
22
+ /**
23
+ * Receives react-query's context. Pass its `signal` into the request
24
+ * (axios takes it as `{ signal }`) so a query superseded by a key change,
25
+ * or abandoned by an unmount, is cancelled rather than left to finish.
26
+ */
27
+ queryFn: (context: QueryFunctionContext<QueryKey>) => Promise<TData>;
21
28
  },
22
29
  ): UseQueryResult<TData, TError> {
23
30
  const { server } = useServer();
@@ -25,9 +32,9 @@ export function useQueryWithApiError<TData = unknown, TError = ApiError>(
25
32
  ...options,
26
33
  // Add in the server to the query key so that we can have a per-server caches.
27
34
  queryKey: [...options.queryKey, server],
28
- queryFn: async () => {
35
+ queryFn: async (context) => {
29
36
  try {
30
- return await options.queryFn();
37
+ return await options.queryFn(context);
31
38
  } catch (err) {
32
39
  // Standardized error handling for axios errors
33
40
  if (err && typeof err === "object" && "response" in err) {
@@ -37,7 +37,7 @@ export function useRawQueryData({
37
37
  sourceName,
38
38
  queryName,
39
39
  ],
40
- queryFn: () =>
40
+ queryFn: ({ signal }) =>
41
41
  apiClients.models.executeQueryModel(
42
42
  environmentName,
43
43
  packageName,
@@ -48,6 +48,8 @@ export function useRawQueryData({
48
48
  queryName: queryName,
49
49
  versionId: versionId,
50
50
  },
51
+ undefined,
52
+ { signal },
51
53
  ),
52
54
  enabled,
53
55
  });
@@ -30,7 +30,9 @@ const executeQueryModel = mock(
30
30
 
31
31
  mockServerProvider({ models: { executeQueryModel } });
32
32
 
33
- const { useSuggestOptions } = await import("./useSuggestOptions");
33
+ const { buildSuggestQuery, useSuggestOptions } = await import(
34
+ "./useSuggestOptions"
35
+ );
34
36
 
35
37
  const SPECS: Given[] = [
36
38
  {
@@ -148,3 +150,40 @@ it("sends no givens when the suggest names none, or the caller offers none", asy
148
150
  (executeQueryModel.mock.calls[0][3] as { givens?: unknown }).givens,
149
151
  ).toBeUndefined();
150
152
  });
153
+
154
+ it("runs a suggest as the document's definitions plus one run:, by name or by dimension, when a preamble is given", async () => {
155
+ const specs: Given[] = [
156
+ {
157
+ name: "REGION",
158
+ control: "select",
159
+ suggest: { source: "a", dimension: "region" },
160
+ },
161
+ { name: "BRAND", control: "select", suggest: { query: "brands" } },
162
+ ];
163
+ executeQueryModel.mockClear();
164
+ renderHook(
165
+ () =>
166
+ useSuggestOptions(
167
+ "env",
168
+ "pkg",
169
+ "models/orders.malloy",
170
+ specs,
171
+ undefined,
172
+ undefined,
173
+ "source: a is orders",
174
+ ),
175
+ { wrapper: serverWrapper },
176
+ );
177
+
178
+ await waitFor(() => expect(executeQueryModel).toHaveBeenCalledTimes(2));
179
+ const requests = executeQueryModel.mock.calls.map(
180
+ (call) => call[3] as { query?: string; queryName?: string },
181
+ );
182
+ expect(requests.every((request) => request.queryName === undefined)).toBe(
183
+ true,
184
+ );
185
+ expect(requests.map((request) => request.query)).toEqual([
186
+ `source: a is orders\n\n${buildSuggestQuery("a", "region")}`,
187
+ "source: a is orders\n\nrun: brands",
188
+ ]);
189
+ });
@@ -4,9 +4,13 @@
4
4
  import { useQueries } from "@tanstack/react-query";
5
5
  import { useMemo } from "react";
6
6
  import type { Given } from "../client";
7
- import { givensToRequest } from "../components/given/paramCodec";
7
+ import { withPreamble } from "../components/Dashboard/textSource";
8
+ import {
9
+ givensToRequest,
10
+ withHostGivens,
11
+ } from "../components/given/paramCodec";
8
12
  import { useServer } from "../components/ServerProvider";
9
- import type { GivenValue } from "./givenValue";
13
+ import type { GivenValue, HostGivenValue } from "./givenValue";
10
14
 
11
15
  /**
12
16
  * How many options a generated `suggest { source=… dimension=… }` asks for.
@@ -92,9 +96,10 @@ export function suggestRequestGivens(
92
96
  ): Record<string, unknown> | undefined {
93
97
  const names = spec.suggest?.givenNames;
94
98
  if (!applied || !names || names.length === 0) return undefined;
95
- const request = givensToRequest(
96
- applied.values,
97
- applied.declaredTypes,
99
+ const request = withHostGivens(
100
+ givensToRequest(applied.values, applied.declaredTypes, names),
101
+ // A control's own value wins, so only what no control declares is added.
102
+ hostOnly(applied),
98
103
  names,
99
104
  );
100
105
  return Object.keys(request).length > 0 ? request : undefined;
@@ -104,6 +109,19 @@ export function suggestRequestGivens(
104
109
  export interface AppliedGivens {
105
110
  values: ReadonlyMap<string, GivenValue>;
106
111
  declaredTypes: ReadonlyMap<string, string | undefined>;
112
+ /** Givens the host sets with no control: a gated source's suggest needs them, and they may be lists. */
113
+ host?: Readonly<Record<string, HostGivenValue>>;
114
+ }
115
+
116
+ function hostOnly(
117
+ applied: AppliedGivens,
118
+ ): Record<string, HostGivenValue> | undefined {
119
+ if (!applied.host) return undefined;
120
+ return Object.fromEntries(
121
+ Object.entries(applied.host).filter(
122
+ ([name]) => !applied.declaredTypes.has(name),
123
+ ),
124
+ );
107
125
  }
108
126
 
109
127
  export function useSuggestOptions(
@@ -120,6 +138,11 @@ export function useSuggestOptions(
120
138
  * caller that omits it gets the pre-gating behaviour.
121
139
  */
122
140
  applied?: AppliedGivens,
141
+ /**
142
+ * Text-source mode: the document's definitions, sent ahead of the suggest as
143
+ * the viewer's own text. Absent, a suggest runs by name or by view as before.
144
+ */
145
+ preamble?: string,
123
146
  ): {
124
147
  options: Map<string, string[]>;
125
148
  isLoading: boolean;
@@ -167,19 +190,21 @@ export function useSuggestOptions(
167
190
  // Only the givens the suggest carries, so a change to any OTHER
168
191
  // control leaves the cached list alone.
169
192
  givens === undefined ? null : JSON.stringify(givens),
193
+ // Only a text source keys on its definitions, so no other key changes shape.
194
+ ...(preamble === undefined ? [] : [preamble]),
170
195
  ],
171
196
  enabled: modelPath !== undefined,
172
197
  // Option lists change with the data, not with the filters, so they
173
198
  // are cached well past a single control interaction.
174
199
  staleTime: 5 * 60 * 1000,
175
200
  refetchOnWindowFocus: false,
176
- queryFn: async () => {
201
+ queryFn: async ({ signal }: { signal: AbortSignal }) => {
177
202
  const suggest = spec.suggest ?? {};
178
203
  const response = await apiClients.models.executeQueryModel(
179
204
  environmentName,
180
205
  packageName,
181
206
  modelPath as string,
182
- suggest.query !== undefined
207
+ suggest.query !== undefined && preamble === undefined
183
208
  ? {
184
209
  queryName: suggest.query,
185
210
  compactJson: true,
@@ -187,14 +212,21 @@ export function useSuggestOptions(
187
212
  givens,
188
213
  }
189
214
  : {
190
- query: buildSuggestQuery(
191
- suggest.source as string,
192
- suggest.dimension as string,
215
+ query: withPreamble(
216
+ preamble ?? "",
217
+ suggest.query !== undefined
218
+ ? `run: ${suggest.query}`
219
+ : buildSuggestQuery(
220
+ suggest.source as string,
221
+ suggest.dimension as string,
222
+ ),
193
223
  ),
194
224
  compactJson: true,
195
225
  versionId,
196
226
  givens,
197
227
  },
228
+ undefined,
229
+ { signal },
198
230
  );
199
231
  return readOptionValues(
200
232
  response.data.result,
package/src/text-entry.ts CHANGED
@@ -8,5 +8,5 @@ export {
8
8
  artifactTag,
9
9
  splitSourceLines,
10
10
  type ArtifactTag,
11
- } from "./components/DashboardBuilder/malloyText";
11
+ } from "./utils/malloyText";
12
12
  export { canRetryRequest } from "./components/DocumentCreate/canRetry";
@@ -13,20 +13,14 @@ const RETRY = path.join(
13
13
  import.meta.dir,
14
14
  "components/DocumentCreate/canRetry.ts",
15
15
  );
16
- const MODULE = path.join(
17
- import.meta.dir,
18
- "components/DashboardBuilder/malloyText.ts",
19
- );
16
+ const MODULE = path.join(import.meta.dir, "utils/malloyText.ts");
20
17
 
21
18
  describe("@malloy-publisher/sdk/text", () => {
22
19
  // Hosts import this in vitest's plain node environment, where they also mock the main entry.
23
20
  it("re-exports two modules, which import nothing", () => {
24
21
  const entry = fs.readFileSync(ENTRY, "utf8");
25
22
  expect([...entry.matchAll(/from\s+"([^"]+)"/g)].map((m) => m[1])).toEqual(
26
- [
27
- "./components/DashboardBuilder/malloyText",
28
- "./components/DocumentCreate/canRetry",
29
- ],
23
+ ["./utils/malloyText", "./components/DocumentCreate/canRetry"],
30
24
  );
31
25
  expect(fs.readFileSync(RETRY, "utf8")).not.toMatch(
32
26
  /^\s*(import|export\s.*\sfrom)\b|\brequire\(|\bimport\(/m,
@@ -0,0 +1,116 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { describe, expect, it } from "bun:test";
5
+ import { PALETTE } from "../components/styles";
6
+ import { accentFor, contrastRatio, legibleOn } from "./accent";
7
+ import { resolveTheme } from "./resolveTheme";
8
+
9
+ const WHITE = "#ffffff";
10
+ const SLATE = "#0f172a";
11
+ const ratio = (a: string, b: string) => contrastRatio(a, b) as number;
12
+
13
+ describe("accentFor", () => {
14
+ it("keeps the Console's own blue pair when nothing is configured", () => {
15
+ expect(accentFor(PALETTE.blue, "light")).toEqual({
16
+ accent: PALETTE.blue,
17
+ accentHover: "#1d4ed8",
18
+ accentContrast: "#ffffff",
19
+ });
20
+ expect(accentFor(undefined, "dark").accent).toBe("#60a5fa");
21
+ });
22
+
23
+ it("keeps a colour that already reads, in either mode, exactly as picked", () => {
24
+ // A dark brand colour on white, and a bright one on slate.
25
+ expect(accentFor("#2d323d", "light").accent).toBe("#2d323d");
26
+ expect(accentFor("#f59e0b", "dark").accent).toBe("#f59e0b");
27
+ });
28
+
29
+ it("deepens a pale first colour on the light page until it reads at 3:1", () => {
30
+ expect(ratio("#fde047", WHITE)).toBeLessThan(3);
31
+ const { accent } = accentFor("#fde047", "light");
32
+ expect(ratio(accent, WHITE)).toBeGreaterThanOrEqual(3);
33
+ // Only as far as it takes: not all the way to black.
34
+ expect(ratio(accent, WHITE)).toBeLessThan(4);
35
+ });
36
+
37
+ it("lifts a dark first colour on the dark page only as far as it takes", () => {
38
+ expect(ratio("#2d323d", SLATE)).toBeLessThan(3);
39
+ const { accent } = accentFor("#2d323d", "dark");
40
+ expect(ratio(accent, SLATE)).toBeGreaterThanOrEqual(3);
41
+ expect(ratio(accent, SLATE)).toBeLessThan(4);
42
+ });
43
+
44
+ it("puts whichever label reads better on the accent", () => {
45
+ for (const [first, mode] of [
46
+ ["#2d323d", "light"],
47
+ ["#2d323d", "dark"],
48
+ ["#fde047", "light"],
49
+ ["#f59e0b", "dark"],
50
+ ] as const) {
51
+ const { accent, accentContrast } = accentFor(first, mode);
52
+ const other = accentContrast === WHITE ? SLATE : WHITE;
53
+ expect(ratio(accent, accentContrast)).toBeGreaterThanOrEqual(
54
+ ratio(accent, other),
55
+ );
56
+ }
57
+ });
58
+
59
+ it("uses a non-hex colour as given in light mode and keeps the dark default", () => {
60
+ expect(accentFor("rebeccapurple", "light").accent).toBe("rebeccapurple");
61
+ expect(accentFor("rebeccapurple", "dark").accent).toBe("#60a5fa");
62
+ });
63
+
64
+ it("follows the instance palette through resolveTheme, measured against its own page", () => {
65
+ const theme = resolveTheme(
66
+ [{ palette: { series: ["#2d323d", "#573f35"] } }],
67
+ "dark",
68
+ );
69
+ expect(ratio(theme.accent, theme.background)).toBeGreaterThanOrEqual(3);
70
+ expect(
71
+ resolveTheme([{ palette: { series: ["#2d323d"] } }], "light").accent,
72
+ ).toBe("#2d323d");
73
+ });
74
+
75
+ it("keeps drill links on the Console's default accent, whatever the palette", () => {
76
+ const theme = resolveTheme(
77
+ [{ palette: { series: ["#7e1d47"] } }],
78
+ "light",
79
+ );
80
+ expect(theme.drillLink).toBe(accentFor(undefined, "light").accent);
81
+ });
82
+ });
83
+
84
+ describe("legibleOn", () => {
85
+ it("returns a colour that already reads unchanged", () => {
86
+ expect(legibleOn("#b45309", SLATE)).toBe("#b45309");
87
+ });
88
+
89
+ it("moves toward white on a dark ground and toward black on a light one", () => {
90
+ expect(ratio(legibleOn("#2d323d", SLATE), SLATE)).toBeGreaterThanOrEqual(
91
+ 3,
92
+ );
93
+ expect(ratio(legibleOn("#fde047", WHITE), WHITE)).toBeGreaterThanOrEqual(
94
+ 3,
95
+ );
96
+ });
97
+ });
98
+
99
+ describe("dark mode legibility", () => {
100
+ it("lifts a series colour that disappears on the dark canvas, and leaves light mode alone", () => {
101
+ const layers = [{ palette: { series: ["#2d323d", "#b45309"] } }];
102
+ expect(resolveTheme(layers, "light").series[0]).toBe("#2d323d");
103
+ const dark = resolveTheme(layers, "dark");
104
+ expect(ratio(dark.series[0], dark.background)).toBeGreaterThanOrEqual(3);
105
+ // Already readable on slate: kept as picked.
106
+ expect(dark.series[1]).toBe("#b45309");
107
+ });
108
+
109
+ it("carries a light-only map colour into dark instead of the default", () => {
110
+ const layers = [{ palette: { mapColor: { light: "#465472" } } }];
111
+ const dark = resolveTheme(layers, "dark").mapColor;
112
+ const fallback = resolveTheme([], "dark").mapColor;
113
+ expect(dark).not.toBe(fallback);
114
+ expect(resolveTheme(layers, "light").mapColor).toBe("#465472");
115
+ });
116
+ });
@@ -0,0 +1,148 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { PALETTE } from "../components/styles";
5
+ import type { ThemeMode } from "./types";
6
+
7
+ /** The Console's accent, its hover state, and the label colour that sits on it. */
8
+ export interface Accent {
9
+ accent: string;
10
+ accentHover: string;
11
+ accentContrast: string;
12
+ }
13
+
14
+ /**
15
+ * The defaults, kept to the value: an unthemed Console looks exactly as it did
16
+ * before the accent followed the palette. Dark inverts the pair rather than
17
+ * shifting the blue — a bright fill with a near-black label reads at 7:1 on a
18
+ * slate page, where a mid blue with white text does not reach 4.5:1.
19
+ *
20
+ * The one definition: the Console's MUI theme and the drill-link colour read
21
+ * these through {@link accentFor} rather than keeping copies.
22
+ */
23
+ const DEFAULT_ACCENT: Record<ThemeMode, Accent> = {
24
+ light: {
25
+ accent: PALETTE.blue,
26
+ accentHover: "#1d4ed8",
27
+ accentContrast: "#ffffff",
28
+ },
29
+ dark: {
30
+ accent: "#60a5fa",
31
+ accentHover: "#93c5fd",
32
+ accentContrast: "#0f172a",
33
+ },
34
+ };
35
+
36
+ /** The page each mode's accent is drawn on, when the caller does not say. */
37
+ const DEFAULT_GROUND: Record<ThemeMode, string> = {
38
+ light: "#ffffff",
39
+ dark: "#0f172a",
40
+ };
41
+
42
+ /**
43
+ * WCAG's minimum for a graphical object — a focus ring, a selection outline, a
44
+ * slider track — against what it sits on.
45
+ */
46
+ const GRAPHIC_CONTRAST = 3;
47
+
48
+ type Rgb = [number, number, number];
49
+
50
+ const rgbOf = (hex: string): Rgb | undefined => {
51
+ const match = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
52
+ if (!match) return undefined;
53
+ const digits =
54
+ match[1].length === 3
55
+ ? [...match[1]].map((d) => d + d).join("")
56
+ : match[1];
57
+ return [0, 2, 4].map((at) => parseInt(digits.slice(at, at + 2), 16)) as Rgb;
58
+ };
59
+
60
+ const hexOf = (rgb: number[]) =>
61
+ `#${rgb.map((c) => Math.round(c).toString(16).padStart(2, "0")).join("")}`;
62
+
63
+ /** `from` moved `share` of the way towards `to` (0 black, 255 white). */
64
+ const mix = (from: Rgb, to: number, share: number) =>
65
+ hexOf(from.map((c) => c + (to - c) * share));
66
+
67
+ /** WCAG relative luminance, 0 (black) to 1 (white). */
68
+ const luminance = (rgb: Rgb) => {
69
+ const [r, g, b] = rgb.map((c) => {
70
+ const s = c / 255;
71
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
72
+ });
73
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
74
+ };
75
+
76
+ /** The WCAG contrast ratio of two colours, 1 to 21. */
77
+ const contrastOf = (a: Rgb, b: Rgb) => {
78
+ const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
79
+ return (hi + 0.05) / (lo + 0.05);
80
+ };
81
+
82
+ /** The contrast ratio of two hex colours, or undefined when either is not one. */
83
+ export function contrastRatio(a: string, b: string): number | undefined {
84
+ const x = rgbOf(a);
85
+ const y = rgbOf(b);
86
+ return x && y ? contrastOf(x, y) : undefined;
87
+ }
88
+
89
+ /** The near-black label the dark defaults use. */
90
+ const INK: Rgb = [0x0f, 0x17, 0x2a];
91
+
92
+ /**
93
+ * `color`, moved just far enough to stand at `min`:1 against `ground` —
94
+ * toward white on a dark ground, toward black on a light one — so a colour
95
+ * picked for one page still reads on the other, and one that already reads
96
+ * comes back exactly as given. A colour that is not a hex value comes back as
97
+ * given too, since it cannot be measured.
98
+ */
99
+ export function legibleOn(
100
+ color: string,
101
+ ground: string,
102
+ min = GRAPHIC_CONTRAST,
103
+ ): string {
104
+ const rgb = rgbOf(color);
105
+ const base = rgbOf(ground);
106
+ if (!rgb || !base || contrastOf(rgb, base) >= min) return color;
107
+ const toward = luminance(base) < 0.5 ? 255 : 0;
108
+ for (let share = 0.05; share < 1; share += 0.05) {
109
+ const moved = rgbOf(mix(rgb, toward, share));
110
+ if (moved && contrastOf(moved, base) >= min) return hexOf(moved);
111
+ }
112
+ return toward === 255 ? "#ffffff" : "#000000";
113
+ }
114
+
115
+ /**
116
+ * The accent the Console's chrome is drawn in — its primary buttons, sliders,
117
+ * the builder's selection — from the first colour of the palette's series, so
118
+ * a page has one accent and it is the operator's: the button that saves a
119
+ * dashboard and the first line on it are the same hue.
120
+ *
121
+ * In either mode the colour is kept as picked when it already reads against
122
+ * the page at 3:1, and otherwise moved only as far as it takes to read: lifted
123
+ * on the dark page, deepened on the light one. The label on it is whichever of
124
+ * white and near-black reads better. With no palette, the Console's own blue.
125
+ */
126
+ export function accentFor(
127
+ first: string | undefined,
128
+ mode: ThemeMode,
129
+ ground: string = DEFAULT_GROUND[mode],
130
+ ): Accent {
131
+ const fallback = DEFAULT_ACCENT[mode];
132
+ if (!first || first.toLowerCase() === PALETTE.blue) return fallback;
133
+ if (!rgbOf(first))
134
+ return mode === "light"
135
+ ? { ...fallback, accent: first, accentHover: first }
136
+ : fallback;
137
+ const accent = legibleOn(first, ground);
138
+ const accentRgb = rgbOf(accent) as Rgb;
139
+ const accentHover =
140
+ mode === "dark" ? mix(accentRgb, 255, 0.25) : mix(accentRgb, 0, 0.2);
141
+ const onWhite = contrastOf(accentRgb, [255, 255, 255]);
142
+ const onInk = contrastOf(accentRgb, INK);
143
+ return {
144
+ accent,
145
+ accentHover,
146
+ accentContrast: onWhite >= onInk ? "#ffffff" : "#0f172a",
147
+ };
148
+ }
@@ -34,6 +34,30 @@ describe("buildTableCssVars", () => {
34
34
  expect(vars["--malloy-render--value-color"]).toBe(t.valueColor);
35
35
  });
36
36
 
37
+ it("carries palette.border, cardBorder and value into their vars", () => {
38
+ const t = resolveTheme(
39
+ [
40
+ {
41
+ palette: {
42
+ border: { light: "#aaaaaa" },
43
+ cardBorder: { light: "#bbbbbb" },
44
+ value: { light: "#cccccc" },
45
+ },
46
+ },
47
+ ],
48
+ "light",
49
+ );
50
+ const vars = buildTableCssVars(t);
51
+ expect(vars["--malloy-render--table-border"]).toBe("1px solid #aaaaaa");
52
+ expect(vars["--publisher-dashboard-card-border"]).toBe(
53
+ "1px solid #bbbbbb",
54
+ );
55
+ expect(vars["--malloy-render--table-pinned-border"]).toBe(
56
+ "1px solid #bbbbbb",
57
+ );
58
+ expect(vars["--malloy-render--value-color"]).toBe("#cccccc");
59
+ });
60
+
37
61
  it("omits the dashboard-root background keys", () => {
38
62
  // background and table-background are deliberately not surfaced
39
63
  // here; the renderer paints the dashboard chrome with its own
@@ -80,8 +80,7 @@ export function buildTableCssVars(
80
80
  // Drives the dashboard tile title (e.g. "by_month" above a chart)
81
81
  // and the dimension-name text via injectRendererOverrides.
82
82
  "--malloy-render--label-color": theme.tileTitle,
83
- // The numeric value rendered under each tile title. Not editable
84
- // in v1; computed from the active mode for readable contrast.
83
+ // The numeric value rendered under each tile title (`palette.value`).
85
84
  "--malloy-render--value-color": theme.valueColor,
86
85
  // Custom var. Drives the hover colour of a `# drill` cell via the
87
86
  // .publisher-drill rule in injectRendererOverrides: the renderer