@sqlrooms/mosaic 0.29.0-rc.1 → 0.29.0-rc.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 (398) hide show
  1. package/README.md +161 -2
  2. package/dist/MosaicChart.d.ts +20 -0
  3. package/dist/MosaicChart.d.ts.map +1 -0
  4. package/dist/MosaicChart.js +25 -0
  5. package/dist/MosaicChart.js.map +1 -0
  6. package/dist/MosaicChartBuilder.d.ts +67 -0
  7. package/dist/MosaicChartBuilder.d.ts.map +1 -0
  8. package/dist/MosaicChartBuilder.js +33 -0
  9. package/dist/MosaicChartBuilder.js.map +1 -0
  10. package/dist/MosaicColorLegend.d.ts +18 -0
  11. package/dist/MosaicColorLegend.d.ts.map +1 -0
  12. package/dist/MosaicColorLegend.js +117 -0
  13. package/dist/MosaicColorLegend.js.map +1 -0
  14. package/dist/MosaicSlice.d.ts +27 -13
  15. package/dist/MosaicSlice.d.ts.map +1 -1
  16. package/dist/MosaicSlice.js +140 -42
  17. package/dist/MosaicSlice.js.map +1 -1
  18. package/dist/ResponsivePlot.d.ts +23 -0
  19. package/dist/ResponsivePlot.d.ts.map +1 -0
  20. package/dist/ResponsivePlot.js +43 -0
  21. package/dist/ResponsivePlot.js.map +1 -0
  22. package/dist/VgPlotChart.d.ts +24 -0
  23. package/dist/VgPlotChart.d.ts.map +1 -1
  24. package/dist/VgPlotChart.js +127 -21
  25. package/dist/VgPlotChart.js.map +1 -1
  26. package/dist/chart-builders/ChartBuilderActions.d.ts +6 -0
  27. package/dist/chart-builders/ChartBuilderActions.d.ts.map +1 -0
  28. package/dist/chart-builders/ChartBuilderActions.js +28 -0
  29. package/dist/chart-builders/ChartBuilderActions.js.map +1 -0
  30. package/dist/chart-builders/ChartBuilderContent.d.ts +28 -0
  31. package/dist/chart-builders/ChartBuilderContent.d.ts.map +1 -0
  32. package/dist/chart-builders/ChartBuilderContent.js +28 -0
  33. package/dist/chart-builders/ChartBuilderContent.js.map +1 -0
  34. package/dist/chart-builders/ChartBuilderContext.d.ts +16 -0
  35. package/dist/chart-builders/ChartBuilderContext.d.ts.map +1 -0
  36. package/dist/chart-builders/ChartBuilderContext.js +15 -0
  37. package/dist/chart-builders/ChartBuilderContext.js.map +1 -0
  38. package/dist/chart-builders/ChartBuilderDialog.d.ts +48 -0
  39. package/dist/chart-builders/ChartBuilderDialog.d.ts.map +1 -0
  40. package/dist/chart-builders/ChartBuilderDialog.js +30 -0
  41. package/dist/chart-builders/ChartBuilderDialog.js.map +1 -0
  42. package/dist/chart-builders/ChartBuilderFields.d.ts +6 -0
  43. package/dist/chart-builders/ChartBuilderFields.d.ts.map +1 -0
  44. package/dist/chart-builders/ChartBuilderFields.js +25 -0
  45. package/dist/chart-builders/ChartBuilderFields.js.map +1 -0
  46. package/dist/chart-builders/ChartBuilderRoot.d.ts +27 -0
  47. package/dist/chart-builders/ChartBuilderRoot.d.ts.map +1 -0
  48. package/dist/chart-builders/ChartBuilderRoot.js +61 -0
  49. package/dist/chart-builders/ChartBuilderRoot.js.map +1 -0
  50. package/dist/chart-builders/ChartBuilderTypeGrid.d.ts +7 -0
  51. package/dist/chart-builders/ChartBuilderTypeGrid.d.ts.map +1 -0
  52. package/dist/chart-builders/ChartBuilderTypeGrid.js +23 -0
  53. package/dist/chart-builders/ChartBuilderTypeGrid.js.map +1 -0
  54. package/dist/chart-builders/FieldSelectorInput.d.ts +13 -0
  55. package/dist/chart-builders/FieldSelectorInput.d.ts.map +1 -0
  56. package/dist/chart-builders/FieldSelectorInput.js +19 -0
  57. package/dist/chart-builders/FieldSelectorInput.js.map +1 -0
  58. package/dist/chart-builders/builders.d.ts +34 -0
  59. package/dist/chart-builders/builders.d.ts.map +1 -0
  60. package/dist/chart-builders/builders.js +51 -0
  61. package/dist/chart-builders/builders.js.map +1 -0
  62. package/dist/chart-builders/chartSpecTitle.d.ts +6 -0
  63. package/dist/chart-builders/chartSpecTitle.d.ts.map +1 -0
  64. package/dist/chart-builders/chartSpecTitle.js +8 -0
  65. package/dist/chart-builders/chartSpecTitle.js.map +1 -0
  66. package/dist/chart-builders/chartTypeUtils.d.ts +17 -0
  67. package/dist/chart-builders/chartTypeUtils.d.ts.map +1 -0
  68. package/dist/chart-builders/chartTypeUtils.js +55 -0
  69. package/dist/chart-builders/chartTypeUtils.js.map +1 -0
  70. package/dist/chart-builders/constants.d.ts +7 -0
  71. package/dist/chart-builders/constants.d.ts.map +1 -0
  72. package/dist/chart-builders/constants.js +34 -0
  73. package/dist/chart-builders/constants.js.map +1 -0
  74. package/dist/chart-builders/createChartBuilderStore.d.ts +11 -0
  75. package/dist/chart-builders/createChartBuilderStore.d.ts.map +1 -0
  76. package/dist/chart-builders/createChartBuilderStore.js +26 -0
  77. package/dist/chart-builders/createChartBuilderStore.js.map +1 -0
  78. package/dist/chart-builders/describeChartSpecs.d.ts +9 -0
  79. package/dist/chart-builders/describeChartSpecs.d.ts.map +1 -0
  80. package/dist/chart-builders/describeChartSpecs.js +41 -0
  81. package/dist/chart-builders/describeChartSpecs.js.map +1 -0
  82. package/dist/chart-builders/hooks/useChartFieldForm.d.ts +13 -0
  83. package/dist/chart-builders/hooks/useChartFieldForm.d.ts.map +1 -0
  84. package/dist/chart-builders/hooks/useChartFieldForm.js +12 -0
  85. package/dist/chart-builders/hooks/useChartFieldForm.js.map +1 -0
  86. package/dist/chart-builders/types.d.ts +23 -0
  87. package/dist/chart-builders/types.d.ts.map +1 -0
  88. package/dist/chart-builders/types.js +17 -0
  89. package/dist/chart-builders/types.js.map +1 -0
  90. package/dist/chart-types/base-types.d.ts +54 -0
  91. package/dist/chart-types/base-types.d.ts.map +1 -0
  92. package/dist/chart-types/base-types.js +6 -0
  93. package/dist/chart-types/base-types.js.map +1 -0
  94. package/dist/chart-types/box-plot/definition.d.ts +4 -0
  95. package/dist/chart-types/box-plot/definition.d.ts.map +1 -0
  96. package/dist/chart-types/box-plot/definition.js +45 -0
  97. package/dist/chart-types/box-plot/definition.js.map +1 -0
  98. package/dist/chart-types/box-plot/index.d.ts +3 -0
  99. package/dist/chart-types/box-plot/index.d.ts.map +1 -0
  100. package/dist/chart-types/box-plot/index.js +3 -0
  101. package/dist/chart-types/box-plot/index.js.map +1 -0
  102. package/dist/chart-types/box-plot/schema.d.ts +17 -0
  103. package/dist/chart-types/box-plot/schema.d.ts.map +1 -0
  104. package/dist/chart-types/box-plot/schema.js +12 -0
  105. package/dist/chart-types/box-plot/schema.js.map +1 -0
  106. package/dist/chart-types/bubble-chart/definition.d.ts +4 -0
  107. package/dist/chart-types/bubble-chart/definition.d.ts.map +1 -0
  108. package/dist/chart-types/bubble-chart/definition.js +48 -0
  109. package/dist/chart-types/bubble-chart/definition.js.map +1 -0
  110. package/dist/chart-types/bubble-chart/index.d.ts +3 -0
  111. package/dist/chart-types/bubble-chart/index.d.ts.map +1 -0
  112. package/dist/chart-types/bubble-chart/index.js +3 -0
  113. package/dist/chart-types/bubble-chart/index.js.map +1 -0
  114. package/dist/chart-types/bubble-chart/schema.d.ts +17 -0
  115. package/dist/chart-types/bubble-chart/schema.d.ts.map +1 -0
  116. package/dist/chart-types/bubble-chart/schema.js +12 -0
  117. package/dist/chart-types/bubble-chart/schema.js.map +1 -0
  118. package/dist/chart-types/count-plot/definition.d.ts +4 -0
  119. package/dist/chart-types/count-plot/definition.d.ts.map +1 -0
  120. package/dist/chart-types/count-plot/definition.js +50 -0
  121. package/dist/chart-types/count-plot/definition.js.map +1 -0
  122. package/dist/chart-types/count-plot/index.d.ts +3 -0
  123. package/dist/chart-types/count-plot/index.d.ts.map +1 -0
  124. package/dist/chart-types/count-plot/index.js +3 -0
  125. package/dist/chart-types/count-plot/index.js.map +1 -0
  126. package/dist/chart-types/count-plot/schema.d.ts +15 -0
  127. package/dist/chart-types/count-plot/schema.d.ts.map +1 -0
  128. package/dist/chart-types/count-plot/schema.js +11 -0
  129. package/dist/chart-types/count-plot/schema.js.map +1 -0
  130. package/dist/chart-types/custom-spec/definition.d.ts +4 -0
  131. package/dist/chart-types/custom-spec/definition.d.ts.map +1 -0
  132. package/dist/chart-types/custom-spec/definition.js +28 -0
  133. package/dist/chart-types/custom-spec/definition.js.map +1 -0
  134. package/dist/chart-types/custom-spec/index.d.ts +3 -0
  135. package/dist/chart-types/custom-spec/index.d.ts.map +1 -0
  136. package/dist/chart-types/custom-spec/index.js +3 -0
  137. package/dist/chart-types/custom-spec/index.js.map +1 -0
  138. package/dist/chart-types/custom-spec/schema.d.ts +11 -0
  139. package/dist/chart-types/custom-spec/schema.d.ts.map +1 -0
  140. package/dist/chart-types/custom-spec/schema.js +9 -0
  141. package/dist/chart-types/custom-spec/schema.js.map +1 -0
  142. package/dist/chart-types/ecdf/definition.d.ts +4 -0
  143. package/dist/chart-types/ecdf/definition.d.ts.map +1 -0
  144. package/dist/chart-types/ecdf/definition.js +47 -0
  145. package/dist/chart-types/ecdf/definition.js.map +1 -0
  146. package/dist/chart-types/ecdf/index.d.ts +3 -0
  147. package/dist/chart-types/ecdf/index.d.ts.map +1 -0
  148. package/dist/chart-types/ecdf/index.js +3 -0
  149. package/dist/chart-types/ecdf/index.js.map +1 -0
  150. package/dist/chart-types/ecdf/schema.d.ts +15 -0
  151. package/dist/chart-types/ecdf/schema.d.ts.map +1 -0
  152. package/dist/chart-types/ecdf/schema.js +11 -0
  153. package/dist/chart-types/ecdf/schema.js.map +1 -0
  154. package/dist/chart-types/heatmap/definition.d.ts +4 -0
  155. package/dist/chart-types/heatmap/definition.d.ts.map +1 -0
  156. package/dist/chart-types/heatmap/definition.js +49 -0
  157. package/dist/chart-types/heatmap/definition.js.map +1 -0
  158. package/dist/chart-types/heatmap/index.d.ts +3 -0
  159. package/dist/chart-types/heatmap/index.d.ts.map +1 -0
  160. package/dist/chart-types/heatmap/index.js +3 -0
  161. package/dist/chart-types/heatmap/index.js.map +1 -0
  162. package/dist/chart-types/heatmap/schema.d.ts +17 -0
  163. package/dist/chart-types/heatmap/schema.d.ts.map +1 -0
  164. package/dist/chart-types/heatmap/schema.js +12 -0
  165. package/dist/chart-types/heatmap/schema.js.map +1 -0
  166. package/dist/chart-types/histogram/definition.d.ts +4 -0
  167. package/dist/chart-types/histogram/definition.d.ts.map +1 -0
  168. package/dist/chart-types/histogram/definition.js +49 -0
  169. package/dist/chart-types/histogram/definition.js.map +1 -0
  170. package/dist/chart-types/histogram/index.d.ts +3 -0
  171. package/dist/chart-types/histogram/index.d.ts.map +1 -0
  172. package/dist/chart-types/histogram/index.js +3 -0
  173. package/dist/chart-types/histogram/index.js.map +1 -0
  174. package/dist/chart-types/histogram/schema.d.ts +15 -0
  175. package/dist/chart-types/histogram/schema.d.ts.map +1 -0
  176. package/dist/chart-types/histogram/schema.js +11 -0
  177. package/dist/chart-types/histogram/schema.js.map +1 -0
  178. package/dist/chart-types/index.d.ts +109 -0
  179. package/dist/chart-types/index.d.ts.map +1 -0
  180. package/dist/chart-types/index.js +70 -0
  181. package/dist/chart-types/index.js.map +1 -0
  182. package/dist/chart-types/line-chart/definition.d.ts +4 -0
  183. package/dist/chart-types/line-chart/definition.d.ts.map +1 -0
  184. package/dist/chart-types/line-chart/definition.js +46 -0
  185. package/dist/chart-types/line-chart/definition.js.map +1 -0
  186. package/dist/chart-types/line-chart/index.d.ts +3 -0
  187. package/dist/chart-types/line-chart/index.d.ts.map +1 -0
  188. package/dist/chart-types/line-chart/index.js +3 -0
  189. package/dist/chart-types/line-chart/index.js.map +1 -0
  190. package/dist/chart-types/line-chart/schema.d.ts +17 -0
  191. package/dist/chart-types/line-chart/schema.d.ts.map +1 -0
  192. package/dist/chart-types/line-chart/schema.js +12 -0
  193. package/dist/chart-types/line-chart/schema.js.map +1 -0
  194. package/dist/chart-types/registry.d.ts +5 -0
  195. package/dist/chart-types/registry.d.ts.map +1 -0
  196. package/dist/chart-types/registry.js +28 -0
  197. package/dist/chart-types/registry.js.map +1 -0
  198. package/dist/dashboard/DashboardPanelErrorBoundary.d.ts +17 -0
  199. package/dist/dashboard/DashboardPanelErrorBoundary.d.ts.map +1 -0
  200. package/dist/dashboard/DashboardPanelErrorBoundary.js +21 -0
  201. package/dist/dashboard/DashboardPanelErrorBoundary.js.map +1 -0
  202. package/dist/dashboard/MosaicDashboard.d.ts +18 -0
  203. package/dist/dashboard/MosaicDashboard.d.ts.map +1 -0
  204. package/dist/dashboard/MosaicDashboard.js +91 -0
  205. package/dist/dashboard/MosaicDashboard.js.map +1 -0
  206. package/dist/dashboard/MosaicDashboardContext.d.ts +12 -0
  207. package/dist/dashboard/MosaicDashboardContext.d.ts.map +1 -0
  208. package/dist/dashboard/MosaicDashboardContext.js +10 -0
  209. package/dist/dashboard/MosaicDashboardContext.js.map +1 -0
  210. package/dist/dashboard/MosaicDashboardPanel.d.ts +3 -0
  211. package/dist/dashboard/MosaicDashboardPanel.d.ts.map +1 -0
  212. package/dist/dashboard/MosaicDashboardPanel.js +26 -0
  213. package/dist/dashboard/MosaicDashboardPanel.js.map +1 -0
  214. package/dist/dashboard/MosaicDashboardPanelDragOverlay.d.ts +8 -0
  215. package/dist/dashboard/MosaicDashboardPanelDragOverlay.d.ts.map +1 -0
  216. package/dist/dashboard/MosaicDashboardPanelDragOverlay.js +17 -0
  217. package/dist/dashboard/MosaicDashboardPanelDragOverlay.js.map +1 -0
  218. package/dist/dashboard/MosaicDashboardPanelHeader.d.ts +13 -0
  219. package/dist/dashboard/MosaicDashboardPanelHeader.d.ts.map +1 -0
  220. package/dist/dashboard/MosaicDashboardPanelHeader.js +30 -0
  221. package/dist/dashboard/MosaicDashboardPanelHeader.js.map +1 -0
  222. package/dist/dashboard/MosaicDashboardPanelLayout.d.ts +10 -0
  223. package/dist/dashboard/MosaicDashboardPanelLayout.d.ts.map +1 -0
  224. package/dist/dashboard/MosaicDashboardPanelLayout.js +25 -0
  225. package/dist/dashboard/MosaicDashboardPanelLayout.js.map +1 -0
  226. package/dist/dashboard/MosaicDashboardPanels.d.ts +2 -0
  227. package/dist/dashboard/MosaicDashboardPanels.d.ts.map +1 -0
  228. package/dist/dashboard/MosaicDashboardPanels.js +52 -0
  229. package/dist/dashboard/MosaicDashboardPanels.js.map +1 -0
  230. package/dist/dashboard/MosaicDashboardProfilerPanelRenderer.d.ts +3 -0
  231. package/dist/dashboard/MosaicDashboardProfilerPanelRenderer.d.ts.map +1 -0
  232. package/dist/dashboard/MosaicDashboardProfilerPanelRenderer.js +32 -0
  233. package/dist/dashboard/MosaicDashboardProfilerPanelRenderer.js.map +1 -0
  234. package/dist/dashboard/MosaicDashboardSlice.d.ts +523 -0
  235. package/dist/dashboard/MosaicDashboardSlice.d.ts.map +1 -0
  236. package/dist/dashboard/MosaicDashboardSlice.js +615 -0
  237. package/dist/dashboard/MosaicDashboardSlice.js.map +1 -0
  238. package/dist/dashboard/MosaicDashboardToolbar.d.ts +3 -0
  239. package/dist/dashboard/MosaicDashboardToolbar.d.ts.map +1 -0
  240. package/dist/dashboard/MosaicDashboardToolbar.js +81 -0
  241. package/dist/dashboard/MosaicDashboardToolbar.js.map +1 -0
  242. package/dist/dashboard/MosaicDashboardVgPlotHeaderActions.d.ts +4 -0
  243. package/dist/dashboard/MosaicDashboardVgPlotHeaderActions.d.ts.map +1 -0
  244. package/dist/dashboard/MosaicDashboardVgPlotHeaderActions.js +29 -0
  245. package/dist/dashboard/MosaicDashboardVgPlotHeaderActions.js.map +1 -0
  246. package/dist/dashboard/MosaicDashboardVgPlotPanelRenderer.d.ts +3 -0
  247. package/dist/dashboard/MosaicDashboardVgPlotPanelRenderer.d.ts.map +1 -0
  248. package/dist/dashboard/MosaicDashboardVgPlotPanelRenderer.js +68 -0
  249. package/dist/dashboard/MosaicDashboardVgPlotPanelRenderer.js.map +1 -0
  250. package/dist/dashboard/VgPlotSpecPopoverEditor.d.ts +8 -0
  251. package/dist/dashboard/VgPlotSpecPopoverEditor.d.ts.map +1 -0
  252. package/dist/dashboard/VgPlotSpecPopoverEditor.js +40 -0
  253. package/dist/dashboard/VgPlotSpecPopoverEditor.js.map +1 -0
  254. package/dist/dashboard/chart-settings/ChartSettings.d.ts +39 -0
  255. package/dist/dashboard/chart-settings/ChartSettings.d.ts.map +1 -0
  256. package/dist/dashboard/chart-settings/ChartSettings.js +90 -0
  257. package/dist/dashboard/chart-settings/ChartSettings.js.map +1 -0
  258. package/dist/dashboard/chart-settings/ChartSettingsContext.d.ts +20 -0
  259. package/dist/dashboard/chart-settings/ChartSettingsContext.d.ts.map +1 -0
  260. package/dist/dashboard/chart-settings/ChartSettingsContext.js +14 -0
  261. package/dist/dashboard/chart-settings/ChartSettingsContext.js.map +1 -0
  262. package/dist/dashboard/chart-settings/ChartSettingsPanel.d.ts +11 -0
  263. package/dist/dashboard/chart-settings/ChartSettingsPanel.d.ts.map +1 -0
  264. package/dist/dashboard/chart-settings/ChartSettingsPanel.js +8 -0
  265. package/dist/dashboard/chart-settings/ChartSettingsPanel.js.map +1 -0
  266. package/dist/dashboard/chart-settings/ChartTypeSelector.d.ts +11 -0
  267. package/dist/dashboard/chart-settings/ChartTypeSelector.d.ts.map +1 -0
  268. package/dist/dashboard/chart-settings/ChartTypeSelector.js +17 -0
  269. package/dist/dashboard/chart-settings/ChartTypeSelector.js.map +1 -0
  270. package/dist/dashboard/chart-settings/DynamicChartSettings.d.ts +11 -0
  271. package/dist/dashboard/chart-settings/DynamicChartSettings.d.ts.map +1 -0
  272. package/dist/dashboard/chart-settings/DynamicChartSettings.js +19 -0
  273. package/dist/dashboard/chart-settings/DynamicChartSettings.js.map +1 -0
  274. package/dist/dashboard/chart-settings/index.d.ts +6 -0
  275. package/dist/dashboard/chart-settings/index.d.ts.map +1 -0
  276. package/dist/dashboard/chart-settings/index.js +6 -0
  277. package/dist/dashboard/chart-settings/index.js.map +1 -0
  278. package/dist/dashboard/chart-settings/useTableColumns.d.ts +3 -0
  279. package/dist/dashboard/chart-settings/useTableColumns.d.ts.map +1 -0
  280. package/dist/dashboard/chart-settings/useTableColumns.js +12 -0
  281. package/dist/dashboard/chart-settings/useTableColumns.js.map +1 -0
  282. package/dist/dashboard/defaultPanelRenderers.d.ts +3 -0
  283. package/dist/dashboard/defaultPanelRenderers.d.ts.map +1 -0
  284. package/dist/dashboard/defaultPanelRenderers.js +11 -0
  285. package/dist/dashboard/defaultPanelRenderers.js.map +1 -0
  286. package/dist/dashboard/generateMosaicChartSpec.d.ts +15 -0
  287. package/dist/dashboard/generateMosaicChartSpec.d.ts.map +1 -0
  288. package/dist/dashboard/generateMosaicChartSpec.js +30 -0
  289. package/dist/dashboard/generateMosaicChartSpec.js.map +1 -0
  290. package/dist/editor/MosaicChartContainer.d.ts +51 -0
  291. package/dist/editor/MosaicChartContainer.d.ts.map +1 -0
  292. package/dist/editor/MosaicChartContainer.js +39 -0
  293. package/dist/editor/MosaicChartContainer.js.map +1 -0
  294. package/dist/editor/MosaicChartDisplay.d.ts +18 -0
  295. package/dist/editor/MosaicChartDisplay.d.ts.map +1 -0
  296. package/dist/editor/MosaicChartDisplay.js +26 -0
  297. package/dist/editor/MosaicChartDisplay.js.map +1 -0
  298. package/dist/editor/MosaicChartEditorActions.d.ts +20 -0
  299. package/dist/editor/MosaicChartEditorActions.d.ts.map +1 -0
  300. package/dist/editor/MosaicChartEditorActions.js +18 -0
  301. package/dist/editor/MosaicChartEditorActions.js.map +1 -0
  302. package/dist/editor/MosaicCodeMirrorEditor.d.ts +15 -0
  303. package/dist/editor/MosaicCodeMirrorEditor.d.ts.map +1 -0
  304. package/dist/editor/MosaicCodeMirrorEditor.js +26 -0
  305. package/dist/editor/MosaicCodeMirrorEditor.js.map +1 -0
  306. package/dist/editor/MosaicEditorContext.d.ts +8 -0
  307. package/dist/editor/MosaicEditorContext.d.ts.map +1 -0
  308. package/dist/editor/MosaicEditorContext.js +14 -0
  309. package/dist/editor/MosaicEditorContext.js.map +1 -0
  310. package/dist/editor/MosaicSpecEditorPanel.d.ts +20 -0
  311. package/dist/editor/MosaicSpecEditorPanel.d.ts.map +1 -0
  312. package/dist/editor/MosaicSpecEditorPanel.js +25 -0
  313. package/dist/editor/MosaicSpecEditorPanel.js.map +1 -0
  314. package/dist/editor/mosaicSchema.d.ts +20 -0
  315. package/dist/editor/mosaicSchema.d.ts.map +1 -0
  316. package/dist/editor/mosaicSchema.js +57 -0
  317. package/dist/editor/mosaicSchema.js.map +1 -0
  318. package/dist/editor/types.d.ts +72 -0
  319. package/dist/editor/types.d.ts.map +1 -0
  320. package/dist/editor/types.js +2 -0
  321. package/dist/editor/types.js.map +1 -0
  322. package/dist/editor/useMosaicChartEditor.d.ts +9 -0
  323. package/dist/editor/useMosaicChartEditor.d.ts.map +1 -0
  324. package/dist/editor/useMosaicChartEditor.js +199 -0
  325. package/dist/editor/useMosaicChartEditor.js.map +1 -0
  326. package/dist/index.d.ts +53 -2
  327. package/dist/index.d.ts.map +1 -1
  328. package/dist/index.js +37 -1
  329. package/dist/index.js.map +1 -1
  330. package/dist/profiler/MosaicProfiler.d.ts +32 -0
  331. package/dist/profiler/MosaicProfiler.d.ts.map +1 -0
  332. package/dist/profiler/MosaicProfiler.js +57 -0
  333. package/dist/profiler/MosaicProfiler.js.map +1 -0
  334. package/dist/profiler/MosaicProfilerHeader.d.ts +7 -0
  335. package/dist/profiler/MosaicProfilerHeader.d.ts.map +1 -0
  336. package/dist/profiler/MosaicProfilerHeader.js +196 -0
  337. package/dist/profiler/MosaicProfilerHeader.js.map +1 -0
  338. package/dist/profiler/MosaicProfilerRows.d.ts +9 -0
  339. package/dist/profiler/MosaicProfilerRows.d.ts.map +1 -0
  340. package/dist/profiler/MosaicProfilerRows.js +65 -0
  341. package/dist/profiler/MosaicProfilerRows.js.map +1 -0
  342. package/dist/profiler/MosaicProfilerStatusBar.d.ts +9 -0
  343. package/dist/profiler/MosaicProfilerStatusBar.d.ts.map +1 -0
  344. package/dist/profiler/MosaicProfilerStatusBar.js +28 -0
  345. package/dist/profiler/MosaicProfilerStatusBar.js.map +1 -0
  346. package/dist/profiler/ProfilerCategoryClient.d.ts +50 -0
  347. package/dist/profiler/ProfilerCategoryClient.d.ts.map +1 -0
  348. package/dist/profiler/ProfilerCategoryClient.js +121 -0
  349. package/dist/profiler/ProfilerCategoryClient.js.map +1 -0
  350. package/dist/profiler/ProfilerCountClient.d.ts +28 -0
  351. package/dist/profiler/ProfilerCountClient.d.ts.map +1 -0
  352. package/dist/profiler/ProfilerCountClient.js +51 -0
  353. package/dist/profiler/ProfilerCountClient.js.map +1 -0
  354. package/dist/profiler/ProfilerHistogramClient.d.ts +69 -0
  355. package/dist/profiler/ProfilerHistogramClient.d.ts.map +1 -0
  356. package/dist/profiler/ProfilerHistogramClient.js +179 -0
  357. package/dist/profiler/ProfilerHistogramClient.js.map +1 -0
  358. package/dist/profiler/ProfilerPageClient.d.ts +37 -0
  359. package/dist/profiler/ProfilerPageClient.d.ts.map +1 -0
  360. package/dist/profiler/ProfilerPageClient.js +65 -0
  361. package/dist/profiler/ProfilerPageClient.js.map +1 -0
  362. package/dist/profiler/ProfilerUnsupportedSummaryClient.d.ts +24 -0
  363. package/dist/profiler/ProfilerUnsupportedSummaryClient.d.ts.map +1 -0
  364. package/dist/profiler/ProfilerUnsupportedSummaryClient.js +51 -0
  365. package/dist/profiler/ProfilerUnsupportedSummaryClient.js.map +1 -0
  366. package/dist/profiler/createProfilerStore.d.ts +45 -0
  367. package/dist/profiler/createProfilerStore.d.ts.map +1 -0
  368. package/dist/profiler/createProfilerStore.js +120 -0
  369. package/dist/profiler/createProfilerStore.js.map +1 -0
  370. package/dist/profiler/layout.d.ts +7 -0
  371. package/dist/profiler/layout.d.ts.map +1 -0
  372. package/dist/profiler/layout.js +13 -0
  373. package/dist/profiler/layout.js.map +1 -0
  374. package/dist/profiler/profilerController.d.ts +64 -0
  375. package/dist/profiler/profilerController.d.ts.map +1 -0
  376. package/dist/profiler/profilerController.js +123 -0
  377. package/dist/profiler/profilerController.js.map +1 -0
  378. package/dist/profiler/types.d.ts +86 -0
  379. package/dist/profiler/types.d.ts.map +1 -0
  380. package/dist/profiler/types.js +2 -0
  381. package/dist/profiler/types.js.map +1 -0
  382. package/dist/profiler/useMosaicProfiler.d.ts +7 -0
  383. package/dist/profiler/useMosaicProfiler.d.ts.map +1 -0
  384. package/dist/profiler/useMosaicProfiler.js +339 -0
  385. package/dist/profiler/useMosaicProfiler.js.map +1 -0
  386. package/dist/profiler/utils.d.ts +61 -0
  387. package/dist/profiler/utils.d.ts.map +1 -0
  388. package/dist/profiler/utils.js +347 -0
  389. package/dist/profiler/utils.js.map +1 -0
  390. package/dist/tableInterop.d.ts +30 -0
  391. package/dist/tableInterop.d.ts.map +1 -0
  392. package/dist/tableInterop.js +85 -0
  393. package/dist/tableInterop.js.map +1 -0
  394. package/dist/useMosaicClient.d.ts +5 -15
  395. package/dist/useMosaicClient.d.ts.map +1 -1
  396. package/dist/useMosaicClient.js +22 -6
  397. package/dist/useMosaicClient.js.map +1 -1
  398. package/package.json +30 -6
@@ -0,0 +1,615 @@
1
+ import { createId } from '@paralleldrive/cuid2';
2
+ import { DEFAULT_GRID_COLS, getGridColsForBreakpoint, } from '@sqlrooms/layout';
3
+ import { isLayoutGridNode, isLayoutNodeKey, isLayoutPanelNode, isLayoutSplitNode, LayoutNode as LayoutNodeSchema, } from '@sqlrooms/layout-config';
4
+ import { createSlice, useBaseRoomStore, } from '@sqlrooms/room-store';
5
+ import { produce } from 'immer';
6
+ import { z } from 'zod';
7
+ import { destroyRetainedVgPlotChart, } from '../VgPlotChart';
8
+ import { VgPlotChartConfig } from '../chart-types';
9
+ /**
10
+ * Panel key used for function-form panel definitions registered by
11
+ * `MosaicDashboardPanels`. Individual dashboard panels are represented as
12
+ * `LayoutPanelNode` entries whose `panel` property carries
13
+ * `{ key: MOSAIC_DASHBOARD_PANEL, meta: { dashboardId, panelId } }`.
14
+ */
15
+ export const MOSAIC_DASHBOARD_PANEL = 'mosaic-dashboard-panel';
16
+ export const MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE = 'vgplot';
17
+ export const MOSAIC_DASHBOARD_PROFILER_PANEL_TYPE = 'profiler';
18
+ export const MosaicDashboardLayoutType = z.enum(['dock', 'grid']);
19
+ export const MosaicDashboardPanelSource = z.object({
20
+ tableName: z.string().optional(),
21
+ sqlQuery: z.string().optional(),
22
+ });
23
+ // Profiler panel config
24
+ export const ProfilerPanelConfig = z.object({
25
+ pageSize: z.number().optional(),
26
+ });
27
+ // Panel configs discriminated by type
28
+ export const VgPlotPanelConfig = z.object({
29
+ id: z.string(),
30
+ type: z.literal(MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE),
31
+ title: z.string().default('Panel'),
32
+ source: MosaicDashboardPanelSource.optional(),
33
+ config: VgPlotChartConfig,
34
+ });
35
+ export const ProfilerPanel = z.object({
36
+ id: z.string(),
37
+ type: z.literal(MOSAIC_DASHBOARD_PROFILER_PANEL_TYPE),
38
+ title: z.string().default('Panel'),
39
+ source: MosaicDashboardPanelSource.optional(),
40
+ config: ProfilerPanelConfig,
41
+ });
42
+ // Legacy panel for backward compatibility
43
+ export const LegacyPanelConfig = z.object({
44
+ id: z.string(),
45
+ type: z.string(),
46
+ title: z.string().default('Panel'),
47
+ source: MosaicDashboardPanelSource.optional(),
48
+ config: z.record(z.string(), z.unknown()).default({}),
49
+ });
50
+ // Discriminated union of all panel types
51
+ export const MosaicDashboardPanelConfig = z
52
+ .discriminatedUnion('type', [VgPlotPanelConfig, ProfilerPanel])
53
+ .or(LegacyPanelConfig);
54
+ export function createMosaicDashboardVgPlotPanelConfig(title, config, source) {
55
+ return VgPlotPanelConfig.parse({
56
+ id: createId(),
57
+ type: MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE,
58
+ title,
59
+ source,
60
+ config,
61
+ });
62
+ }
63
+ export function createMosaicDashboardProfilerPanelConfig(options = {}) {
64
+ return {
65
+ id: createId(),
66
+ type: MOSAIC_DASHBOARD_PROFILER_PANEL_TYPE,
67
+ title: options.title ?? 'Profiler',
68
+ source: options.source,
69
+ config: {
70
+ pageSize: options.pageSize ?? 10,
71
+ },
72
+ };
73
+ }
74
+ export const MosaicDashboardEntry = z.object({
75
+ id: z.string(),
76
+ title: z.string().default('Dashboard'),
77
+ layoutType: MosaicDashboardLayoutType.default('dock'),
78
+ selectedTable: z.string().optional(),
79
+ panels: z.array(MosaicDashboardPanelConfig).default([]),
80
+ layout: LayoutNodeSchema.nullable().default(null),
81
+ updatedAt: z.number().default(0),
82
+ });
83
+ export const MosaicDashboardSliceConfig = z.object({
84
+ dashboardsById: z.record(z.string(), MosaicDashboardEntry).default({}),
85
+ });
86
+ // ---------------------------------------------------------------------------
87
+ // Layout tree helpers (operate on the new LayoutNode types)
88
+ // ---------------------------------------------------------------------------
89
+ function createDashboardPanelNode(dashboardId, panelId) {
90
+ return {
91
+ type: 'panel',
92
+ id: getMosaicDashboardPanelId(dashboardId, panelId),
93
+ minSize: 200,
94
+ panel: {
95
+ key: MOSAIC_DASHBOARD_PANEL,
96
+ meta: { dashboardId, panelId },
97
+ },
98
+ };
99
+ }
100
+ function getDashboardPanelTypesByLayoutId(dashboardId, panels) {
101
+ return Object.fromEntries(panels.map((panel) => [
102
+ getMosaicDashboardPanelId(dashboardId, panel.id),
103
+ panel.type,
104
+ ]));
105
+ }
106
+ function appendPanelToLayout(layout, panelNode) {
107
+ if (!layout) {
108
+ return panelNode;
109
+ }
110
+ return {
111
+ type: 'split',
112
+ id: `split-${createId()}`,
113
+ direction: 'row',
114
+ children: [layout, panelNode],
115
+ };
116
+ }
117
+ function createDashboardGridLayout(dashboardId, panelNode) {
118
+ const children = panelNode ? [panelNode] : [];
119
+ const layouts = createDashboardGridLayoutsForChildren(children);
120
+ return {
121
+ type: 'grid',
122
+ id: getMosaicDashboardGridId(dashboardId),
123
+ children,
124
+ rowHeight: 150,
125
+ margin: [12, 12],
126
+ containerPadding: [0, 0],
127
+ compactType: 'vertical',
128
+ preventCollision: false,
129
+ resizeHandles: ['e', 's', 'w', 'se', 'sw'],
130
+ layouts,
131
+ };
132
+ }
133
+ function getLayoutChildId(node) {
134
+ return isLayoutNodeKey(node) ? node : node.id;
135
+ }
136
+ function createDashboardGridItem(panelId, layout, cols = 12, panelType) {
137
+ const effectiveCols = Math.max(1, cols);
138
+ const w = panelType === MOSAIC_DASHBOARD_PROFILER_PANEL_TYPE
139
+ ? effectiveCols
140
+ : Math.max(1, Math.ceil(effectiveCols / 2));
141
+ const h = 2;
142
+ const bottom = layout.reduce((max, item) => Math.max(max, item.y + item.h), 0);
143
+ for (let y = 0; y <= bottom; y += 1) {
144
+ for (let x = 0; x <= effectiveCols - w; x += 1) {
145
+ const overlaps = layout.some((item) => x < item.x + item.w &&
146
+ x + w > item.x &&
147
+ y < item.y + item.h &&
148
+ y + h > item.y);
149
+ if (!overlaps) {
150
+ return {
151
+ i: panelId,
152
+ x,
153
+ y,
154
+ w,
155
+ h,
156
+ };
157
+ }
158
+ }
159
+ }
160
+ return {
161
+ i: panelId,
162
+ x: 0,
163
+ y: bottom,
164
+ w,
165
+ h,
166
+ };
167
+ }
168
+ function createDashboardGridLayoutsForChildren(children, sourceLayouts, cols, panelTypesByLayoutId = {}) {
169
+ const childIds = new Set(children.map((child) => getLayoutChildId(child)));
170
+ const sourceEntries = new Map(Object.keys(DEFAULT_GRID_COLS).map((breakpoint) => [breakpoint, []]));
171
+ for (const [breakpoint, breakpointLayout] of Object.entries(sourceLayouts ?? {})) {
172
+ sourceEntries.set(breakpoint, breakpointLayout);
173
+ }
174
+ return Object.fromEntries([...sourceEntries.entries()].map(([breakpoint, breakpointLayout]) => {
175
+ const nextLayout = breakpointLayout.filter((item) => childIds.has(item.i));
176
+ const layoutItemIds = new Set(nextLayout.map((item) => item.i));
177
+ for (const child of children) {
178
+ const childId = getLayoutChildId(child);
179
+ if (!layoutItemIds.has(childId)) {
180
+ const item = createDashboardGridItem(childId, nextLayout, getGridColsForBreakpoint(cols, breakpoint), panelTypesByLayoutId[childId]);
181
+ nextLayout.push(item);
182
+ layoutItemIds.add(childId);
183
+ }
184
+ }
185
+ return [breakpoint, nextLayout];
186
+ }));
187
+ }
188
+ function isExpectedDashboardPanelNode(node, expectedPanelIds) {
189
+ return expectedPanelIds.has(getLayoutChildId(node));
190
+ }
191
+ function collectDashboardPanelNodes(layout, expectedPanelIds, nodes = [], seen = new Set()) {
192
+ if (!layout)
193
+ return nodes;
194
+ if (isLayoutNodeKey(layout) || isLayoutPanelNode(layout)) {
195
+ if (isExpectedDashboardPanelNode(layout, expectedPanelIds)) {
196
+ const id = getLayoutChildId(layout);
197
+ if (!seen.has(id)) {
198
+ nodes.push(layout);
199
+ seen.add(id);
200
+ }
201
+ }
202
+ return nodes;
203
+ }
204
+ if (isLayoutSplitNode(layout) || isLayoutGridNode(layout)) {
205
+ for (const child of layout.children) {
206
+ collectDashboardPanelNodes(child, expectedPanelIds, nodes, seen);
207
+ }
208
+ }
209
+ return nodes;
210
+ }
211
+ function normalizeDashboardGridLayout(layout, dashboardId, expectedPanelIds, panelTypesByLayoutId = {}) {
212
+ const collectedPanelIds = collectPanelIds(layout);
213
+ const existingExpectedPanelIds = new Set([...expectedPanelIds].filter((panelId) => collectedPanelIds.has(panelId)));
214
+ const children = collectDashboardPanelNodes(layout, existingExpectedPanelIds);
215
+ const layouts = createDashboardGridLayoutsForChildren(children, isLayoutGridNode(layout) ? layout.layouts : undefined, isLayoutGridNode(layout) ? layout.cols : undefined, panelTypesByLayoutId);
216
+ if (isLayoutGridNode(layout)) {
217
+ return {
218
+ ...layout,
219
+ children,
220
+ layouts,
221
+ };
222
+ }
223
+ return {
224
+ ...createDashboardGridLayout(dashboardId),
225
+ children,
226
+ layouts,
227
+ };
228
+ }
229
+ function appendPanelToGridLayout(layout, dashboardId, panelNode, panelType, panelTypesByLayoutId = {}) {
230
+ const nextPanelTypesByLayoutId = {
231
+ ...panelTypesByLayoutId,
232
+ [panelNode.id]: panelType ?? panelTypesByLayoutId[panelNode.id],
233
+ };
234
+ if (!isLayoutGridNode(layout)) {
235
+ const dashboardPanelPrefix = `dashboard:${dashboardId}:panel:`;
236
+ const expectedPanelIds = new Set([...collectPanelIds(layout)].filter((panelId) => panelId.startsWith(dashboardPanelPrefix)));
237
+ expectedPanelIds.add(panelNode.id);
238
+ const normalizedLayout = normalizeDashboardGridLayout(layout, dashboardId, expectedPanelIds, nextPanelTypesByLayoutId);
239
+ return appendPanelToGridLayout(normalizedLayout, dashboardId, panelNode, panelType, nextPanelTypesByLayoutId);
240
+ }
241
+ const hasChild = layout.children.some((child) => {
242
+ if (isLayoutNodeKey(child))
243
+ return child === panelNode.id;
244
+ return child.id === panelNode.id;
245
+ });
246
+ const children = hasChild ? layout.children : [...layout.children, panelNode];
247
+ const layouts = Object.fromEntries(Object.entries(createDashboardGridLayoutsForChildren(children, layout.layouts, layout.cols, nextPanelTypesByLayoutId) ?? {}).map(([breakpoint, breakpointLayout]) => {
248
+ if (breakpointLayout.some((item) => item.i === panelNode.id)) {
249
+ return [breakpoint, breakpointLayout];
250
+ }
251
+ return [
252
+ breakpoint,
253
+ [
254
+ ...breakpointLayout,
255
+ createDashboardGridItem(panelNode.id, breakpointLayout, getGridColsForBreakpoint(layout.cols, breakpoint), nextPanelTypesByLayoutId[panelNode.id]),
256
+ ],
257
+ ];
258
+ }));
259
+ return {
260
+ ...layout,
261
+ children,
262
+ layouts,
263
+ };
264
+ }
265
+ function removePanelFromLayout(layout, panelId) {
266
+ if (!layout)
267
+ return null;
268
+ if (isLayoutNodeKey(layout)) {
269
+ return layout === panelId ? null : layout;
270
+ }
271
+ if (isLayoutPanelNode(layout)) {
272
+ return layout.id === panelId ? null : layout;
273
+ }
274
+ if (isLayoutSplitNode(layout)) {
275
+ const nextChildren = layout.children
276
+ .map((child) => removePanelFromLayout(child, panelId))
277
+ .filter((child) => child !== null);
278
+ if (nextChildren.length === 0)
279
+ return null;
280
+ if (nextChildren.length === 1)
281
+ return nextChildren[0] ?? null;
282
+ return { ...layout, children: nextChildren };
283
+ }
284
+ if (isLayoutGridNode(layout)) {
285
+ const nextChildren = layout.children.filter((child) => {
286
+ if (isLayoutNodeKey(child))
287
+ return child !== panelId;
288
+ return child.id !== panelId;
289
+ });
290
+ const nextLayouts = layout.layouts
291
+ ? Object.fromEntries(Object.entries(layout.layouts).map(([breakpoint, breakpointLayout]) => [
292
+ breakpoint,
293
+ breakpointLayout.filter((item) => item.i !== panelId),
294
+ ]))
295
+ : layout.layouts;
296
+ if (nextChildren.length === 0)
297
+ return null;
298
+ return { ...layout, children: nextChildren, layouts: nextLayouts };
299
+ }
300
+ return layout;
301
+ }
302
+ function collectPanelIds(layout, panelIds = new Set()) {
303
+ if (!layout)
304
+ return panelIds;
305
+ if (isLayoutNodeKey(layout)) {
306
+ panelIds.add(layout);
307
+ return panelIds;
308
+ }
309
+ if (isLayoutPanelNode(layout)) {
310
+ panelIds.add(layout.id);
311
+ return panelIds;
312
+ }
313
+ if (isLayoutSplitNode(layout)) {
314
+ for (const child of layout.children) {
315
+ collectPanelIds(child, panelIds);
316
+ }
317
+ }
318
+ if (isLayoutGridNode(layout)) {
319
+ for (const child of layout.children) {
320
+ collectPanelIds(child, panelIds);
321
+ }
322
+ }
323
+ return panelIds;
324
+ }
325
+ function ensureLayoutContainsDashboardPanels(layout, dashboardId, panelIds, layoutType = 'dock', panelTypesByLayoutId = {}) {
326
+ let nextLayout = layout;
327
+ if (layoutType === 'grid') {
328
+ const expectedPanelIds = new Set(panelIds.map((panelId) => getMosaicDashboardPanelId(dashboardId, panelId)));
329
+ nextLayout = normalizeDashboardGridLayout(nextLayout, dashboardId, expectedPanelIds, panelTypesByLayoutId);
330
+ }
331
+ const existing = collectPanelIds(nextLayout);
332
+ for (const panelId of panelIds) {
333
+ const layoutPanelId = getMosaicDashboardPanelId(dashboardId, panelId);
334
+ if (!existing.has(layoutPanelId)) {
335
+ const panelNode = createDashboardPanelNode(dashboardId, panelId);
336
+ nextLayout =
337
+ layoutType === 'grid'
338
+ ? appendPanelToGridLayout(nextLayout, dashboardId, panelNode, panelTypesByLayoutId[layoutPanelId], panelTypesByLayoutId)
339
+ : appendPanelToLayout(nextLayout, panelNode);
340
+ existing.add(layoutPanelId);
341
+ }
342
+ }
343
+ return nextLayout;
344
+ }
345
+ export function isVgPlotPanelConfig(panel) {
346
+ return panel.type === MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE;
347
+ }
348
+ export function getMosaicDashboardPanelId(dashboardId, panelId) {
349
+ return `dashboard:${dashboardId}:panel:${panelId}`;
350
+ }
351
+ export function getMosaicDashboardDockId(dashboardId) {
352
+ return `dashboard:${dashboardId}:dock`;
353
+ }
354
+ export function getMosaicDashboardGridId(dashboardId) {
355
+ return `dashboard:${dashboardId}:grid`;
356
+ }
357
+ export function getMosaicDashboardSelectionName(dashboardId) {
358
+ return `dashboard:${dashboardId}:brush`;
359
+ }
360
+ function destroyDashboardRuntimeChart(chart) {
361
+ if (!chart)
362
+ return;
363
+ destroyRetainedVgPlotChart(chart);
364
+ }
365
+ function evictDashboardSelection(state, dashboardId) {
366
+ state.mosaic.selections[getMosaicDashboardSelectionName(dashboardId)]?.reset();
367
+ }
368
+ function shouldEvictPanelRuntimeForPatch(panel, patch) {
369
+ if (patch.type && patch.type !== panel.type) {
370
+ return true;
371
+ }
372
+ if (panel.type === MOSAIC_DASHBOARD_VGPLOT_PANEL_TYPE) {
373
+ return Boolean(patch.config &&
374
+ Object.prototype.hasOwnProperty.call(patch.config, 'vgplot'));
375
+ }
376
+ return false;
377
+ }
378
+ export function resolveMosaicDashboardPanelSource(dashboard, panel) {
379
+ if (panel.source?.sqlQuery || panel.source?.tableName) {
380
+ return panel.source;
381
+ }
382
+ return dashboard.selectedTable
383
+ ? { tableName: dashboard.selectedTable }
384
+ : undefined;
385
+ }
386
+ export function createDefaultMosaicDashboardConfig(props) {
387
+ return MosaicDashboardSliceConfig.parse({
388
+ dashboardsById: {},
389
+ ...props,
390
+ });
391
+ }
392
+ export function createMosaicDashboardSlice(props = {}) {
393
+ return createSlice((set, get) => ({
394
+ mosaicDashboard: {
395
+ config: createDefaultMosaicDashboardConfig(props.config),
396
+ runtime: {
397
+ retainedChartsByPanelId: {},
398
+ },
399
+ chartBuilders: props.chartBuilders,
400
+ chartTypes: props.chartTypes,
401
+ addPanelActions: props.addPanelActions ?? [],
402
+ panelRenderers: props.panelRenderers ?? {},
403
+ createDashboard(title, layoutType) {
404
+ const dashboardId = createId();
405
+ get().mosaicDashboard.ensureDashboard(dashboardId, title, layoutType);
406
+ return dashboardId;
407
+ },
408
+ ensureDashboard(dashboardId, title, layoutType) {
409
+ set((state) => produce(state, (draft) => {
410
+ const existing = draft.mosaicDashboard.config.dashboardsById[dashboardId];
411
+ if (existing) {
412
+ if (title && existing.title !== title) {
413
+ existing.title = title;
414
+ existing.updatedAt = Date.now();
415
+ }
416
+ return;
417
+ }
418
+ draft.mosaicDashboard.config.dashboardsById[dashboardId] = {
419
+ id: dashboardId,
420
+ title: title ?? 'Dashboard',
421
+ layoutType: layoutType ?? 'dock',
422
+ selectedTable: undefined,
423
+ panels: [],
424
+ layout: layoutType === 'grid'
425
+ ? createDashboardGridLayout(dashboardId)
426
+ : null,
427
+ updatedAt: Date.now(),
428
+ };
429
+ }));
430
+ },
431
+ removeDashboard(dashboardId) {
432
+ get().mosaicDashboard.evictDashboardRuntime(dashboardId, {
433
+ resetSelection: true,
434
+ });
435
+ set((state) => produce(state, (draft) => {
436
+ delete draft.mosaicDashboard.config.dashboardsById[dashboardId];
437
+ }));
438
+ },
439
+ getDashboard(dashboardId) {
440
+ return get().mosaicDashboard.config.dashboardsById[dashboardId];
441
+ },
442
+ setConfig(config) {
443
+ set((state) => produce(state, (draft) => {
444
+ draft.mosaicDashboard.config = config;
445
+ }));
446
+ },
447
+ setSelectedTable(dashboardId, tableName) {
448
+ get().mosaicDashboard.ensureDashboard(dashboardId);
449
+ set((state) => produce(state, (draft) => {
450
+ const dashboard = draft.mosaicDashboard.config.dashboardsById[dashboardId];
451
+ if (!dashboard)
452
+ return;
453
+ dashboard.selectedTable = tableName;
454
+ dashboard.updatedAt = Date.now();
455
+ }));
456
+ },
457
+ registerPanelRenderer(type, renderer) {
458
+ set((state) => produce(state, (draft) => {
459
+ draft.mosaicDashboard.panelRenderers[type] = renderer;
460
+ }));
461
+ },
462
+ unregisterPanelRenderer(type) {
463
+ set((state) => produce(state, (draft) => {
464
+ delete draft.mosaicDashboard.panelRenderers[type];
465
+ }));
466
+ },
467
+ addPanel(dashboardId, panel) {
468
+ get().mosaicDashboard.ensureDashboard(dashboardId);
469
+ set((state) => produce(state, (draft) => {
470
+ const dashboard = draft.mosaicDashboard.config.dashboardsById[dashboardId];
471
+ if (!dashboard)
472
+ return;
473
+ dashboard.panels.push(panel);
474
+ const panelNode = createDashboardPanelNode(dashboardId, panel.id);
475
+ const panelTypesByLayoutId = getDashboardPanelTypesByLayoutId(dashboardId, dashboard.panels);
476
+ dashboard.layout =
477
+ dashboard.layoutType === 'grid'
478
+ ? appendPanelToGridLayout(dashboard.layout, dashboardId, panelNode, panel.type, panelTypesByLayoutId)
479
+ : appendPanelToLayout(dashboard.layout, panelNode);
480
+ dashboard.updatedAt = Date.now();
481
+ }));
482
+ return panel.id;
483
+ },
484
+ updatePanel(dashboardId, panelId, patch) {
485
+ const existing = get().mosaicDashboard.config.dashboardsById[dashboardId]?.panels.find((candidate) => candidate.id === panelId);
486
+ const shouldEvict = existing
487
+ ? shouldEvictPanelRuntimeForPatch(existing, patch)
488
+ : false;
489
+ set((state) => produce(state, (draft) => {
490
+ const dashboard = draft.mosaicDashboard.config.dashboardsById[dashboardId];
491
+ if (!dashboard)
492
+ return;
493
+ const panel = dashboard.panels.find((candidate) => candidate.id === panelId);
494
+ if (!panel)
495
+ return;
496
+ Object.assign(panel, patch);
497
+ dashboard.updatedAt = Date.now();
498
+ }));
499
+ if (shouldEvict) {
500
+ get().mosaicDashboard.evictPanelRuntime(dashboardId, panelId);
501
+ }
502
+ },
503
+ removePanel(dashboardId, panelId) {
504
+ get().mosaicDashboard.evictPanelRuntime(dashboardId, panelId);
505
+ set((state) => produce(state, (draft) => {
506
+ const dashboard = draft.mosaicDashboard.config.dashboardsById[dashboardId];
507
+ if (!dashboard)
508
+ return;
509
+ dashboard.panels = dashboard.panels.filter((panel) => panel.id !== panelId);
510
+ dashboard.layout = removePanelFromLayout(dashboard.layout, getMosaicDashboardPanelId(dashboardId, panelId));
511
+ dashboard.updatedAt = Date.now();
512
+ }));
513
+ },
514
+ getRetainedChart(dashboardId, panelId) {
515
+ return get().mosaicDashboard.runtime.retainedChartsByPanelId[getMosaicDashboardPanelId(dashboardId, panelId)];
516
+ },
517
+ setRetainedChart(dashboardId, panelId, chart) {
518
+ const runtimePanelId = getMosaicDashboardPanelId(dashboardId, panelId);
519
+ const previous = get().mosaicDashboard.runtime.retainedChartsByPanelId[runtimePanelId];
520
+ if (previous && previous !== chart) {
521
+ destroyDashboardRuntimeChart(previous);
522
+ }
523
+ set((state) => ({
524
+ mosaicDashboard: {
525
+ ...state.mosaicDashboard,
526
+ runtime: {
527
+ ...state.mosaicDashboard.runtime,
528
+ retainedChartsByPanelId: {
529
+ ...state.mosaicDashboard.runtime.retainedChartsByPanelId,
530
+ [runtimePanelId]: chart,
531
+ },
532
+ },
533
+ },
534
+ }));
535
+ },
536
+ evictPanelRuntime(dashboardId, panelId) {
537
+ const runtimePanelId = getMosaicDashboardPanelId(dashboardId, panelId);
538
+ const existing = get().mosaicDashboard.runtime.retainedChartsByPanelId[runtimePanelId];
539
+ destroyDashboardRuntimeChart(existing);
540
+ set((state) => {
541
+ const nextRetainedChartsByPanelId = {
542
+ ...state.mosaicDashboard.runtime.retainedChartsByPanelId,
543
+ };
544
+ delete nextRetainedChartsByPanelId[runtimePanelId];
545
+ return {
546
+ mosaicDashboard: {
547
+ ...state.mosaicDashboard,
548
+ runtime: {
549
+ ...state.mosaicDashboard.runtime,
550
+ retainedChartsByPanelId: nextRetainedChartsByPanelId,
551
+ },
552
+ },
553
+ };
554
+ });
555
+ },
556
+ evictDashboardRuntime(dashboardId, options) {
557
+ const runtimePrefix = `dashboard:${dashboardId}:panel:`;
558
+ const existingEntries = Object.entries(get().mosaicDashboard.runtime.retainedChartsByPanelId).filter(([runtimePanelId]) => runtimePanelId.startsWith(runtimePrefix));
559
+ existingEntries.forEach(([, chart]) => {
560
+ destroyDashboardRuntimeChart(chart);
561
+ });
562
+ if (options?.resetSelection) {
563
+ evictDashboardSelection(get(), dashboardId);
564
+ }
565
+ set((state) => {
566
+ const nextRetainedChartsByPanelId = {
567
+ ...state.mosaicDashboard.runtime.retainedChartsByPanelId,
568
+ };
569
+ for (const [runtimePanelId] of existingEntries) {
570
+ delete nextRetainedChartsByPanelId[runtimePanelId];
571
+ }
572
+ return {
573
+ mosaicDashboard: {
574
+ ...state.mosaicDashboard,
575
+ runtime: {
576
+ ...state.mosaicDashboard.runtime,
577
+ retainedChartsByPanelId: nextRetainedChartsByPanelId,
578
+ },
579
+ },
580
+ };
581
+ });
582
+ },
583
+ clearAllDashboardRuntime() {
584
+ Object.values(get().mosaicDashboard.runtime.retainedChartsByPanelId).forEach((chart) => {
585
+ destroyDashboardRuntimeChart(chart);
586
+ });
587
+ set((state) => ({
588
+ mosaicDashboard: {
589
+ ...state.mosaicDashboard,
590
+ runtime: {
591
+ ...state.mosaicDashboard.runtime,
592
+ retainedChartsByPanelId: {},
593
+ },
594
+ },
595
+ }));
596
+ },
597
+ setLayout(dashboardId, layout) {
598
+ get().mosaicDashboard.ensureDashboard(dashboardId);
599
+ set((state) => produce(state, (draft) => {
600
+ const dashboard = draft.mosaicDashboard.config.dashboardsById[dashboardId];
601
+ if (!dashboard)
602
+ return;
603
+ const panelIds = dashboard.panels.map((panel) => panel.id);
604
+ const panelTypesByLayoutId = getDashboardPanelTypesByLayoutId(dashboardId, dashboard.panels);
605
+ dashboard.layout = ensureLayoutContainsDashboardPanels(layout, dashboardId, panelIds, dashboard.layoutType, panelTypesByLayoutId);
606
+ dashboard.updatedAt = Date.now();
607
+ }));
608
+ },
609
+ },
610
+ }));
611
+ }
612
+ export function useStoreWithMosaicDashboard(selector) {
613
+ return useBaseRoomStore((state) => selector(state));
614
+ }
615
+ //# sourceMappingURL=MosaicDashboardSlice.js.map