@malloy-publisher/sdk 0.0.382-dev → 0.2.0

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 (277) hide show
  1. package/README.md +115 -95
  2. package/TREE_SHAKING.md +16 -11
  3. package/bunfig.toml +7 -0
  4. package/dist/ServerProvider-CTopDUWW.cjs.js +1 -0
  5. package/dist/ServerProvider-DUFPY6Rv.es.js +4072 -0
  6. package/dist/client/api.d.ts +3718 -1507
  7. package/dist/client/configuration.d.ts +1 -1
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.d.ts +1 -1
  10. package/dist/client/index.es.js +85 -59
  11. package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
  12. package/dist/components/Connections/common.d.ts +8 -2
  13. package/dist/components/Dashboard/Dashboard.d.ts +49 -0
  14. package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
  15. package/dist/components/Dashboard/index.d.ts +2 -0
  16. package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
  17. package/dist/components/DataAppViewer/index.d.ts +1 -0
  18. package/dist/components/Environment/Environment.d.ts +6 -0
  19. package/dist/components/Environment/index.d.ts +2 -0
  20. package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
  21. package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
  22. package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
  23. package/dist/components/Home/Home.d.ts +2 -2
  24. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
  25. package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
  26. package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
  27. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
  28. package/dist/components/Materializations/ManifestView.d.ts +13 -0
  29. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
  30. package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
  31. package/dist/components/Materializations/Materializations.d.ts +7 -0
  32. package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
  33. package/dist/components/Materializations/SectionLabel.d.ts +10 -0
  34. package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
  35. package/dist/components/Materializations/TriggerChip.d.ts +10 -0
  36. package/dist/components/Materializations/cron.d.ts +23 -0
  37. package/dist/components/Materializations/index.d.ts +2 -0
  38. package/dist/components/Materializations/utils.d.ts +46 -0
  39. package/dist/components/Notebook/Notebook.d.ts +47 -4
  40. package/dist/components/Notebook/NotebookCell.d.ts +37 -1
  41. package/dist/components/Notebook/runPlan.d.ts +29 -0
  42. package/dist/components/Notebook/types.d.ts +10 -0
  43. package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
  44. package/dist/components/Package/Package.d.ts +1 -4
  45. package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
  46. package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
  47. package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
  48. package/dist/components/ResultsDialog.d.ts +6 -1
  49. package/dist/components/ServerProvider.d.ts +28 -4
  50. package/dist/components/click_helper.d.ts +10 -1
  51. package/dist/components/drill/index.d.ts +3 -0
  52. package/dist/components/drill/markDrillableCells.d.ts +55 -0
  53. package/dist/components/drill/resolveDrill.d.ts +139 -0
  54. package/dist/components/drill/useDrill.d.ts +63 -0
  55. package/dist/components/given/GivenInput.d.ts +52 -0
  56. package/dist/components/given/GivensPanel.d.ts +47 -0
  57. package/dist/components/given/filterValue.d.ts +97 -0
  58. package/dist/components/given/index.d.ts +2 -0
  59. package/dist/components/given/paramCodec.d.ts +60 -0
  60. package/dist/components/given/utils.d.ts +17 -0
  61. package/dist/components/highlighter.d.ts +6 -1
  62. package/dist/components/index.d.ts +7 -2
  63. package/dist/components/styles.d.ts +47 -0
  64. package/dist/constants/docLinks.d.ts +12 -0
  65. package/dist/{core-YNpOLuB1.cjs.js → core-hLahnv0W.cjs.js} +1 -1
  66. package/dist/{core-CjeTkq8O.es.js → core-lb28vQkR.es.js} +1 -1
  67. package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
  68. package/dist/github-dark-DenFmJkN.es.js +4 -0
  69. package/dist/hooks/givenValue.d.ts +10 -0
  70. package/dist/hooks/index.d.ts +4 -0
  71. package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
  72. package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
  73. package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
  74. package/dist/hooks/useGivensState.d.ts +64 -0
  75. package/dist/hooks/useModelGivens.d.ts +10 -0
  76. package/dist/hooks/useSuggestOptions.d.ts +78 -0
  77. package/dist/index-DvEanVgc.cjs.js +339 -0
  78. package/dist/{index-DRDu9kIV.es.js → index-txw04ZbN.es.js} +40531 -27964
  79. package/dist/index.cjs.js +1 -1
  80. package/dist/index.d.ts +4 -1
  81. package/dist/index.es.js +79 -48
  82. package/dist/malloy-explorer.css +12 -1
  83. package/dist/sdk.css +1 -1
  84. package/dist/theme/ThemeContext.d.ts +45 -0
  85. package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
  86. package/dist/theme/buildTableCssVars.d.ts +25 -0
  87. package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
  88. package/dist/theme/defaults.d.ts +7 -0
  89. package/dist/theme/index.d.ts +8 -0
  90. package/dist/theme/keys.d.ts +20 -0
  91. package/dist/theme/readChartAnnotations.d.ts +23 -0
  92. package/dist/theme/resolveTheme.d.ts +22 -0
  93. package/dist/theme/types.d.ts +70 -0
  94. package/dist/utils/dataAppEmbed.d.ts +44 -0
  95. package/dist/utils/formatting.d.ts +1 -1
  96. package/dist/utils/malloyString.d.ts +7 -0
  97. package/dist/utils/parsing.d.ts +2 -2
  98. package/dist/utils/queryClient.d.ts +5 -0
  99. package/package.json +19 -8
  100. package/src/client-entry.ts +3 -0
  101. package/src/components/AnalyzePackageButton.tsx +9 -3
  102. package/src/components/ApiErrorDisplay.tsx +3 -0
  103. package/src/components/Connections/AddConnectionDialog.tsx +30 -2
  104. package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
  105. package/src/components/Connections/EditConnectionDialog.tsx +33 -4
  106. package/src/components/Connections/common.ts +64 -1
  107. package/src/components/DOMElement/DOMElement.tsx +3 -0
  108. package/src/components/DOMElement/index.ts +3 -0
  109. package/src/components/Dashboard/Dashboard.tsx +398 -0
  110. package/src/components/Dashboard/DashboardTile.tsx +153 -0
  111. package/src/components/Dashboard/index.ts +5 -0
  112. package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
  113. package/src/components/DataAppViewer/index.ts +4 -0
  114. package/src/components/{Project → Environment}/About.tsx +11 -4
  115. package/src/components/Environment/AddPackageDialog.tsx +202 -0
  116. package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
  117. package/src/components/Environment/Connections.tsx +391 -0
  118. package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
  119. package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
  120. package/src/components/Environment/Environment.tsx +89 -0
  121. package/src/components/Environment/Packages.tsx +206 -0
  122. package/src/components/Environment/index.ts +5 -0
  123. package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
  124. package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
  125. package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
  126. package/src/components/Home/Home.tsx +386 -408
  127. package/src/components/Home/index.ts +3 -0
  128. package/src/components/Loading.tsx +3 -0
  129. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
  130. package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
  131. package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
  132. package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
  133. package/src/components/Materializations/ManifestView.tsx +87 -0
  134. package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
  135. package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
  136. package/src/components/Materializations/Materializations.tsx +355 -0
  137. package/src/components/Materializations/ScheduleCard.tsx +231 -0
  138. package/src/components/Materializations/SectionLabel.tsx +30 -0
  139. package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
  140. package/src/components/Materializations/TriggerChip.tsx +44 -0
  141. package/src/components/Materializations/cron.ts +124 -0
  142. package/src/components/Materializations/index.ts +5 -0
  143. package/src/components/Materializations/utils.ts +145 -0
  144. package/src/components/Model/Model.tsx +44 -2
  145. package/src/components/Model/ModelCell.tsx +14 -5
  146. package/src/components/Model/ModelExplorer.tsx +3 -0
  147. package/src/components/Model/ModelExplorerDialog.tsx +4 -1
  148. package/src/components/Model/SourcesExplorer.tsx +9 -6
  149. package/src/components/Model/index.ts +3 -0
  150. package/src/components/Model/useModelData.ts +6 -3
  151. package/src/components/Notebook/Notebook.tsx +475 -339
  152. package/src/components/Notebook/NotebookCell.tsx +264 -25
  153. package/src/components/Notebook/index.ts +3 -0
  154. package/src/components/Notebook/runPlan.spec.ts +155 -0
  155. package/src/components/Notebook/runPlan.ts +67 -0
  156. package/src/components/Notebook/types.ts +14 -0
  157. package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
  158. package/src/components/Package/ContentTypeIcon.tsx +177 -0
  159. package/src/components/Package/FileTreeView.tsx +3 -0
  160. package/src/components/Package/Models.tsx +7 -4
  161. package/src/components/Package/Package.tsx +666 -59
  162. package/src/components/Package/index.ts +3 -0
  163. package/src/components/QueryResult/QueryResult.tsx +17 -8
  164. package/src/components/QueryResult/index.ts +3 -0
  165. package/src/components/RenderedResult/RenderedResult.tsx +685 -67
  166. package/src/components/RenderedResult/ResultContainer.tsx +71 -2
  167. package/src/components/RenderedResult/index.ts +3 -0
  168. package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
  169. package/src/components/RenderedResult/renderLogs.ts +43 -0
  170. package/src/components/ResultsDialog.tsx +13 -1
  171. package/src/components/ServerProvider.tsx +175 -51
  172. package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
  173. package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
  174. package/src/components/Workbook/ModelPicker.tsx +7 -4
  175. package/src/components/Workbook/MutableCell.tsx +10 -5
  176. package/src/components/Workbook/Workbook.tsx +8 -5
  177. package/src/components/Workbook/WorkbookList.tsx +3 -0
  178. package/src/components/Workbook/WorkbookManager.ts +3 -0
  179. package/src/components/Workbook/WorkbookStorage.ts +3 -0
  180. package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
  181. package/src/components/Workbook/index.ts +3 -0
  182. package/src/components/click_helper.ts +17 -1
  183. package/src/components/drill/index.ts +28 -0
  184. package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
  185. package/src/components/drill/markDrillableCells.spec.ts +109 -0
  186. package/src/components/drill/markDrillableCells.ts +314 -0
  187. package/src/components/drill/resolveDrill.spec.ts +449 -0
  188. package/src/components/drill/resolveDrill.ts +375 -0
  189. package/src/components/drill/useDrill.tsx +203 -0
  190. package/src/components/filter/DimensionFilter.tsx +3 -0
  191. package/src/components/filter/index.ts +3 -0
  192. package/src/components/filter/utils.ts +16 -5
  193. package/src/components/given/GivenInput.spec.tsx +689 -0
  194. package/src/components/given/GivenInput.tsx +801 -0
  195. package/src/components/given/GivensPanel.spec.tsx +175 -0
  196. package/src/components/given/GivensPanel.tsx +195 -0
  197. package/src/components/given/filterValue.spec.ts +364 -0
  198. package/src/components/given/filterValue.ts +207 -0
  199. package/src/components/given/index.ts +9 -0
  200. package/src/components/given/paramCodec.spec.ts +857 -0
  201. package/src/components/given/paramCodec.ts +483 -0
  202. package/src/components/given/utils.spec.ts +60 -0
  203. package/src/components/given/utils.ts +79 -0
  204. package/src/components/highlighter.ts +22 -5
  205. package/src/components/index.ts +10 -2
  206. package/src/components/styles.ts +82 -33
  207. package/src/constants/docLinks.spec.ts +54 -0
  208. package/src/constants/docLinks.ts +46 -0
  209. package/src/hooks/givenValue.ts +13 -0
  210. package/src/hooks/index.ts +13 -0
  211. package/src/hooks/useDimensionFilters.ts +4 -7
  212. package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
  213. package/src/hooks/useDimensionFiltersQuery.ts +10 -13
  214. package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
  215. package/src/hooks/useGivensState.spec.ts +449 -0
  216. package/src/hooks/useGivensState.ts +340 -0
  217. package/src/hooks/useModelGivens.ts +29 -0
  218. package/src/hooks/useQueryWithApiError.ts +3 -0
  219. package/src/hooks/useRawQueryData.ts +6 -3
  220. package/src/hooks/useSuggestOptions.spec.ts +112 -0
  221. package/src/hooks/useSuggestOptions.ts +263 -0
  222. package/src/index.ts +10 -1
  223. package/src/react-app-env.d.ts +3 -0
  224. package/src/theme/ThemeContext.tsx +86 -0
  225. package/src/theme/buildMalloyExplicitTheme.ts +61 -0
  226. package/src/theme/buildTableCssVars.spec.ts +67 -0
  227. package/src/theme/buildTableCssVars.ts +67 -0
  228. package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
  229. package/src/theme/buildVegaThemeOverride.ts +47 -0
  230. package/src/theme/defaults.ts +78 -0
  231. package/src/theme/index.ts +11 -0
  232. package/src/theme/keys.ts +32 -0
  233. package/src/theme/readChartAnnotations.spec.ts +58 -0
  234. package/src/theme/readChartAnnotations.ts +69 -0
  235. package/src/theme/resolveTheme.spec.ts +160 -0
  236. package/src/theme/resolveTheme.ts +121 -0
  237. package/src/theme/types.ts +79 -0
  238. package/src/utils/dataAppEmbed.spec.ts +63 -0
  239. package/src/utils/dataAppEmbed.ts +84 -0
  240. package/src/utils/formatting.spec.ts +25 -21
  241. package/src/utils/formatting.ts +11 -7
  242. package/src/utils/malloyString.spec.ts +24 -0
  243. package/src/utils/malloyString.ts +12 -0
  244. package/src/utils/parsing.spec.ts +26 -19
  245. package/src/utils/parsing.ts +11 -6
  246. package/src/utils/queryClient.ts +17 -0
  247. package/test/README.md +141 -0
  248. package/test/setup.ts +29 -0
  249. package/tsconfig.json +12 -1
  250. package/tsconfig.spec.json +22 -0
  251. package/vite.config.ts +3 -0
  252. package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
  253. package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
  254. package/dist/components/Home/AddProjectDialog.d.ts +0 -1
  255. package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
  256. package/dist/components/Home/EditProjectDialog.d.ts +0 -7
  257. package/dist/components/Package/Config.d.ts +0 -5
  258. package/dist/components/Package/Databases.d.ts +0 -5
  259. package/dist/components/Package/Notebooks.d.ts +0 -6
  260. package/dist/components/Project/Project.d.ts +0 -6
  261. package/dist/components/Project/index.d.ts +0 -2
  262. package/dist/index-BOLBP6_i.cjs.js +0 -233
  263. package/src/components/Package/Config.tsx +0 -97
  264. package/src/components/Package/Connections.tsx +0 -373
  265. package/src/components/Package/Databases.tsx +0 -228
  266. package/src/components/Package/Notebooks.tsx +0 -77
  267. package/src/components/Project/AddPackageDialog.tsx +0 -159
  268. package/src/components/Project/Packages.tsx +0 -191
  269. package/src/components/Project/Project.tsx +0 -52
  270. package/src/components/Project/index.ts +0 -2
  271. /package/dist/components/{Project → Environment}/About.d.ts +0 -0
  272. /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
  273. /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
  274. /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
  275. /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
  276. /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
  277. /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
@@ -0,0 +1,263 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { useQueries } from "@tanstack/react-query";
5
+ import { useMemo } from "react";
6
+ import type { Given } from "../client";
7
+ import { useServer } from "../components/ServerProvider";
8
+
9
+ /**
10
+ * How many options a generated `suggest { source=… dimension=… }` asks for.
11
+ *
12
+ * Stated here rather than left to the server's `DEFAULT_QUERY_ROW_LIMIT`, which
13
+ * is also 1000 but caps silently and in whatever order the warehouse returns.
14
+ * An explicit limit with an explicit order makes a truncated list the same list
15
+ * every time, and makes the cap something a reader of this file can see.
16
+ * A dimension with more distinct values than this needs a hand-written
17
+ * `suggest { query=… }`: a picker over thousands of options is the wrong
18
+ * control anyway.
19
+ */
20
+ export const SUGGEST_OPTION_LIMIT = 1000;
21
+
22
+ /**
23
+ * The name a `group_by` gives its output column, which is the last segment of a
24
+ * field path.
25
+ *
26
+ * `order_by` takes an output field name, not a path: `order_by:
27
+ * products.category` is refused outright ("order_by takes the name of a field in
28
+ * the query output, not a path"), while `group_by: products.category` names its
29
+ * column `category`. A joined dimension is the ordinary case for a `suggest`, so
30
+ * getting this wrong would have failed the option query for most of them.
31
+ */
32
+ function outputFieldName(dimension: string): string {
33
+ const segments = dimension.split(".");
34
+ return segments[segments.length - 1];
35
+ }
36
+
37
+ /**
38
+ * The query a `suggest { source=… dimension=… }` runs.
39
+ *
40
+ * Exported so the spec can assert the text this hook actually sends. A test that
41
+ * rebuilds the same string alongside it proves only that the test agrees with
42
+ * itself, and this text has already been wrong once: `order_by` takes an output
43
+ * field name, not a path, so a joined dimension failed the query outright.
44
+ */
45
+ export function buildSuggestQuery(source: string, dimension: string): string {
46
+ return (
47
+ `run: ${source} -> {\n` +
48
+ ` group_by: ${dimension}\n` +
49
+ ` order_by: ${outputFieldName(dimension)} asc\n` +
50
+ ` limit: ${SUGGEST_OPTION_LIMIT}\n` +
51
+ `}`
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Resolve the option lists behind `select` / `multiselect` controls.
57
+ *
58
+ * A `suggest` is an ordinary query: either a named one (`suggest { query=… }`)
59
+ * or a grouping over a dimension (`suggest { source=… dimension=… }`), so this
60
+ * runs it on the same governed query endpoint everything else uses. No new
61
+ * endpoint, and the row caps and authorize gates that apply to a surface's own
62
+ * queries apply to its dropdowns too.
63
+ *
64
+ * Takes plain `Given`s: `suggest` is declared on the given, so a notebook's
65
+ * Parameters panel and a dashboard's control row fill the same dropdown from
66
+ * the same declaration.
67
+ *
68
+ * Requested with `compactJson` because these results are never rendered: the
69
+ * flat row form is what the widget needs, and asking for the full Malloy result
70
+ * would mean parsing rendering metadata to get at a list of strings.
71
+ *
72
+ * KNOWN GAP, latent until something populates `suggest`. The request carries no
73
+ * `givens`, and `QueryRequest` has a field for them. That is fine for row caps
74
+ * but not for `#(authorize)`: a gate is evaluated against the request's givens,
75
+ * so a `suggest` over a gated source is denied and every dropdown on it resolves
76
+ * to "Options unavailable": the failure surfaces honestly, but the control is
77
+ * unusable. Deliberately not guessed at here, because *which* givens a suggest
78
+ * should carry is a real decision: the applied ones make the option list depend
79
+ * on the current filters, which this hook's caching deliberately avoids, while
80
+ * only the gate-relevant ones means knowing which those are. Whoever populates
81
+ * `suggest` server-side should settle it, and this hook's signature will need
82
+ * the values passed in.
83
+ */
84
+ export function useSuggestOptions(
85
+ environmentName: string,
86
+ packageName: string,
87
+ modelPath: string | undefined,
88
+ specs: Given[],
89
+ ): {
90
+ options: Map<string, string[]>;
91
+ isLoading: boolean;
92
+ /**
93
+ * Givens whose suggest query failed.
94
+ *
95
+ * Reported separately from an empty option list because the two look
96
+ * identical in a dropdown and mean opposite things: "this dimension has no
97
+ * values" is data, "the query did not run" is a fault, and a reader offered
98
+ * an empty picker has no way to tell which they are looking at.
99
+ */
100
+ failed: Set<string>;
101
+ } {
102
+ const { apiClients } = useServer();
103
+
104
+ // Only a picker needs options; a text box or a slider would just be issuing
105
+ // a query whose answer it never shows.
106
+ const suggestable = useMemo(
107
+ () =>
108
+ specs.filter(
109
+ (spec) =>
110
+ spec.name !== undefined &&
111
+ (spec.control === "select" || spec.control === "multiselect") &&
112
+ (spec.suggest?.query !== undefined ||
113
+ (spec.suggest?.source !== undefined &&
114
+ spec.suggest?.dimension !== undefined)),
115
+ ),
116
+ [specs],
117
+ );
118
+
119
+ const results = useQueries({
120
+ queries: suggestable.map((spec) => ({
121
+ queryKey: [
122
+ "givenSuggest",
123
+ environmentName,
124
+ packageName,
125
+ modelPath,
126
+ spec.name,
127
+ spec.suggest?.query,
128
+ spec.suggest?.source,
129
+ spec.suggest?.dimension,
130
+ ],
131
+ enabled: modelPath !== undefined,
132
+ // Option lists change with the data, not with the filters, so they are
133
+ // cached well past a single control interaction.
134
+ staleTime: 5 * 60 * 1000,
135
+ refetchOnWindowFocus: false,
136
+ queryFn: async () => {
137
+ const suggest = spec.suggest ?? {};
138
+ const response = await apiClients.models.executeQueryModel(
139
+ environmentName,
140
+ packageName,
141
+ modelPath as string,
142
+ suggest.query !== undefined
143
+ ? { queryName: suggest.query, compactJson: true }
144
+ : {
145
+ query: buildSuggestQuery(
146
+ suggest.source as string,
147
+ suggest.dimension as string,
148
+ ),
149
+ compactJson: true,
150
+ },
151
+ );
152
+ return readOptionValues(
153
+ response.data.result,
154
+ suggest.dimension === undefined
155
+ ? undefined
156
+ : outputFieldName(suggest.dimension),
157
+ );
158
+ },
159
+ })),
160
+ });
161
+
162
+ const options = useMemo(() => {
163
+ const byName = new Map<string, string[]>();
164
+ suggestable.forEach((spec, index) => {
165
+ const value = results[index]?.data;
166
+ if (spec.name && value) byName.set(spec.name, value);
167
+ });
168
+ return byName;
169
+ // `results` is a fresh array each render; its data identity is what
170
+ // matters, so depend on that rather than the wrapper objects.
171
+ //
172
+ // `JSON.stringify`, not `join("|")`. `join` flattens a nested array with
173
+ // commas and renders undefined as empty, so genuinely different option
174
+ // lists produced the SAME key: `[["a","b"]]` and `[["a,b"]]` both give
175
+ // `a,b`, and `[undefined]`, `[[]]` and `[[""]]` all give `""`. A refetch
176
+ // between two colliding lists left the previous dropdown in place.
177
+ // eslint-disable-next-line react-hooks/exhaustive-deps
178
+ }, [suggestable, JSON.stringify(results.map((result) => result.data))]);
179
+
180
+ const failed = useMemo(() => {
181
+ const names = new Set<string>();
182
+ suggestable.forEach((spec, index) => {
183
+ if (spec.name && results[index]?.isError) names.add(spec.name);
184
+ });
185
+ return names;
186
+ // Same reasoning as `options`: `results` is a fresh array each render.
187
+ // eslint-disable-next-line react-hooks/exhaustive-deps
188
+ }, [suggestable, results.map((result) => result.isError).join("|")]);
189
+
190
+ return {
191
+ options,
192
+ isLoading: results.some((result) => result.isLoading),
193
+ failed,
194
+ };
195
+ }
196
+
197
+ /**
198
+ * Pull the option strings out of a compact-JSON result.
199
+ *
200
+ * Prefers the named column and otherwise takes the first, which covers a
201
+ * `suggest { query=… }` whose column is named something else. Nulls are
202
+ * dropped: "no value" is expressed by clearing the control, not by picking an
203
+ * empty option.
204
+ *
205
+ * The name to pass is the OUTPUT column, so a joined `products.category` is
206
+ * looked up as `category`. Passing the path found nothing and fell through to
207
+ * the first column, which happened to be right only because the generated query
208
+ * selects exactly one.
209
+ */
210
+ export function readOptionValues(
211
+ result: string | undefined,
212
+ dimension: string | undefined,
213
+ ): string[] {
214
+ // Absent is tolerated: `result` is optional in the API contract, so a
215
+ // missing one is a shape the server is allowed to send and "no values" is
216
+ // the honest reading of it.
217
+ if (!result) return [];
218
+
219
+ // Corrupt is NOT tolerated, and the difference matters. This hook exists to
220
+ // separate "this dimension has no values" from "the option query failed",
221
+ // and returning `[]` for a response that could not be read collapsed the
222
+ // second into the first: the control rendered "No matching values" and told
223
+ // the reader a populated dimension was empty. Thrown, so react-query marks
224
+ // the query errored and `failed` reports it, which is what puts "Options
225
+ // unavailable" on the control.
226
+ let rows: unknown;
227
+ try {
228
+ rows = JSON.parse(result);
229
+ } catch {
230
+ throw new Error("Suggest query returned a result that is not JSON.");
231
+ }
232
+ if (!Array.isArray(rows)) {
233
+ throw new Error(
234
+ "Suggest query returned JSON that is not a list of rows.",
235
+ );
236
+ }
237
+
238
+ const values: string[] = [];
239
+ const seen = new Set<string>();
240
+ for (const row of rows) {
241
+ if (row === null || typeof row !== "object") continue;
242
+ const record = row as Record<string, unknown>;
243
+ const keys = Object.keys(record);
244
+ // `hasOwnProperty`, not `in`: `record` comes from `JSON.parse`, so `in`
245
+ // walks its prototype and reports `constructor`, `toString` and friends
246
+ // as present. A dimension with one of those names would select a
247
+ // function off the prototype instead of falling back to the first
248
+ // column. The same hazard was fixed in the app's URL merge; this is the
249
+ // other place the rule lives.
250
+ const key =
251
+ dimension !== undefined &&
252
+ Object.prototype.hasOwnProperty.call(record, dimension)
253
+ ? dimension
254
+ : keys[0];
255
+ const value = key === undefined ? undefined : record[key];
256
+ if (value === null || value === undefined) continue;
257
+ const text = String(value);
258
+ if (seen.has(text)) continue;
259
+ seen.add(text);
260
+ values.push(text);
261
+ }
262
+ return values;
263
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,15 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  export * from "./components";
2
- export { default as ConnectionExplorer } from "./components/Project/ConnectionExplorer";
5
+ export { default as ConnectionExplorer } from "./components/Environment/ConnectionExplorer";
3
6
  export { useServer } from "./components/ServerProvider";
4
7
  export * from "./hooks";
5
8
  export { useRawQueryData } from "./hooks/useRawQueryData";
9
+ export * from "./theme";
6
10
  export * from "./utils/formatting";
11
+ // How a package's own files are addressed. Exported because a host that renders
12
+ // its own "this path is not a model" state has to point at the URL that does
13
+ // serve the file, and this is the one place that string is built.
14
+ export { packageFileUrl } from "./utils/dataAppEmbed";
15
+ export * from "./constants/docLinks";
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  /* eslint-disable @typescript-eslint/triple-slash-reference */
2
5
  /// <reference types="node" />
3
6
  /// <reference types="react" />
@@ -0,0 +1,86 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import React, {
5
+ createContext,
6
+ useContext,
7
+ useMemo,
8
+ type ReactNode,
9
+ } from "react";
10
+ import { resolveTheme } from "./resolveTheme";
11
+ import type { ResolvedTheme, Theme, ThemeMode } from "./types";
12
+
13
+ interface ThemeContextValue {
14
+ /** Theme resolved from {@link layers} + {@link mode}. Used by the app shell. */
15
+ theme: ResolvedTheme;
16
+ /**
17
+ * Raw base layers in cascade order. Today this holds only the
18
+ * instance-level theme from `/status`; the built-in defaults live inside
19
+ * {@link resolveTheme}, not in this array. Exposed so per-chart renderers
20
+ * can append a per-chart override and re-run {@link resolveTheme} without
21
+ * losing that instance baseline. The merge accepts any number of
22
+ * lower-precedence layers, so a per-environment layer can be fed in here
23
+ * later (once the server wires it through) without changing the merge.
24
+ */
25
+ layers: Array<Theme | undefined>;
26
+ /**
27
+ * The effective mode applied to charts and chrome (always "light" or "dark").
28
+ * "auto" is resolved before reaching here.
29
+ */
30
+ mode: ThemeMode;
31
+ /**
32
+ * The viewer's stored preference: "light" | "dark" | "auto", or undefined
33
+ * when no choice has been persisted. Use this (not {@link mode}) when
34
+ * rendering a multi-state toggle that needs to expose "auto" as a position.
35
+ */
36
+ userChoice: ThemeMode | "auto" | undefined;
37
+ setMode: (mode: ThemeMode | "auto") => void;
38
+ allowUserToggle: boolean;
39
+ }
40
+
41
+ const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);
42
+
43
+ interface ThemeProviderProps {
44
+ layers: Array<Theme | undefined>;
45
+ mode: ThemeMode;
46
+ userChoice: ThemeMode | "auto" | undefined;
47
+ setMode: (mode: ThemeMode | "auto") => void;
48
+ allowUserToggle?: boolean;
49
+ children: ReactNode;
50
+ }
51
+
52
+ export function ThemeProvider({
53
+ layers,
54
+ mode,
55
+ userChoice,
56
+ setMode,
57
+ allowUserToggle = true,
58
+ children,
59
+ }: ThemeProviderProps) {
60
+ const theme = useMemo(() => resolveTheme(layers, mode), [layers, mode]);
61
+ const value = useMemo<ThemeContextValue>(
62
+ () => ({ theme, layers, mode, userChoice, setMode, allowUserToggle }),
63
+ [theme, layers, mode, userChoice, setMode, allowUserToggle],
64
+ );
65
+ return (
66
+ <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Resolved publisher theme. Returns a sensible default outside a provider
72
+ * so SDK consumers (third-party embedders, isolated stories) still get
73
+ * styled output without having to mount the provider.
74
+ */
75
+ export function usePublisherTheme(): ThemeContextValue {
76
+ const ctx = useContext(ThemeContext);
77
+ if (ctx) return ctx;
78
+ return {
79
+ theme: resolveTheme([], "light"),
80
+ layers: [],
81
+ mode: "light",
82
+ userChoice: undefined,
83
+ setMode: () => {},
84
+ allowUserToggle: false,
85
+ };
86
+ }
@@ -0,0 +1,61 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import type { MalloyExplicitTheme } from "@malloydata/render";
5
+ import type { ResolvedTheme } from "./types";
6
+
7
+ /**
8
+ * Map our {@link ResolvedTheme} onto the explicit `theme` option that
9
+ * `@malloydata/render` accepts. Values flow into the renderer's inline
10
+ * `--malloy-render--*` style ahead of any `# theme.*` annotations the
11
+ * Malloy result carries, so operator choices made in the Theme Editor
12
+ * reach table chrome and dashboard tiles directly instead of going
13
+ * through the outer-wrapper var cascade.
14
+ *
15
+ * Two non-operator-customizable fields:
16
+ *
17
+ * - `background` paints the renderer's HTML chrome (the area between
18
+ * dashboard tiles). Sourced from `theme.dashboardRoot` — mode-keyed,
19
+ * stays decoupled from `palette.background` so a bold accent on the
20
+ * chart canvas doesn't bleed across the panel.
21
+ * - `tableBackground` paints the table interior. Sourced from
22
+ * `theme.tableBackground` — currently tracks `palette.background`
23
+ * so charts and tables share a single viz surface colour.
24
+ *
25
+ * Operator-customizable mappings:
26
+ *
27
+ * - `tablePinnedBackground` = `theme.tableHeaderBackground` (a NEW
28
+ * schema field). Despite the renderer's name, this paints the
29
+ * table header row (`.malloy-table .pinned-header.th` in
30
+ * scroll-pinned tables; for non-pinned tables our CSS override
31
+ * forces the same value onto `.th.column-cell`). Distinct from
32
+ * `tile` (below).
33
+ * - `tile` does NOT flow to `tablePinnedBackground` anymore — the
34
+ * dashboard tile container picks it up via our outer-wrapper
35
+ * `--malloy-render--tile-background` var and the CSS override on
36
+ * `.dashboard-item`. See `buildTableCssVars`.
37
+ */
38
+ export function buildMalloyExplicitTheme(
39
+ theme: ResolvedTheme,
40
+ ): MalloyExplicitTheme {
41
+ return {
42
+ background: theme.dashboardRoot,
43
+ tableBackground: theme.tableBackground,
44
+ tableHeaderColor: theme.tableHeader,
45
+ tableBodyColor: theme.tableBody,
46
+ tableBorder: theme.border,
47
+ // Header row background (operator-customizable, NEW). The
48
+ // renderer reuses tablePinnedBackground for any pinned header
49
+ // cell; we additionally paint the regular header row from the
50
+ // same var via injectRendererOverrides so non-pinned tables
51
+ // also show the header band.
52
+ tablePinnedBackground: theme.tableHeaderBackground,
53
+ tablePinnedBorder: theme.pinnedBorder,
54
+ tableFontSize: `${theme.font.size}px`,
55
+ fontFamily: theme.font.family,
56
+ // Saturated end of the choropleth gradient. The renderer
57
+ // generates a low-to-high ramp from a neutral grey to this
58
+ // colour for shape-map / segment-map plugins via getColorScale.
59
+ mapColor: theme.mapColor,
60
+ };
61
+ }
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { describe, expect, it } from "bun:test";
5
+ import { buildTableCssVars } from "./buildTableCssVars";
6
+ import { resolveTheme } from "./resolveTheme";
7
+
8
+ describe("buildTableCssVars", () => {
9
+ it("emits only --malloy-render--* and --publisher-* namespaces (no shadow --malloy-theme--*)", () => {
10
+ const vars = buildTableCssVars(resolveTheme([], "light"));
11
+ for (const key of Object.keys(vars)) {
12
+ const allowed =
13
+ key.startsWith("--malloy-render--") ||
14
+ key.startsWith("--publisher-");
15
+ expect(allowed).toBe(true);
16
+ expect(key.startsWith("--malloy-theme--")).toBe(false);
17
+ }
18
+ });
19
+
20
+ it("includes header, body, border, tile, label, value", () => {
21
+ const t = resolveTheme([], "light");
22
+ const vars = buildTableCssVars(t);
23
+ expect(vars["--malloy-render--table-header-color"]).toBe(t.tableHeader);
24
+ expect(vars["--malloy-render--table-body-color"]).toBe(t.tableBody);
25
+ expect(vars["--malloy-render--table-border"]).toBe(t.border);
26
+ // `tile-background` is our custom var for the dashboard tile
27
+ // container. It's NOT the renderer's `table-pinned-background`
28
+ // (which now carries `tableHeaderBackground` via the theme prop).
29
+ expect(vars["--malloy-render--tile-background"]).toBe(t.tile);
30
+ expect(vars["--malloy-render--label-color"]).toBe(t.tileTitle);
31
+ expect(vars["--malloy-render--value-color"]).toBe(t.valueColor);
32
+ });
33
+
34
+ it("omits the dashboard-root background keys", () => {
35
+ // background and table-background are deliberately not surfaced
36
+ // here; the renderer paints the dashboard chrome with its own
37
+ // neutral default and the operator's accent lands on viz
38
+ // surfaces (charts via Vega, tables via the renderer prop).
39
+ const vars = buildTableCssVars(resolveTheme([], "light"));
40
+ expect(vars["--malloy-render--background"]).toBeUndefined();
41
+ expect(vars["--malloy-render--table-background"]).toBeUndefined();
42
+ });
43
+
44
+ it("flips body color and tile background in dark mode", () => {
45
+ const dark = resolveTheme([], "dark");
46
+ const vars = buildTableCssVars(dark);
47
+ expect(vars["--malloy-render--table-body-color"]).toBe("#e2e8f0");
48
+ expect(vars["--malloy-render--tile-background"]).toBe("#0f172a");
49
+ });
50
+
51
+ it("honors a custom font size from the theme", () => {
52
+ const t = resolveTheme([{ font: { size: 14 } }], "light");
53
+ expect(buildTableCssVars(t)["--malloy-render--table-font-size"]).toBe(
54
+ "14px",
55
+ );
56
+ });
57
+
58
+ it("emits the font-family token consumed by the renderer", () => {
59
+ const t = resolveTheme(
60
+ [{ font: { family: "Roboto, sans-serif" } }],
61
+ "light",
62
+ );
63
+ expect(buildTableCssVars(t)["--malloy-render--font-family"]).toBe(
64
+ "Roboto, sans-serif",
65
+ );
66
+ });
67
+ });
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import type { ResolvedTheme } from "./types";
5
+
6
+ /**
7
+ * Build the CSS variable map applied to the wrapper element around
8
+ * `<malloy-render>`. The values here power two things only:
9
+ *
10
+ * 1. The dashboard tile chrome rules in
11
+ * {@link PUBLISHER_RENDERER_OVERRIDES_CSS} (`.dashboard-item`,
12
+ * `.dashboard-item-title`, `.dashboard-item-value`, ...). The
13
+ * renderer doesn't expose those surfaces through its `theme` prop,
14
+ * so we paint them ourselves via the var cascade.
15
+ *
16
+ * 2. Renderer-internal rules that read the same `--malloy-render--*`
17
+ * names. The renderer's own `theme` prop write (see
18
+ * `buildMalloyExplicitTheme`) usually sets these inline on a deeper
19
+ * element first, but we set them on the outer wrapper so the var
20
+ * has a value even when the prop is partial.
21
+ *
22
+ * Single namespace by design: the `--malloy-theme--*` shadow set we
23
+ * used to emit was a workaround for the renderer's
24
+ * `var(--malloy-theme--<key>)` fallback lookup, which only fires when
25
+ * no explicit `theme` prop is given. With the prop wired we no longer
26
+ * compete with that lookup, so the shadow namespace just bloated
27
+ * every wrapper element's inline style.
28
+ */
29
+ export function buildTableCssVars(
30
+ theme: ResolvedTheme,
31
+ ): Record<string, string> {
32
+ return {
33
+ "--malloy-render--font-family": theme.font.family,
34
+ "--malloy-render--table-font-size": `${theme.font.size}px`,
35
+ "--malloy-render--table-header-color": theme.tableHeader,
36
+ "--malloy-render--table-body-color": theme.tableBody,
37
+ "--malloy-render--table-border": theme.border,
38
+ "--malloy-render--table-pinned-border": theme.pinnedBorder,
39
+ // Custom var (not used by the renderer's own CSS). Drives the
40
+ // dashboard tile container background via our
41
+ // injectRendererOverrides rule on `.dashboard-item`. Kept
42
+ // separate from `--malloy-render--table-pinned-background`
43
+ // (which is the renderer's own var for the table header band)
44
+ // so the operator can theme the tile padding and the table
45
+ // header row independently.
46
+ "--malloy-render--tile-background": theme.tile,
47
+ // Custom var for the dashboard PANEL (area between tiles).
48
+ // Set on the outer Publisher wrapper rather than relying on the
49
+ // renderer's own `--malloy-render--background` because that var
50
+ // gets shadowed by an inline write deeper in the renderer's DOM
51
+ // when annotations are present — and our intent here is to keep
52
+ // the panel neutral regardless of any annotation. The
53
+ // injectRendererOverrides CSS reads this var on .malloy-dashboard
54
+ // and its row-header / row-body children.
55
+ "--publisher-dashboard-root": theme.dashboardRoot,
56
+ // Drives the dashboard tile title (e.g. "by_month" above a chart)
57
+ // and the dimension-name text via injectRendererOverrides.
58
+ "--malloy-render--label-color": theme.tileTitle,
59
+ // The numeric value rendered under each tile title. Not editable
60
+ // in v1; computed from the active mode for readable contrast.
61
+ "--malloy-render--value-color": theme.valueColor,
62
+ // Custom var. Drives the hover colour of a `# drill` cell via the
63
+ // .publisher-drill rule in injectRendererOverrides: the renderer
64
+ // has no notion of drill, so the affordance is entirely ours.
65
+ "--publisher-drill-link": theme.drillLink,
66
+ };
67
+ }
@@ -0,0 +1,56 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { describe, expect, it } from "bun:test";
5
+ import { buildVegaThemeOverride } from "./buildVegaThemeOverride";
6
+ import { resolveTheme } from "./resolveTheme";
7
+
8
+ describe("buildVegaThemeOverride", () => {
9
+ it("populates range.category from the resolved series", () => {
10
+ const t = resolveTheme(
11
+ [{ palette: { series: ["#ff0080", "#ff6b00"] } }],
12
+ "light",
13
+ );
14
+ const config = buildVegaThemeOverride(t)("bar");
15
+ const ranges = (config as { range: { category: string[] } }).range;
16
+ expect(ranges.category).toEqual(["#ff0080", "#ff6b00"]);
17
+ });
18
+
19
+ it("sets background to the resolved theme background", () => {
20
+ const t = resolveTheme(
21
+ [{ palette: { background: { dark: "#001122" } } }],
22
+ "dark",
23
+ );
24
+ const config = buildVegaThemeOverride(t)("line");
25
+ expect((config as { background: string }).background).toBe("#001122");
26
+ });
27
+
28
+ it("propagates the font family to axis/legend/title text marks", () => {
29
+ const t = resolveTheme([{ font: { family: "Roboto Mono" } }], "light");
30
+ const cfg = buildVegaThemeOverride(t)("bar") as {
31
+ font: string;
32
+ axis: { labelFont: string; titleFont: string };
33
+ legend: { labelFont: string; titleFont: string };
34
+ title: { font: string };
35
+ };
36
+ expect(cfg.font).toBe("Roboto Mono");
37
+ expect(cfg.axis.labelFont).toBe("Roboto Mono");
38
+ expect(cfg.legend.titleFont).toBe("Roboto Mono");
39
+ expect(cfg.title.font).toBe("Roboto Mono");
40
+ });
41
+
42
+ it("uses the resolved foreground + axisFaint values (no mode branch)", () => {
43
+ const dark = resolveTheme([], "dark");
44
+ const cfg = buildVegaThemeOverride(dark)("bar") as {
45
+ axis: { labelColor: string; gridColor: string };
46
+ };
47
+ expect(cfg.axis.labelColor).toBe(dark.foreground);
48
+ expect(cfg.axis.gridColor).toBe(dark.axisFaint);
49
+ });
50
+
51
+ it("returns the same config across chart types in v1", () => {
52
+ const t = resolveTheme([], "light");
53
+ const cb = buildVegaThemeOverride(t);
54
+ expect(cb("bar")).toBe(cb("line"));
55
+ });
56
+ });
@@ -0,0 +1,47 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import type { ResolvedTheme } from "./types";
5
+
6
+ /**
7
+ * Produce a `vegaConfigOverride` callback for `new MalloyRenderer({...})`.
8
+ * The renderer invokes the callback once per chart type and merges the
9
+ * returned object into the Vega spec's config. We set the category
10
+ * colour scale, the global font, the page background, and foreground /
11
+ * faint colours so chart text and axis chrome inherit the active mode.
12
+ *
13
+ * Foreground and axis-faint values come from {@link ResolvedTheme}
14
+ * (computed once in `resolveTheme`), so this builder no longer branches
15
+ * on mode itself.
16
+ *
17
+ * The same config is returned for every chart type today. The
18
+ * parameter is reserved for future per-chart-type tweaks.
19
+ */
20
+ export function buildVegaThemeOverride(theme: ResolvedTheme) {
21
+ const { foreground, axisFaint, font } = theme;
22
+
23
+ const config: Record<string, unknown> = {
24
+ background: theme.background,
25
+ font: font.family,
26
+ title: { color: foreground, font: font.family },
27
+ axis: {
28
+ labelColor: foreground,
29
+ titleColor: foreground,
30
+ domainColor: axisFaint,
31
+ tickColor: axisFaint,
32
+ gridColor: axisFaint,
33
+ labelFont: font.family,
34
+ titleFont: font.family,
35
+ },
36
+ legend: {
37
+ labelColor: foreground,
38
+ titleColor: foreground,
39
+ labelFont: font.family,
40
+ titleFont: font.family,
41
+ },
42
+ header: { labelColor: foreground, titleColor: foreground },
43
+ range: { category: theme.series },
44
+ };
45
+
46
+ return (_chartType: string) => config;
47
+ }