@sqlrooms/mosaic 0.29.0-rc.7 → 0.29.0-rc.9

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 (572) hide show
  1. package/LICENSE.md +2 -1
  2. package/README.md +179 -35
  3. package/dist/MosaicSlice.d.ts +1 -0
  4. package/dist/MosaicSlice.d.ts.map +1 -1
  5. package/dist/MosaicSlice.js.map +1 -1
  6. package/dist/VgPlotChart.d.ts.map +1 -1
  7. package/dist/VgPlotChart.js +9 -3
  8. package/dist/VgPlotChart.js.map +1 -1
  9. package/dist/ai/agentIntent.d.ts +5 -0
  10. package/dist/ai/agentIntent.d.ts.map +1 -0
  11. package/dist/ai/agentIntent.js +8 -0
  12. package/dist/ai/agentIntent.js.map +1 -0
  13. package/dist/ai/block-document/constants.d.ts +9 -0
  14. package/dist/ai/block-document/constants.d.ts.map +1 -0
  15. package/dist/ai/block-document/constants.js +9 -0
  16. package/dist/ai/block-document/constants.js.map +1 -0
  17. package/dist/ai/block-document/createAddMosaicDashboardBlockTool.d.ts +48 -0
  18. package/dist/ai/block-document/createAddMosaicDashboardBlockTool.d.ts.map +1 -0
  19. package/dist/ai/block-document/createAddMosaicDashboardBlockTool.js +59 -0
  20. package/dist/ai/block-document/createAddMosaicDashboardBlockTool.js.map +1 -0
  21. package/dist/ai/block-document/createBlockDocumentChartTools.d.ts +19 -0
  22. package/dist/ai/block-document/createBlockDocumentChartTools.d.ts.map +1 -0
  23. package/dist/ai/block-document/createBlockDocumentChartTools.js +37 -0
  24. package/dist/ai/block-document/createBlockDocumentChartTools.js.map +1 -0
  25. package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.d.ts +32 -0
  26. package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.d.ts.map +1 -0
  27. package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.js +37 -0
  28. package/dist/ai/block-document/createBlockDocumentDataTableExplorerTool.js.map +1 -0
  29. package/dist/ai/constants.d.ts +3 -0
  30. package/dist/ai/constants.d.ts.map +1 -0
  31. package/dist/ai/constants.js +3 -0
  32. package/dist/ai/constants.js.map +1 -0
  33. package/dist/ai/createDataTableExplorerTool.d.ts +69 -0
  34. package/dist/ai/createDataTableExplorerTool.d.ts.map +1 -0
  35. package/dist/ai/createDataTableExplorerTool.js +68 -0
  36. package/dist/ai/createDataTableExplorerTool.js.map +1 -0
  37. package/dist/ai/dashboard/constants.d.ts +6 -0
  38. package/dist/ai/dashboard/constants.d.ts.map +1 -0
  39. package/dist/ai/dashboard/constants.js +6 -0
  40. package/dist/ai/dashboard/constants.js.map +1 -0
  41. package/dist/ai/dashboard/createDashboardAgentTool.d.ts +17 -0
  42. package/dist/ai/dashboard/createDashboardAgentTool.d.ts.map +1 -0
  43. package/dist/ai/dashboard/createDashboardAgentTool.js +205 -0
  44. package/dist/ai/dashboard/createDashboardAgentTool.js.map +1 -0
  45. package/dist/ai/dashboard/createDashboardAiAdapter.d.ts +14 -0
  46. package/dist/ai/dashboard/createDashboardAiAdapter.d.ts.map +1 -0
  47. package/dist/ai/dashboard/createDashboardAiAdapter.js +75 -0
  48. package/dist/ai/dashboard/createDashboardAiAdapter.js.map +1 -0
  49. package/dist/ai/dashboard/createDashboardAiTools.d.ts +26 -0
  50. package/dist/ai/dashboard/createDashboardAiTools.d.ts.map +1 -0
  51. package/dist/ai/dashboard/createDashboardAiTools.js +40 -0
  52. package/dist/ai/dashboard/createDashboardAiTools.js.map +1 -0
  53. package/dist/ai/dashboard/createDashboardChartTools.d.ts +27 -0
  54. package/dist/ai/dashboard/createDashboardChartTools.d.ts.map +1 -0
  55. package/dist/ai/dashboard/createDashboardChartTools.js +55 -0
  56. package/dist/ai/dashboard/createDashboardChartTools.js.map +1 -0
  57. package/dist/ai/dashboard/createDashboardDataTableExplorerTool.d.ts +23 -0
  58. package/dist/ai/dashboard/createDashboardDataTableExplorerTool.d.ts.map +1 -0
  59. package/dist/ai/dashboard/createDashboardDataTableExplorerTool.js +29 -0
  60. package/dist/ai/dashboard/createDashboardDataTableExplorerTool.js.map +1 -0
  61. package/dist/ai/dashboard/createListDashboardPanelsTool.d.ts +28 -0
  62. package/dist/ai/dashboard/createListDashboardPanelsTool.d.ts.map +1 -0
  63. package/dist/ai/dashboard/createListDashboardPanelsTool.js +54 -0
  64. package/dist/ai/dashboard/createListDashboardPanelsTool.js.map +1 -0
  65. package/dist/ai/dashboard/dashboard-types.d.ts +59 -0
  66. package/dist/ai/dashboard/dashboard-types.d.ts.map +1 -0
  67. package/dist/ai/dashboard/dashboard-types.js +2 -0
  68. package/dist/ai/dashboard/dashboard-types.js.map +1 -0
  69. package/dist/ai/database-types.d.ts +12 -0
  70. package/dist/ai/database-types.d.ts.map +1 -0
  71. package/dist/ai/database-types.js +2 -0
  72. package/dist/ai/database-types.js.map +1 -0
  73. package/dist/ai/errors.d.ts +8 -0
  74. package/dist/ai/errors.d.ts.map +1 -0
  75. package/dist/ai/errors.js +11 -0
  76. package/dist/ai/errors.js.map +1 -0
  77. package/dist/ai/tool-helpers.d.ts +28 -29
  78. package/dist/ai/tool-helpers.d.ts.map +1 -1
  79. package/dist/ai/tool-helpers.js +38 -76
  80. package/dist/ai/tool-helpers.js.map +1 -1
  81. package/dist/ai/tool-schemas.d.ts +9 -4
  82. package/dist/ai/tool-schemas.d.ts.map +1 -1
  83. package/dist/ai/tool-schemas.js +12 -12
  84. package/dist/ai/tool-schemas.js.map +1 -1
  85. package/dist/ai/tool-types.d.ts +19 -1
  86. package/dist/ai/tool-types.d.ts.map +1 -1
  87. package/dist/ai/tool-types.js.map +1 -1
  88. package/dist/ai/types.d.ts +64 -0
  89. package/dist/ai/types.d.ts.map +1 -0
  90. package/dist/ai/types.js +2 -0
  91. package/dist/ai/types.js.map +1 -0
  92. package/dist/ai.d.ts +16 -2
  93. package/dist/ai.d.ts.map +1 -1
  94. package/dist/ai.js +14 -5
  95. package/dist/ai.js.map +1 -1
  96. package/dist/charts/MosaicChart.d.ts +3 -1
  97. package/dist/charts/MosaicChart.d.ts.map +1 -1
  98. package/dist/charts/MosaicChart.js +2 -2
  99. package/dist/charts/MosaicChart.js.map +1 -1
  100. package/dist/charts/MosaicChartError.d.ts +8 -2
  101. package/dist/charts/MosaicChartError.d.ts.map +1 -1
  102. package/dist/charts/MosaicChartError.js +29 -3
  103. package/dist/charts/MosaicChartError.js.map +1 -1
  104. package/dist/charts/MosaicChartSettingsButton.d.ts +15 -0
  105. package/dist/charts/MosaicChartSettingsButton.d.ts.map +1 -0
  106. package/dist/charts/MosaicChartSettingsButton.js +7 -0
  107. package/dist/charts/MosaicChartSettingsButton.js.map +1 -0
  108. package/dist/charts/MosaicChartView.d.ts +2 -0
  109. package/dist/charts/MosaicChartView.d.ts.map +1 -1
  110. package/dist/charts/MosaicChartView.js +19 -7
  111. package/dist/charts/MosaicChartView.js.map +1 -1
  112. package/dist/charts/chart-settings/MosaicChartSettings.d.ts.map +1 -1
  113. package/dist/charts/chart-settings/MosaicChartSettings.js +3 -3
  114. package/dist/charts/chart-settings/MosaicChartSettings.js.map +1 -1
  115. package/dist/charts/chart-settings/MosaicChartSettingsPanel.js +1 -1
  116. package/dist/charts/chart-settings/MosaicChartSettingsPanel.js.map +1 -1
  117. package/dist/charts/chart-settings/MosaicChartSpecViewerPanel.d.ts.map +1 -1
  118. package/dist/charts/chart-settings/MosaicChartSpecViewerPanel.js +2 -1
  119. package/dist/charts/chart-settings/MosaicChartSpecViewerPanel.js.map +1 -1
  120. package/dist/charts/chart-settings/MosaicChartTypeSelector.d.ts.map +1 -1
  121. package/dist/charts/chart-settings/MosaicChartTypeSelector.js +3 -3
  122. package/dist/charts/chart-settings/MosaicChartTypeSelector.js.map +1 -1
  123. package/dist/charts/chart-types/base-types.d.ts +40 -25
  124. package/dist/charts/chart-types/base-types.d.ts.map +1 -1
  125. package/dist/charts/chart-types/base-types.js +5 -0
  126. package/dist/charts/chart-types/base-types.js.map +1 -1
  127. package/dist/charts/chart-types/box-plot/definition.d.ts.map +1 -1
  128. package/dist/charts/chart-types/box-plot/definition.js +1 -0
  129. package/dist/charts/chart-types/box-plot/definition.js.map +1 -1
  130. package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.d.ts +37 -3
  131. package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.d.ts.map +1 -1
  132. package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.js +28 -13
  133. package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.js.map +1 -1
  134. package/dist/charts/chart-types/box-plot/renderer/BoxPlotPanelRenderer.js +2 -2
  135. package/dist/charts/chart-types/box-plot/renderer/BoxPlotPanelRenderer.js.map +1 -1
  136. package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.d.ts +12 -1
  137. package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.d.ts.map +1 -1
  138. package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.js +13 -3
  139. package/dist/charts/chart-types/box-plot/renderer/useBoxPlotClient.js.map +1 -1
  140. package/dist/charts/chart-types/box-plot/tool.d.ts +20 -24
  141. package/dist/charts/chart-types/box-plot/tool.d.ts.map +1 -1
  142. package/dist/charts/chart-types/box-plot/tool.js +25 -33
  143. package/dist/charts/chart-types/box-plot/tool.js.map +1 -1
  144. package/dist/charts/chart-types/box-plot/validation.d.ts +9 -0
  145. package/dist/charts/chart-types/box-plot/validation.d.ts.map +1 -0
  146. package/dist/charts/chart-types/box-plot/validation.js +32 -0
  147. package/dist/charts/chart-types/box-plot/validation.js.map +1 -0
  148. package/dist/charts/chart-types/chart-config.d.ts +3 -1
  149. package/dist/charts/chart-types/chart-config.d.ts.map +1 -1
  150. package/dist/charts/chart-types/chart-config.js +2 -2
  151. package/dist/charts/chart-types/chart-config.js.map +1 -1
  152. package/dist/charts/chart-types/column-types.d.ts +8 -0
  153. package/dist/charts/chart-types/column-types.d.ts.map +1 -0
  154. package/dist/charts/chart-types/column-types.js +2 -0
  155. package/dist/charts/chart-types/column-types.js.map +1 -0
  156. package/dist/charts/chart-types/count-plot/definition.d.ts.map +1 -1
  157. package/dist/charts/chart-types/count-plot/definition.js +1 -0
  158. package/dist/charts/chart-types/count-plot/definition.js.map +1 -1
  159. package/dist/charts/chart-types/count-plot/spec.d.ts +2 -1
  160. package/dist/charts/chart-types/count-plot/spec.d.ts.map +1 -1
  161. package/dist/charts/chart-types/count-plot/spec.js +47 -34
  162. package/dist/charts/chart-types/count-plot/spec.js.map +1 -1
  163. package/dist/charts/chart-types/count-plot/tool.d.ts +19 -24
  164. package/dist/charts/chart-types/count-plot/tool.d.ts.map +1 -1
  165. package/dist/charts/chart-types/count-plot/tool.js +26 -33
  166. package/dist/charts/chart-types/count-plot/tool.js.map +1 -1
  167. package/dist/charts/chart-types/count-plot/validation.d.ts +8 -0
  168. package/dist/charts/chart-types/count-plot/validation.d.ts.map +1 -0
  169. package/dist/charts/chart-types/count-plot/validation.js +20 -0
  170. package/dist/charts/chart-types/count-plot/validation.js.map +1 -0
  171. package/dist/charts/chart-types/createChartInstructions.d.ts +3 -0
  172. package/dist/charts/chart-types/createChartInstructions.d.ts.map +1 -0
  173. package/dist/charts/chart-types/createChartInstructions.js +12 -0
  174. package/dist/charts/chart-types/createChartInstructions.js.map +1 -0
  175. package/dist/charts/chart-types/createChartTools.d.ts +15 -9
  176. package/dist/charts/chart-types/createChartTools.d.ts.map +1 -1
  177. package/dist/charts/chart-types/createChartTools.js +16 -10
  178. package/dist/charts/chart-types/createChartTools.js.map +1 -1
  179. package/dist/charts/chart-types/createDefaultChartTypes.js +2 -2
  180. package/dist/charts/chart-types/createDefaultChartTypes.js.map +1 -1
  181. package/dist/charts/chart-types/custom-spec/definition.d.ts.map +1 -1
  182. package/dist/charts/chart-types/custom-spec/definition.js +1 -0
  183. package/dist/charts/chart-types/custom-spec/definition.js.map +1 -1
  184. package/dist/charts/chart-types/custom-spec/spec.d.ts +2 -1
  185. package/dist/charts/chart-types/custom-spec/spec.d.ts.map +1 -1
  186. package/dist/charts/chart-types/custom-spec/spec.js +16 -12
  187. package/dist/charts/chart-types/custom-spec/spec.js.map +1 -1
  188. package/dist/charts/chart-types/errors.d.ts +35 -0
  189. package/dist/charts/chart-types/errors.d.ts.map +1 -1
  190. package/dist/charts/chart-types/errors.js +56 -0
  191. package/dist/charts/chart-types/errors.js.map +1 -1
  192. package/dist/charts/chart-types/heatmap/definition.d.ts.map +1 -1
  193. package/dist/charts/chart-types/heatmap/definition.js +1 -0
  194. package/dist/charts/chart-types/heatmap/definition.js.map +1 -1
  195. package/dist/charts/chart-types/heatmap/spec.d.ts +2 -1
  196. package/dist/charts/chart-types/heatmap/spec.d.ts.map +1 -1
  197. package/dist/charts/chart-types/heatmap/spec.js +21 -21
  198. package/dist/charts/chart-types/heatmap/spec.js.map +1 -1
  199. package/dist/charts/chart-types/heatmap/tool.d.ts +20 -24
  200. package/dist/charts/chart-types/heatmap/tool.d.ts.map +1 -1
  201. package/dist/charts/chart-types/heatmap/tool.js +27 -37
  202. package/dist/charts/chart-types/heatmap/tool.js.map +1 -1
  203. package/dist/charts/chart-types/heatmap/validation.d.ts +9 -0
  204. package/dist/charts/chart-types/heatmap/validation.d.ts.map +1 -0
  205. package/dist/charts/chart-types/heatmap/validation.js +34 -0
  206. package/dist/charts/chart-types/heatmap/validation.js.map +1 -0
  207. package/dist/charts/chart-types/histogram/HistogramSettings.d.ts.map +1 -1
  208. package/dist/charts/chart-types/histogram/HistogramSettings.js +3 -1
  209. package/dist/charts/chart-types/histogram/HistogramSettings.js.map +1 -1
  210. package/dist/charts/chart-types/histogram/definition.d.ts.map +1 -1
  211. package/dist/charts/chart-types/histogram/definition.js +1 -0
  212. package/dist/charts/chart-types/histogram/definition.js.map +1 -1
  213. package/dist/charts/chart-types/histogram/schema.d.ts +2 -0
  214. package/dist/charts/chart-types/histogram/schema.d.ts.map +1 -1
  215. package/dist/charts/chart-types/histogram/schema.js +1 -0
  216. package/dist/charts/chart-types/histogram/schema.js.map +1 -1
  217. package/dist/charts/chart-types/histogram/spec.d.ts +2 -1
  218. package/dist/charts/chart-types/histogram/spec.d.ts.map +1 -1
  219. package/dist/charts/chart-types/histogram/spec.js +31 -28
  220. package/dist/charts/chart-types/histogram/spec.js.map +1 -1
  221. package/dist/charts/chart-types/histogram/tool.d.ts +39 -24
  222. package/dist/charts/chart-types/histogram/tool.d.ts.map +1 -1
  223. package/dist/charts/chart-types/histogram/tool.js +39 -33
  224. package/dist/charts/chart-types/histogram/tool.js.map +1 -1
  225. package/dist/charts/chart-types/histogram/validation.d.ts +9 -0
  226. package/dist/charts/chart-types/histogram/validation.d.ts.map +1 -0
  227. package/dist/charts/chart-types/histogram/validation.js +22 -0
  228. package/dist/charts/chart-types/histogram/validation.js.map +1 -0
  229. package/dist/charts/chart-types/index.d.ts +5 -11
  230. package/dist/charts/chart-types/index.d.ts.map +1 -1
  231. package/dist/charts/chart-types/index.js +6 -12
  232. package/dist/charts/chart-types/index.js.map +1 -1
  233. package/dist/charts/chart-types/line-chart/LineChartSettings.d.ts.map +1 -1
  234. package/dist/charts/chart-types/line-chart/LineChartSettings.js +4 -13
  235. package/dist/charts/chart-types/line-chart/LineChartSettings.js.map +1 -1
  236. package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.d.ts +7 -0
  237. package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.d.ts.map +1 -0
  238. package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.js +22 -0
  239. package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.js.map +1 -0
  240. package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.d.ts +7 -0
  241. package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.d.ts.map +1 -0
  242. package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.js +42 -0
  243. package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.js.map +1 -0
  244. package/dist/charts/chart-types/line-chart/definition.d.ts.map +1 -1
  245. package/dist/charts/chart-types/line-chart/definition.js +1 -0
  246. package/dist/charts/chart-types/line-chart/definition.js.map +1 -1
  247. package/dist/charts/chart-types/line-chart/schema.d.ts +2 -0
  248. package/dist/charts/chart-types/line-chart/schema.d.ts.map +1 -1
  249. package/dist/charts/chart-types/line-chart/schema.js +5 -0
  250. package/dist/charts/chart-types/line-chart/schema.js.map +1 -1
  251. package/dist/charts/chart-types/line-chart/spec.d.ts +2 -1
  252. package/dist/charts/chart-types/line-chart/spec.d.ts.map +1 -1
  253. package/dist/charts/chart-types/line-chart/spec.js +56 -65
  254. package/dist/charts/chart-types/line-chart/spec.js.map +1 -1
  255. package/dist/charts/chart-types/line-chart/tool.d.ts +28 -24
  256. package/dist/charts/chart-types/line-chart/tool.d.ts.map +1 -1
  257. package/dist/charts/chart-types/line-chart/tool.js +27 -39
  258. package/dist/charts/chart-types/line-chart/tool.js.map +1 -1
  259. package/dist/charts/chart-types/line-chart/utils.d.ts +7 -0
  260. package/dist/charts/chart-types/line-chart/utils.d.ts.map +1 -0
  261. package/dist/charts/chart-types/line-chart/utils.js +17 -0
  262. package/dist/charts/chart-types/line-chart/utils.js.map +1 -0
  263. package/dist/charts/chart-types/line-chart/validation.d.ts +16 -0
  264. package/dist/charts/chart-types/line-chart/validation.d.ts.map +1 -0
  265. package/dist/charts/chart-types/line-chart/validation.js +43 -0
  266. package/dist/charts/chart-types/line-chart/validation.js.map +1 -0
  267. package/dist/charts/chart-types/mosaicChartTypes.d.ts +4 -2
  268. package/dist/charts/chart-types/mosaicChartTypes.d.ts.map +1 -1
  269. package/dist/charts/chart-types/mosaicChartTypes.js +2 -2
  270. package/dist/charts/chart-types/mosaicChartTypes.js.map +1 -1
  271. package/dist/charts/chart-types/resolveChartTypes.d.ts +3 -0
  272. package/dist/charts/chart-types/resolveChartTypes.d.ts.map +1 -0
  273. package/dist/charts/chart-types/resolveChartTypes.js +8 -0
  274. package/dist/charts/chart-types/resolveChartTypes.js.map +1 -0
  275. package/dist/charts/chart-types/scatter-plot/ScatterPlotSettings.d.ts +3 -0
  276. package/dist/charts/chart-types/scatter-plot/ScatterPlotSettings.d.ts.map +1 -0
  277. package/dist/charts/chart-types/{bubble-chart/BubbleChartSettings.js → scatter-plot/ScatterPlotSettings.js} +4 -4
  278. package/dist/charts/chart-types/scatter-plot/ScatterPlotSettings.js.map +1 -0
  279. package/dist/charts/chart-types/scatter-plot/definition.d.ts +4 -0
  280. package/dist/charts/chart-types/scatter-plot/definition.d.ts.map +1 -0
  281. package/dist/charts/chart-types/scatter-plot/definition.js +25 -0
  282. package/dist/charts/chart-types/scatter-plot/definition.js.map +1 -0
  283. package/dist/charts/chart-types/{bubble-chart → scatter-plot}/schema.d.ts +5 -5
  284. package/dist/charts/chart-types/scatter-plot/schema.d.ts.map +1 -0
  285. package/dist/charts/chart-types/{bubble-chart → scatter-plot}/schema.js +5 -5
  286. package/dist/charts/chart-types/scatter-plot/schema.js.map +1 -0
  287. package/dist/charts/chart-types/scatter-plot/spec.d.ts +5 -0
  288. package/dist/charts/chart-types/scatter-plot/spec.d.ts.map +1 -0
  289. package/dist/charts/chart-types/scatter-plot/spec.js +37 -0
  290. package/dist/charts/chart-types/scatter-plot/spec.js.map +1 -0
  291. package/dist/charts/chart-types/scatter-plot/tool.d.ts +39 -0
  292. package/dist/charts/chart-types/scatter-plot/tool.d.ts.map +1 -0
  293. package/dist/charts/chart-types/scatter-plot/tool.js +57 -0
  294. package/dist/charts/chart-types/scatter-plot/tool.js.map +1 -0
  295. package/dist/charts/chart-types/scatter-plot/validation.d.ts +13 -0
  296. package/dist/charts/chart-types/scatter-plot/validation.d.ts.map +1 -0
  297. package/dist/charts/chart-types/scatter-plot/validation.js +52 -0
  298. package/dist/charts/chart-types/scatter-plot/validation.js.map +1 -0
  299. package/dist/charts/chart-types/tool-types.d.ts +43 -0
  300. package/dist/charts/chart-types/tool-types.d.ts.map +1 -0
  301. package/dist/charts/chart-types/tool-types.js +2 -0
  302. package/dist/charts/chart-types/tool-types.js.map +1 -0
  303. package/dist/charts/chart-types/utils.d.ts +3 -0
  304. package/dist/charts/chart-types/utils.d.ts.map +1 -0
  305. package/dist/charts/chart-types/utils.js +4 -0
  306. package/dist/charts/chart-types/utils.js.map +1 -0
  307. package/dist/charts/dashboard/MosaicDashboardChartHeaderActions.d.ts.map +1 -1
  308. package/dist/charts/dashboard/MosaicDashboardChartHeaderActions.js +12 -5
  309. package/dist/charts/dashboard/MosaicDashboardChartHeaderActions.js.map +1 -1
  310. package/dist/charts/dashboard/MosaicDashboardChartRenderer.d.ts.map +1 -1
  311. package/dist/charts/dashboard/MosaicDashboardChartRenderer.js +6 -4
  312. package/dist/charts/dashboard/MosaicDashboardChartRenderer.js.map +1 -1
  313. package/dist/charts/useChartDataPolicy.d.ts.map +1 -1
  314. package/dist/charts/useChartDataPolicy.js +2 -1
  315. package/dist/charts/useChartDataPolicy.js.map +1 -1
  316. package/dist/charts/useChartPanelClients.d.ts +8 -0
  317. package/dist/charts/useChartPanelClients.d.ts.map +1 -0
  318. package/dist/charts/useChartPanelClients.js +22 -0
  319. package/dist/charts/useChartPanelClients.js.map +1 -0
  320. package/dist/charts/useMosaicChartRenderContext.d.ts +2 -3
  321. package/dist/charts/useMosaicChartRenderContext.d.ts.map +1 -1
  322. package/dist/charts/useMosaicChartRenderContext.js +15 -15
  323. package/dist/charts/useMosaicChartRenderContext.js.map +1 -1
  324. package/dist/charts/worksheet/ChartBlockHeader.d.ts.map +1 -1
  325. package/dist/charts/worksheet/ChartBlockHeader.js +4 -3
  326. package/dist/charts/worksheet/ChartBlockHeader.js.map +1 -1
  327. package/dist/charts/worksheet/ChartBlockRenderer.d.ts.map +1 -1
  328. package/dist/charts/worksheet/ChartBlockRenderer.js +3 -13
  329. package/dist/charts/worksheet/ChartBlockRenderer.js.map +1 -1
  330. package/dist/column-types-utils.d.ts.map +1 -1
  331. package/dist/column-types-utils.js +12 -4
  332. package/dist/column-types-utils.js.map +1 -1
  333. package/dist/components/AggregationSelector.d.ts.map +1 -1
  334. package/dist/components/AggregationSelector.js +9 -2
  335. package/dist/components/AggregationSelector.js.map +1 -1
  336. package/dist/components/BlockCaptionEditor.d.ts +20 -0
  337. package/dist/components/BlockCaptionEditor.d.ts.map +1 -0
  338. package/dist/components/BlockCaptionEditor.js +15 -0
  339. package/dist/components/BlockCaptionEditor.js.map +1 -0
  340. package/dist/components/ColorSelector.d.ts +12 -0
  341. package/dist/components/ColorSelector.d.ts.map +1 -0
  342. package/dist/components/ColorSelector.js +13 -0
  343. package/dist/components/ColorSelector.js.map +1 -0
  344. package/dist/components/ColumnSelector.d.ts +1 -0
  345. package/dist/components/ColumnSelector.d.ts.map +1 -1
  346. package/dist/components/ColumnSelector.js +2 -2
  347. package/dist/components/ColumnSelector.js.map +1 -1
  348. package/dist/components/FieldSelectorInput.d.ts +1 -0
  349. package/dist/components/FieldSelectorInput.d.ts.map +1 -1
  350. package/dist/components/FieldSelectorInput.js +4 -9
  351. package/dist/components/FieldSelectorInput.js.map +1 -1
  352. package/dist/components/MultiFieldSelector.d.ts +4 -1
  353. package/dist/components/MultiFieldSelector.d.ts.map +1 -1
  354. package/dist/components/MultiFieldSelector.js +4 -13
  355. package/dist/components/MultiFieldSelector.js.map +1 -1
  356. package/dist/components/TemporalGranularitySelector.d.ts.map +1 -1
  357. package/dist/components/TemporalGranularitySelector.js +13 -9
  358. package/dist/components/TemporalGranularitySelector.js.map +1 -1
  359. package/dist/constants/chart-colors.d.ts +3 -0
  360. package/dist/constants/chart-colors.d.ts.map +1 -0
  361. package/dist/constants/chart-colors.js +5 -0
  362. package/dist/constants/chart-colors.js.map +1 -0
  363. package/dist/dashboard/DefaultMosaicDashboardBlock.d.ts +2 -1
  364. package/dist/dashboard/DefaultMosaicDashboardBlock.d.ts.map +1 -1
  365. package/dist/dashboard/DefaultMosaicDashboardBlock.js +1 -1
  366. package/dist/dashboard/DefaultMosaicDashboardBlock.js.map +1 -1
  367. package/dist/dashboard/MosaicDashboardCommands.d.ts +19 -0
  368. package/dist/dashboard/MosaicDashboardCommands.d.ts.map +1 -0
  369. package/dist/dashboard/MosaicDashboardCommands.js +226 -0
  370. package/dist/dashboard/MosaicDashboardCommands.js.map +1 -0
  371. package/dist/dashboard/MosaicDashboardSlice.d.ts +22 -4
  372. package/dist/dashboard/MosaicDashboardSlice.d.ts.map +1 -1
  373. package/dist/dashboard/MosaicDashboardSlice.js +55 -0
  374. package/dist/dashboard/MosaicDashboardSlice.js.map +1 -1
  375. package/dist/dashboard/components/ResetFiltersButton.d.ts +14 -0
  376. package/dist/dashboard/components/ResetFiltersButton.d.ts.map +1 -0
  377. package/dist/dashboard/components/ResetFiltersButton.js +15 -0
  378. package/dist/dashboard/components/ResetFiltersButton.js.map +1 -0
  379. package/dist/dashboard/dashboard-types.d.ts +9 -3
  380. package/dist/dashboard/dashboard-types.d.ts.map +1 -1
  381. package/dist/dashboard/dashboard-types.js.map +1 -1
  382. package/dist/dashboard/hooks/useDashboardResetFilters.d.ts +14 -0
  383. package/dist/dashboard/hooks/useDashboardResetFilters.d.ts.map +1 -0
  384. package/dist/dashboard/hooks/useDashboardResetFilters.js +39 -0
  385. package/dist/dashboard/hooks/useDashboardResetFilters.js.map +1 -0
  386. package/dist/dashboard/hooks/usePanelResetFilters.d.ts +16 -0
  387. package/dist/dashboard/hooks/usePanelResetFilters.d.ts.map +1 -0
  388. package/dist/dashboard/hooks/usePanelResetFilters.js +47 -0
  389. package/dist/dashboard/hooks/usePanelResetFilters.js.map +1 -0
  390. package/dist/dashboard/panel/MosaicDashboardPanel.d.ts.map +1 -1
  391. package/dist/dashboard/panel/MosaicDashboardPanel.js +1 -1
  392. package/dist/dashboard/panel/MosaicDashboardPanel.js.map +1 -1
  393. package/dist/dashboard/panel/MosaicDashboardPanelLayout.d.ts.map +1 -1
  394. package/dist/dashboard/panel/MosaicDashboardPanelLayout.js +3 -3
  395. package/dist/dashboard/panel/MosaicDashboardPanelLayout.js.map +1 -1
  396. package/dist/dashboard/panel/MosaicDashboardPanels.d.ts.map +1 -1
  397. package/dist/dashboard/panel/MosaicDashboardPanels.js +4 -2
  398. package/dist/dashboard/panel/MosaicDashboardPanels.js.map +1 -1
  399. package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.d.ts.map +1 -1
  400. package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.js +3 -3
  401. package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.js.map +1 -1
  402. package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.d.ts +7 -0
  403. package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.d.ts.map +1 -0
  404. package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.js +18 -0
  405. package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.js.map +1 -0
  406. package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.d.ts.map +1 -1
  407. package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.js +4 -32
  408. package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.js.map +1 -1
  409. package/dist/dashboard/toolbar/MosaicDashboardToolbar.d.ts +2 -2
  410. package/dist/dashboard/toolbar/MosaicDashboardToolbar.d.ts.map +1 -1
  411. package/dist/dashboard/toolbar/MosaicDashboardToolbar.js +14 -10
  412. package/dist/dashboard/toolbar/MosaicDashboardToolbar.js.map +1 -1
  413. package/dist/dashboard/usePanelClientRegistration.d.ts +7 -0
  414. package/dist/dashboard/usePanelClientRegistration.d.ts.map +1 -0
  415. package/dist/dashboard/usePanelClientRegistration.js +30 -0
  416. package/dist/dashboard/usePanelClientRegistration.js.map +1 -0
  417. package/dist/dashboard/usePanelClients.d.ts +7 -0
  418. package/dist/dashboard/usePanelClients.d.ts.map +1 -0
  419. package/dist/dashboard/usePanelClients.js +13 -0
  420. package/dist/dashboard/usePanelClients.js.map +1 -0
  421. package/dist/dashboard/useSelectedOrFirstTable.d.ts +1 -1
  422. package/dist/dashboard/useSelectedOrFirstTable.d.ts.map +1 -1
  423. package/dist/dashboard/useSelectedOrFirstTable.js +10 -8
  424. package/dist/dashboard/useSelectedOrFirstTable.js.map +1 -1
  425. package/dist/data-table-explorer/DataTableExplorer.d.ts +4 -2
  426. package/dist/data-table-explorer/DataTableExplorer.d.ts.map +1 -1
  427. package/dist/data-table-explorer/DataTableExplorer.js +4 -4
  428. package/dist/data-table-explorer/DataTableExplorer.js.map +1 -1
  429. package/dist/data-table-explorer/DataTableExplorerCategoryClient.d.ts +3 -2
  430. package/dist/data-table-explorer/DataTableExplorerCategoryClient.d.ts.map +1 -1
  431. package/dist/data-table-explorer/DataTableExplorerCategoryClient.js +4 -3
  432. package/dist/data-table-explorer/DataTableExplorerCategoryClient.js.map +1 -1
  433. package/dist/data-table-explorer/DataTableExplorerCountClient.d.ts +3 -1
  434. package/dist/data-table-explorer/DataTableExplorerCountClient.d.ts.map +1 -1
  435. package/dist/data-table-explorer/DataTableExplorerCountClient.js +3 -3
  436. package/dist/data-table-explorer/DataTableExplorerCountClient.js.map +1 -1
  437. package/dist/data-table-explorer/DataTableExplorerHistogramClient.d.ts +3 -2
  438. package/dist/data-table-explorer/DataTableExplorerHistogramClient.d.ts.map +1 -1
  439. package/dist/data-table-explorer/DataTableExplorerHistogramClient.js +4 -4
  440. package/dist/data-table-explorer/DataTableExplorerHistogramClient.js.map +1 -1
  441. package/dist/data-table-explorer/DataTableExplorerPageClient.d.ts +3 -1
  442. package/dist/data-table-explorer/DataTableExplorerPageClient.d.ts.map +1 -1
  443. package/dist/data-table-explorer/DataTableExplorerPageClient.js +3 -1
  444. package/dist/data-table-explorer/DataTableExplorerPageClient.js.map +1 -1
  445. package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.d.ts +3 -2
  446. package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.d.ts.map +1 -1
  447. package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.js +3 -3
  448. package/dist/data-table-explorer/DataTableExplorerUnsupportedSummaryClient.js.map +1 -1
  449. package/dist/data-table-explorer/createDataTableExplorerStore.d.ts +3 -0
  450. package/dist/data-table-explorer/createDataTableExplorerStore.d.ts.map +1 -1
  451. package/dist/data-table-explorer/createDataTableExplorerStore.js +6 -0
  452. package/dist/data-table-explorer/createDataTableExplorerStore.js.map +1 -1
  453. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.d.ts +4 -0
  454. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.d.ts.map +1 -0
  455. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.js +13 -0
  456. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.js.map +1 -0
  457. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.d.ts.map +1 -1
  458. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.js +26 -8
  459. package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.js.map +1 -1
  460. package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.d.ts +13 -0
  461. package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.d.ts.map +1 -0
  462. package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.js +32 -0
  463. package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.js.map +1 -0
  464. package/dist/data-table-explorer/dataTableExplorerController.d.ts +63 -3
  465. package/dist/data-table-explorer/dataTableExplorerController.d.ts.map +1 -1
  466. package/dist/data-table-explorer/dataTableExplorerController.js +73 -10
  467. package/dist/data-table-explorer/dataTableExplorerController.js.map +1 -1
  468. package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.d.ts +12 -0
  469. package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.d.ts.map +1 -0
  470. package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.js +19 -0
  471. package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.js.map +1 -0
  472. package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.d.ts +52 -0
  473. package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.d.ts.map +1 -0
  474. package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.js +153 -0
  475. package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.js.map +1 -0
  476. package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.d.ts +42 -0
  477. package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.d.ts.map +1 -0
  478. package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.js +43 -0
  479. package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.js.map +1 -0
  480. package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.d.ts +13 -0
  481. package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.d.ts.map +1 -0
  482. package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.js +40 -0
  483. package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.js.map +1 -0
  484. package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.d.ts +18 -0
  485. package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.d.ts.map +1 -0
  486. package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.js +23 -0
  487. package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.js.map +1 -0
  488. package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.d.ts +27 -0
  489. package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.d.ts.map +1 -0
  490. package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.js +28 -0
  491. package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.js.map +1 -0
  492. package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.d.ts +15 -0
  493. package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.d.ts.map +1 -0
  494. package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.js +21 -0
  495. package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.js.map +1 -0
  496. package/dist/data-table-explorer/types.d.ts +16 -3
  497. package/dist/data-table-explorer/types.d.ts.map +1 -1
  498. package/dist/data-table-explorer/types.js.map +1 -1
  499. package/dist/data-table-explorer/useDataTableExplorer.d.ts.map +1 -1
  500. package/dist/data-table-explorer/useDataTableExplorer.js +20 -279
  501. package/dist/data-table-explorer/useDataTableExplorer.js.map +1 -1
  502. package/dist/data-table-explorer/utils.d.ts +64 -6
  503. package/dist/data-table-explorer/utils.d.ts.map +1 -1
  504. package/dist/data-table-explorer/utils.js +58 -0
  505. package/dist/data-table-explorer/utils.js.map +1 -1
  506. package/dist/data-table-explorer/worksheet/DataTableBlockHeader.d.ts +1 -0
  507. package/dist/data-table-explorer/worksheet/DataTableBlockHeader.d.ts.map +1 -1
  508. package/dist/data-table-explorer/worksheet/DataTableBlockHeader.js +4 -2
  509. package/dist/data-table-explorer/worksheet/DataTableBlockHeader.js.map +1 -1
  510. package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.d.ts.map +1 -1
  511. package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.js +4 -4
  512. package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.js.map +1 -1
  513. package/dist/index.d.ts +55 -31
  514. package/dist/index.d.ts.map +1 -1
  515. package/dist/index.js +86 -26
  516. package/dist/index.js.map +1 -1
  517. package/dist/mosaicTableReference.d.ts +59 -0
  518. package/dist/mosaicTableReference.d.ts.map +1 -0
  519. package/dist/mosaicTableReference.js +68 -0
  520. package/dist/mosaicTableReference.js.map +1 -0
  521. package/dist/useVgPlotChartRender.d.ts.map +1 -1
  522. package/dist/useVgPlotChartRender.js +151 -25
  523. package/dist/useVgPlotChartRender.js.map +1 -1
  524. package/dist/useVgPlotChartRetention.d.ts +11 -0
  525. package/dist/useVgPlotChartRetention.d.ts.map +1 -1
  526. package/dist/useVgPlotChartRetention.js.map +1 -1
  527. package/dist/utils/table-lookup.d.ts +7 -0
  528. package/dist/utils/table-lookup.d.ts.map +1 -0
  529. package/dist/utils/table-lookup.js +10 -0
  530. package/dist/utils/table-lookup.js.map +1 -0
  531. package/package.json +14 -14
  532. package/dist/ai/ai.d.ts +0 -103
  533. package/dist/ai/ai.d.ts.map +0 -1
  534. package/dist/ai/ai.js +0 -419
  535. package/dist/ai/ai.js.map +0 -1
  536. package/dist/ai/data-table-explorer-tool.d.ts +0 -40
  537. package/dist/ai/data-table-explorer-tool.d.ts.map +0 -1
  538. package/dist/ai/data-table-explorer-tool.js +0 -75
  539. package/dist/ai/data-table-explorer-tool.js.map +0 -1
  540. package/dist/ai/list-panels-tool.d.ts +0 -35
  541. package/dist/ai/list-panels-tool.d.ts.map +0 -1
  542. package/dist/ai/list-panels-tool.js +0 -66
  543. package/dist/ai/list-panels-tool.js.map +0 -1
  544. package/dist/ai/remove-panel-tool.d.ts +0 -31
  545. package/dist/ai/remove-panel-tool.d.ts.map +0 -1
  546. package/dist/ai/remove-panel-tool.js +0 -55
  547. package/dist/ai/remove-panel-tool.js.map +0 -1
  548. package/dist/ai/tool-validation.d.ts +0 -3
  549. package/dist/ai/tool-validation.d.ts.map +0 -1
  550. package/dist/ai/tool-validation.js +0 -11
  551. package/dist/ai/tool-validation.js.map +0 -1
  552. package/dist/charts/chart-types/bubble-chart/BubbleChartSettings.d.ts +0 -3
  553. package/dist/charts/chart-types/bubble-chart/BubbleChartSettings.d.ts.map +0 -1
  554. package/dist/charts/chart-types/bubble-chart/BubbleChartSettings.js.map +0 -1
  555. package/dist/charts/chart-types/bubble-chart/definition.d.ts +0 -4
  556. package/dist/charts/chart-types/bubble-chart/definition.d.ts.map +0 -1
  557. package/dist/charts/chart-types/bubble-chart/definition.js +0 -24
  558. package/dist/charts/chart-types/bubble-chart/definition.js.map +0 -1
  559. package/dist/charts/chart-types/bubble-chart/schema.d.ts.map +0 -1
  560. package/dist/charts/chart-types/bubble-chart/schema.js.map +0 -1
  561. package/dist/charts/chart-types/bubble-chart/spec.d.ts +0 -4
  562. package/dist/charts/chart-types/bubble-chart/spec.d.ts.map +0 -1
  563. package/dist/charts/chart-types/bubble-chart/spec.js +0 -31
  564. package/dist/charts/chart-types/bubble-chart/spec.js.map +0 -1
  565. package/dist/charts/chart-types/bubble-chart/tool.d.ts +0 -42
  566. package/dist/charts/chart-types/bubble-chart/tool.d.ts.map +0 -1
  567. package/dist/charts/chart-types/bubble-chart/tool.js +0 -66
  568. package/dist/charts/chart-types/bubble-chart/tool.js.map +0 -1
  569. package/dist/hooks/useDataTable.d.ts +0 -3
  570. package/dist/hooks/useDataTable.d.ts.map +0 -1
  571. package/dist/hooks/useDataTable.js +0 -28
  572. package/dist/hooks/useDataTable.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ import { useState } from 'react';
2
+ import { useStore } from 'zustand';
3
+ import { createDataTableExplorerStore, } from '../createDataTableExplorerStore';
4
+ /**
5
+ * Creates the per-dataTableExplorer local store and subscribes to the raw state slices
6
+ * that the public dataTableExplorer hook exposes.
7
+ */
8
+ export function useDataTableExplorerStoreState(options) {
9
+ const [dataTableExplorerStore] = useState(() => createDataTableExplorerStore({
10
+ initialSorting: options.initialSorting,
11
+ pageSize: options.pageSize,
12
+ }));
13
+ return {
14
+ client: useStore(dataTableExplorerStore, (state) => state.client),
15
+ filteredCount: useStore(dataTableExplorerStore, (state) => state.filteredCount),
16
+ lastNonEmptyPageTable: useStore(dataTableExplorerStore, (state) => state.lastNonEmptyPageTable),
17
+ page: useStore(dataTableExplorerStore, (state) => state.page),
18
+ pagination: useStore(dataTableExplorerStore, (state) => state.pagination),
19
+ dataTableExplorerStore,
20
+ schema: useStore(dataTableExplorerStore, (state) => state.schema),
21
+ setPagination: useStore(dataTableExplorerStore, (state) => state.setPagination),
22
+ setSorting: useStore(dataTableExplorerStore, (state) => state.setSorting),
23
+ sorting: useStore(dataTableExplorerStore, (state) => state.sorting),
24
+ summaries: useStore(dataTableExplorerStore, (state) => state.summaries),
25
+ totalCount: useStore(dataTableExplorerStore, (state) => state.totalCount),
26
+ };
27
+ }
28
+ //# sourceMappingURL=useDataTableExplorerStoreState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableExplorerStoreState.js","sourceRoot":"","sources":["../../../src/data-table-explorer/hooks/useDataTableExplorerStoreState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EACL,4BAA4B,GAE7B,MAAM,iCAAiC,CAAC;AAwBzC;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAA8C;IAE9C,MAAM,CAAC,sBAAsB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAC7C,4BAA4B,CAAC;QAC3B,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CACH,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;QACjE,aAAa,EAAE,QAAQ,CACrB,sBAAsB,EACtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAC/B;QACD,qBAAqB,EAAE,QAAQ,CAC7B,sBAAsB,EACtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,qBAAqB,CACvC;QACD,IAAI,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QAC7D,UAAU,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;QACzE,sBAAsB;QACtB,MAAM,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;QACjE,aAAa,EAAE,QAAQ,CACrB,sBAAsB,EACtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAC/B;QACD,UAAU,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;QACzE,OAAO,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;QACnE,SAAS,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;QACvE,UAAU,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;KAC1E,CAAC;AACJ,CAAC","sourcesContent":["import {useState} from 'react';\nimport {useStore} from 'zustand';\nimport {\n createDataTableExplorerStore,\n type DataTableExplorerStore,\n} from '../createDataTableExplorerStore';\nimport type {DataTableExplorerSorting} from '../types';\nimport type {DataTableExplorerStoreState} from '../createDataTableExplorerStore';\n\nexport type UseDataTableExplorerStoreStateOptions = {\n initialSorting: DataTableExplorerSorting;\n pageSize: number;\n};\n\nexport type UseDataTableExplorerStoreStateReturn = {\n client: DataTableExplorerStoreState['client'];\n filteredCount: DataTableExplorerStoreState['filteredCount'];\n lastNonEmptyPageTable: DataTableExplorerStoreState['lastNonEmptyPageTable'];\n page: DataTableExplorerStoreState['page'];\n pagination: DataTableExplorerStoreState['pagination'];\n dataTableExplorerStore: DataTableExplorerStore;\n schema: DataTableExplorerStoreState['schema'];\n setPagination: DataTableExplorerStoreState['setPagination'];\n setSorting: DataTableExplorerStoreState['setSorting'];\n sorting: DataTableExplorerStoreState['sorting'];\n summaries: DataTableExplorerStoreState['summaries'];\n totalCount: DataTableExplorerStoreState['totalCount'];\n};\n\n/**\n * Creates the per-dataTableExplorer local store and subscribes to the raw state slices\n * that the public dataTableExplorer hook exposes.\n */\nexport function useDataTableExplorerStoreState(\n options: UseDataTableExplorerStoreStateOptions,\n): UseDataTableExplorerStoreStateReturn {\n const [dataTableExplorerStore] = useState(() =>\n createDataTableExplorerStore({\n initialSorting: options.initialSorting,\n pageSize: options.pageSize,\n }),\n );\n\n return {\n client: useStore(dataTableExplorerStore, (state) => state.client),\n filteredCount: useStore(\n dataTableExplorerStore,\n (state) => state.filteredCount,\n ),\n lastNonEmptyPageTable: useStore(\n dataTableExplorerStore,\n (state) => state.lastNonEmptyPageTable,\n ),\n page: useStore(dataTableExplorerStore, (state) => state.page),\n pagination: useStore(dataTableExplorerStore, (state) => state.pagination),\n dataTableExplorerStore,\n schema: useStore(dataTableExplorerStore, (state) => state.schema),\n setPagination: useStore(\n dataTableExplorerStore,\n (state) => state.setPagination,\n ),\n setSorting: useStore(dataTableExplorerStore, (state) => state.setSorting),\n sorting: useStore(dataTableExplorerStore, (state) => state.sorting),\n summaries: useStore(dataTableExplorerStore, (state) => state.summaries),\n totalCount: useStore(dataTableExplorerStore, (state) => state.totalCount),\n };\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { Table } from 'apache-arrow';
2
+ import type { DataTableExplorerStoreState } from '../createDataTableExplorerStore';
3
+ export type UseDataTableExplorerVisiblePageOptions = {
4
+ lastNonEmptyPageTable: DataTableExplorerStoreState['lastNonEmptyPageTable'];
5
+ pageDatasetId: string;
6
+ page: DataTableExplorerStoreState['page'];
7
+ rowSelectionVersion: number;
8
+ selectionVersion: number;
9
+ };
10
+ /**
11
+ * Keeps the last non-empty page result visible while live brushing has moved
12
+ * ahead of the deferred row query, avoiding transient "No rows" flashes.
13
+ */
14
+ export declare function useDataTableExplorerVisiblePage(options: UseDataTableExplorerVisiblePageOptions): Table | undefined;
15
+ //# sourceMappingURL=useDataTableExplorerVisiblePage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableExplorerVisiblePage.d.ts","sourceRoot":"","sources":["../../../src/data-table-explorer/hooks/useDataTableExplorerVisiblePage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,iCAAiC,CAAC;AAEjF,MAAM,MAAM,sCAAsC,GAAG;IACnD,qBAAqB,EAAE,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;IAC5E,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;IAC1C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,sCAAsC,GAC9C,KAAK,GAAG,SAAS,CAwBnB"}
@@ -0,0 +1,21 @@
1
+ import { useDebounce } from '@sqlrooms/ui';
2
+ /**
3
+ * Keeps the last non-empty page result visible while live brushing has moved
4
+ * ahead of the deferred row query, avoiding transient "No rows" flashes.
5
+ */
6
+ export function useDataTableExplorerVisiblePage(options) {
7
+ const { lastNonEmptyPageTable, page, pageDatasetId, rowSelectionVersion, selectionVersion, } = options;
8
+ const isRowDisplayStale = selectionVersion !== rowSelectionVersion;
9
+ const hasCurrentRows = !!page.pageTable && page.pageTable.numRows > 0;
10
+ const canReuseLastNonEmptyPage = !!lastNonEmptyPageTable &&
11
+ lastNonEmptyPageTable.datasetId === pageDatasetId;
12
+ const canShowStableEmpty = !page.isLoading &&
13
+ !isRowDisplayStale &&
14
+ (!page.pageTable || page.pageTable.numRows === 0);
15
+ const showStableEmpty = useDebounce(canShowStableEmpty, 120);
16
+ if (hasCurrentRows || !canReuseLastNonEmptyPage) {
17
+ return page.pageTable;
18
+ }
19
+ return showStableEmpty ? page.pageTable : lastNonEmptyPageTable.pageTable;
20
+ }
21
+ //# sourceMappingURL=useDataTableExplorerVisiblePage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableExplorerVisiblePage.js","sourceRoot":"","sources":["../../../src/data-table-explorer/hooks/useDataTableExplorerVisiblePage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAYzC;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAC7C,OAA+C;IAE/C,MAAM,EACJ,qBAAqB,EACrB,IAAI,EACJ,aAAa,EACb,mBAAmB,EACnB,gBAAgB,GACjB,GAAG,OAAO,CAAC;IACZ,MAAM,iBAAiB,GAAG,gBAAgB,KAAK,mBAAmB,CAAC;IACnE,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC;IACtE,MAAM,wBAAwB,GAC5B,CAAC,CAAC,qBAAqB;QACvB,qBAAqB,CAAC,SAAS,KAAK,aAAa,CAAC;IACpD,MAAM,kBAAkB,GACtB,CAAC,IAAI,CAAC,SAAS;QACf,CAAC,iBAAiB;QAClB,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC;IACpD,MAAM,eAAe,GAAG,WAAW,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IAE7D,IAAI,cAAc,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,SAAS,CAAC;AAC5E,CAAC","sourcesContent":["import {useDebounce} from '@sqlrooms/ui';\nimport type {Table} from 'apache-arrow';\nimport type {DataTableExplorerStoreState} from '../createDataTableExplorerStore';\n\nexport type UseDataTableExplorerVisiblePageOptions = {\n lastNonEmptyPageTable: DataTableExplorerStoreState['lastNonEmptyPageTable'];\n pageDatasetId: string;\n page: DataTableExplorerStoreState['page'];\n rowSelectionVersion: number;\n selectionVersion: number;\n};\n\n/**\n * Keeps the last non-empty page result visible while live brushing has moved\n * ahead of the deferred row query, avoiding transient \"No rows\" flashes.\n */\nexport function useDataTableExplorerVisiblePage(\n options: UseDataTableExplorerVisiblePageOptions,\n): Table | undefined {\n const {\n lastNonEmptyPageTable,\n page,\n pageDatasetId,\n rowSelectionVersion,\n selectionVersion,\n } = options;\n const isRowDisplayStale = selectionVersion !== rowSelectionVersion;\n const hasCurrentRows = !!page.pageTable && page.pageTable.numRows > 0;\n const canReuseLastNonEmptyPage =\n !!lastNonEmptyPageTable &&\n lastNonEmptyPageTable.datasetId === pageDatasetId;\n const canShowStableEmpty =\n !page.isLoading &&\n !isRowDisplayStale &&\n (!page.pageTable || page.pageTable.numRows === 0);\n const showStableEmpty = useDebounce(canShowStableEmpty, 120);\n\n if (hasCurrentRows || !canReuseLastNonEmptyPage) {\n return page.pageTable;\n }\n\n return showStableEmpty ? page.pageTable : lastNonEmptyPageTable.pageTable;\n}\n"]}
@@ -1,5 +1,6 @@
1
- import { DataTable } from '@sqlrooms/db';
2
- import type { Selection } from '@uwdata/mosaic-core';
1
+ import type { QualifiedTableName } from '@sqlrooms/db';
2
+ import type { MosaicClient, Selection } from '@uwdata/mosaic-core';
3
+ import type { TableRefNode } from '@uwdata/mosaic-sql';
3
4
  import type { Interval1D } from '@uwdata/mosaic-plot';
4
5
  import type { Field, Table } from 'apache-arrow';
5
6
  import type { Dispatch, SetStateAction } from 'react';
@@ -41,6 +42,7 @@ export type DataTableExplorerCategoryBucket = {
41
42
  export type DataTableExplorerCategorySummary = DataTableExplorerSummaryStatus & {
42
43
  bucketCount: number;
43
44
  buckets: DataTableExplorerCategoryBucket[];
45
+ client?: MosaicClient;
44
46
  kind: 'category';
45
47
  selectedKey?: string;
46
48
  toggleValue: (key: string) => void;
@@ -57,6 +59,16 @@ export type DataTableExplorerColumnState = {
57
59
  name: string;
58
60
  summary: DataTableExplorerSummaryState;
59
61
  };
62
+ export type DataTableExplorerTableReference = string | QualifiedTableName;
63
+ /**
64
+ * Table reference accepted by dataTableExplorer query builders.
65
+ *
66
+ * Use a string for simple unqualified table names or for call sites that already
67
+ * require a string SQL boundary. Use a TableRefNode for qualified names,
68
+ * especially when schema or table identifier parts may contain dots or quotes,
69
+ * so Mosaic does not reparse those parts from a flattened string.
70
+ */
71
+ export type DataTableExplorerSqlTableReference = string | TableRefNode;
60
72
  export type DataTableExplorerOptions = {
61
73
  categoryLimit?: number;
62
74
  columns?: string[];
@@ -65,9 +77,10 @@ export type DataTableExplorerOptions = {
65
77
  selection?: Selection;
66
78
  selectionName?: string;
67
79
  summaryBins?: number;
68
- tableName: DataTable;
80
+ tableName: DataTableExplorerTableReference;
69
81
  };
70
82
  export type UseDataTableExplorerReturn = {
83
+ client: MosaicClient | null;
71
84
  columns: DataTableExplorerColumnState[];
72
85
  filteredRowCount?: number;
73
86
  hasFilters: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/data-table-explorer/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAC,KAAK,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,OAAO,CAAC;AAEpD,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAC,CAAC,CAAC;AAE1E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,IAAI,CAAC;AAEtD,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,yBAAyB,CAAC;IAC9B,EAAE,EAAE,yBAAyB,CAAC;IAC9B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E,CAAC;IACnB,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,+BAA+B,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,4BAA4B,EAAE,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,UAAU,EAAE,gCAAgC,CAAC;IAC7C,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,gCAAgC,CAAC,CAAC,CAAC;IAC1E,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAC/D,OAAO,EAAE,wBAAwB,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data-table-explorer/types.ts"],"names":[],"mappings":"","sourcesContent":["import {DataTable} from '@sqlrooms/db';\nimport type {Selection} from '@uwdata/mosaic-core';\nimport type {Interval1D} from '@uwdata/mosaic-plot';\nimport type {Field, Table} from 'apache-arrow';\nimport type {Dispatch, SetStateAction} from 'react';\n\nexport type DataTableExplorerSorting = Array<{id: string; desc: boolean}>;\n\nexport type DataTableExplorerPaginationState = {\n pageIndex: number;\n pageSize: number;\n};\n\nexport type DataTableExplorerBinValue = number | Date;\n\nexport type DataTableExplorerBin = {\n x0: DataTableExplorerBinValue;\n x1: DataTableExplorerBinValue;\n length: number;\n};\n\nexport type DataTableExplorerSummaryStatus = {\n error?: Error;\n isLoading: boolean;\n};\n\nexport type DataTableExplorerHistogramSummary =\n DataTableExplorerSummaryStatus & {\n filteredBins: DataTableExplorerBin[];\n filteredNullCount: number;\n interactor: Interval1D | null;\n kind: 'histogram';\n totalBins: DataTableExplorerBin[];\n totalNullCount: number;\n valueType: 'date' | 'number';\n };\n\nexport type DataTableExplorerCategoryBucket = {\n filteredCount: number;\n key: string;\n kind: 'null' | 'overflow' | 'unique' | 'value';\n label: string;\n selectable: boolean;\n totalCount: number;\n};\n\nexport type DataTableExplorerCategorySummary =\n DataTableExplorerSummaryStatus & {\n bucketCount: number;\n buckets: DataTableExplorerCategoryBucket[];\n kind: 'category';\n selectedKey?: string;\n toggleValue: (key: string) => void;\n };\n\nexport type DataTableExplorerUnsupportedSummary =\n DataTableExplorerSummaryStatus & {\n kind: 'unsupported';\n label: string;\n };\n\nexport type DataTableExplorerSummaryState =\n | DataTableExplorerCategorySummary\n | DataTableExplorerHistogramSummary\n | DataTableExplorerUnsupportedSummary;\n\nexport type DataTableExplorerColumnKind =\n | 'category'\n | 'histogram'\n | 'unsupported';\n\nexport type DataTableExplorerColumnState = {\n field: Field;\n kind: DataTableExplorerColumnKind;\n name: string;\n summary: DataTableExplorerSummaryState;\n};\n\nexport type DataTableExplorerOptions = {\n categoryLimit?: number;\n columns?: string[];\n initialSorting?: DataTableExplorerSorting;\n pageSize?: number;\n selection?: Selection;\n selectionName?: string;\n summaryBins?: number;\n tableName: DataTable;\n};\n\nexport type UseDataTableExplorerReturn = {\n columns: DataTableExplorerColumnState[];\n filteredRowCount?: number;\n hasFilters: boolean;\n isLoading: boolean;\n pageQuery: string;\n pageTable?: Table;\n pagination: DataTableExplorerPaginationState;\n reset: () => void;\n selection: Selection;\n setPagination: Dispatch<SetStateAction<DataTableExplorerPaginationState>>;\n setSorting: Dispatch<SetStateAction<DataTableExplorerSorting>>;\n sorting: DataTableExplorerSorting;\n sql: string;\n tableError?: Error;\n totalRowCount?: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data-table-explorer/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {QualifiedTableName} from '@sqlrooms/db';\nimport type {MosaicClient, Selection} from '@uwdata/mosaic-core';\nimport type {TableRefNode} from '@uwdata/mosaic-sql';\nimport type {Interval1D} from '@uwdata/mosaic-plot';\nimport type {Field, Table} from 'apache-arrow';\nimport type {Dispatch, SetStateAction} from 'react';\n\nexport type DataTableExplorerSorting = Array<{id: string; desc: boolean}>;\n\nexport type DataTableExplorerPaginationState = {\n pageIndex: number;\n pageSize: number;\n};\n\nexport type DataTableExplorerBinValue = number | Date;\n\nexport type DataTableExplorerBin = {\n x0: DataTableExplorerBinValue;\n x1: DataTableExplorerBinValue;\n length: number;\n};\n\nexport type DataTableExplorerSummaryStatus = {\n error?: Error;\n isLoading: boolean;\n};\n\nexport type DataTableExplorerHistogramSummary =\n DataTableExplorerSummaryStatus & {\n filteredBins: DataTableExplorerBin[];\n filteredNullCount: number;\n interactor: Interval1D | null;\n kind: 'histogram';\n totalBins: DataTableExplorerBin[];\n totalNullCount: number;\n valueType: 'date' | 'number';\n };\n\nexport type DataTableExplorerCategoryBucket = {\n filteredCount: number;\n key: string;\n kind: 'null' | 'overflow' | 'unique' | 'value';\n label: string;\n selectable: boolean;\n totalCount: number;\n};\n\nexport type DataTableExplorerCategorySummary =\n DataTableExplorerSummaryStatus & {\n bucketCount: number;\n buckets: DataTableExplorerCategoryBucket[];\n client?: MosaicClient;\n kind: 'category';\n selectedKey?: string;\n toggleValue: (key: string) => void;\n };\n\nexport type DataTableExplorerUnsupportedSummary =\n DataTableExplorerSummaryStatus & {\n kind: 'unsupported';\n label: string;\n };\n\nexport type DataTableExplorerSummaryState =\n | DataTableExplorerCategorySummary\n | DataTableExplorerHistogramSummary\n | DataTableExplorerUnsupportedSummary;\n\nexport type DataTableExplorerColumnKind =\n | 'category'\n | 'histogram'\n | 'unsupported';\n\nexport type DataTableExplorerColumnState = {\n field: Field;\n kind: DataTableExplorerColumnKind;\n name: string;\n summary: DataTableExplorerSummaryState;\n};\n\nexport type DataTableExplorerTableReference = string | QualifiedTableName;\n\n/**\n * Table reference accepted by dataTableExplorer query builders.\n *\n * Use a string for simple unqualified table names or for call sites that already\n * require a string SQL boundary. Use a TableRefNode for qualified names,\n * especially when schema or table identifier parts may contain dots or quotes,\n * so Mosaic does not reparse those parts from a flattened string.\n */\nexport type DataTableExplorerSqlTableReference = string | TableRefNode;\n\nexport type DataTableExplorerOptions = {\n categoryLimit?: number;\n columns?: string[];\n initialSorting?: DataTableExplorerSorting;\n pageSize?: number;\n selection?: Selection;\n selectionName?: string;\n summaryBins?: number;\n tableName: DataTableExplorerTableReference;\n};\n\nexport type UseDataTableExplorerReturn = {\n client: MosaicClient | null;\n columns: DataTableExplorerColumnState[];\n filteredRowCount?: number;\n hasFilters: boolean;\n isLoading: boolean;\n pageQuery: string;\n pageTable?: Table;\n pagination: DataTableExplorerPaginationState;\n reset: () => void;\n selection: Selection;\n setPagination: Dispatch<SetStateAction<DataTableExplorerPaginationState>>;\n setSorting: Dispatch<SetStateAction<DataTableExplorerSorting>>;\n sorting: DataTableExplorerSorting;\n sql: string;\n tableError?: Error;\n totalRowCount?: number;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableExplorer.d.ts","sourceRoot":"","sources":["../../src/data-table-explorer/useDataTableExplorer.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAEV,wBAAwB,EAGxB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AA8bjB;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,wBAAwB,GAChC,0BAA0B,CA8G5B"}
1
+ {"version":3,"file":"useDataTableExplorer.d.ts","sourceRoot":"","sources":["../../src/data-table-explorer/useDataTableExplorer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAcjB;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,wBAAwB,GAChC,0BAA0B,CA0H5B"}
@@ -1,296 +1,34 @@
1
- import { createId } from '@paralleldrive/cuid2';
2
1
  import { useDebounce } from '@sqlrooms/ui';
3
- import { Selection as MosaicSelection, } from '@uwdata/mosaic-core';
4
- import { useEffect, useMemo, useRef, useState, } from 'react';
5
- import { useStore } from 'zustand';
2
+ import { useMemo } from 'react';
6
3
  import { useStoreWithMosaic } from '../MosaicSlice';
7
- import { createDataTableExplorerStore, } from './createDataTableExplorerStore';
8
- import { connectDataTableExplorerCountClient, connectDataTableExplorerPageClient, connectDataTableExplorerSummaryClients, loadDataTableExplorerSchema, } from './dataTableExplorerController';
9
- import { buildDataTableExplorerBaseQuery, buildDataTableExplorerPageQuery, createEmptySummaryState, isDataTableExplorerHistogramType, isDataTableExplorerUnsupportedSummaryType, } from './utils';
10
- /**
11
- * Tracks Mosaic selection updates as a monotonically increasing version so
12
- * memoized queries and lifecycle effects can respond to crossfilter changes.
13
- */
14
- function useSelectionVersion(selection) {
15
- const [version, setVersion] = useState(0);
16
- useEffect(() => {
17
- const handleChange = () => setVersion((value) => value + 1);
18
- selection.addEventListener('value', handleChange);
19
- return () => selection.removeEventListener('value', handleChange);
20
- }, [selection]);
21
- return version;
22
- }
23
- /**
24
- * Resolves the dataTableExplorer selection, creating a crossfilter selection when the
25
- * caller does not supply one, and exposes a version that changes with it.
26
- */
27
- function useDataTableExplorerSelection(options) {
28
- const { selection: providedSelection, selectionName } = options;
29
- const generatedSelectionName = useMemo(() => `mosaic-data-table-explorer-${createId()}`, []);
30
- const selectionKey = selectionName ?? generatedSelectionName;
31
- const existingSelection = useStoreWithMosaic((state) => state.mosaic.selections[selectionKey]);
32
- const getSelection = useStoreWithMosaic((state) => state.mosaic.getSelection);
33
- const [fallbackSelection] = useState(() => MosaicSelection.crossfilter());
34
- useEffect(() => {
35
- if (!providedSelection && !existingSelection) {
36
- getSelection(selectionKey, 'crossfilter');
37
- }
38
- }, [existingSelection, getSelection, providedSelection, selectionKey]);
39
- const selection = providedSelection ?? existingSelection ?? fallbackSelection;
40
- return {
41
- selection,
42
- selectionVersion: useSelectionVersion(selection),
43
- };
44
- }
45
- /**
46
- * Creates the per-dataTableExplorer local store and subscribes to the raw state slices
47
- * that the public dataTableExplorer hook exposes.
48
- */
49
- function useDataTableExplorerStoreState(options) {
50
- const [dataTableExplorerStore] = useState(() => createDataTableExplorerStore({
51
- initialSorting: options.initialSorting,
52
- pageSize: options.pageSize,
53
- }));
54
- return {
55
- filteredCount: useStore(dataTableExplorerStore, (state) => state.filteredCount),
56
- lastNonEmptyPageTable: useStore(dataTableExplorerStore, (state) => state.lastNonEmptyPageTable),
57
- page: useStore(dataTableExplorerStore, (state) => state.page),
58
- pagination: useStore(dataTableExplorerStore, (state) => state.pagination),
59
- dataTableExplorerStore,
60
- schema: useStore(dataTableExplorerStore, (state) => state.schema),
61
- setPagination: useStore(dataTableExplorerStore, (state) => state.setPagination),
62
- setSorting: useStore(dataTableExplorerStore, (state) => state.setSorting),
63
- sorting: useStore(dataTableExplorerStore, (state) => state.sorting),
64
- summaries: useStore(dataTableExplorerStore, (state) => state.summaries),
65
- totalCount: useStore(dataTableExplorerStore, (state) => state.totalCount),
66
- };
67
- }
68
- /**
69
- * Derives the dataTableExplorer's field and SQL state from the current schema,
70
- * selection, sorting, and pagination state.
71
- */
72
- function useDataTableExplorerQueryState(options) {
73
- const { pagination, rowSelectionVersion, schema, selection, selectionVersion, sorting, tableName, } = options;
74
- const fields = schema.fields;
75
- const fieldNames = useMemo(() => fields.map((field) => field.name), [fields]);
76
- const filter = useMemo(() => {
77
- void selectionVersion;
78
- return selection.predicate();
79
- }, [selection, selectionVersion]);
80
- const rowFilter = useMemo(() => {
81
- void rowSelectionVersion;
82
- return selection.predicate();
83
- }, [rowSelectionVersion, selection]);
84
- const baseQuery = useMemo(() => buildDataTableExplorerBaseQuery({
85
- columns: fieldNames,
86
- filter,
87
- sorting,
88
- tableName,
89
- }), [fieldNames, filter, sorting, tableName]);
90
- const pageBaseQuery = useMemo(() => buildDataTableExplorerBaseQuery({
91
- columns: fieldNames,
92
- filter: rowFilter,
93
- sorting,
94
- tableName,
95
- }), [fieldNames, rowFilter, sorting, tableName]);
96
- return {
97
- baseQuery,
98
- datasetId: [tableName, ...fieldNames].join('\u0001'),
99
- fieldNames,
100
- fields,
101
- hasFilters: Array.isArray(filter) ? filter.length > 0 : Boolean(filter),
102
- pageQuery: buildDataTableExplorerPageQuery(pageBaseQuery, pagination).toString(),
103
- rowFilter,
104
- };
105
- }
106
- /**
107
- * Owns the coordinator-backed schema, row, count, and summary client
108
- * lifecycles for a dataTableExplorer instance.
109
- */
110
- function useDataTableExplorerLifecycles(options) {
111
- const { categoryLimit, columns, connection, fieldNames, fields, pageSize, pagination, dataTableExplorerStore, rowFilter, selection, selectionVersion, sorting, summaryBins, tableName, } = options;
112
- const previousTableNameRef = useRef(tableName);
113
- useEffect(() => {
114
- dataTableExplorerStore.getState().syncPageSize(pageSize);
115
- }, [pageSize, dataTableExplorerStore]);
116
- useEffect(() => {
117
- if (previousTableNameRef.current === tableName)
118
- return;
119
- selection.reset();
120
- previousTableNameRef.current = tableName;
121
- }, [selection, tableName]);
122
- useEffect(() => {
123
- dataTableExplorerStore.getState().resetPageIndex();
124
- }, [dataTableExplorerStore, selectionVersion, tableName]);
125
- useEffect(() => {
126
- if (connection.status !== 'ready' || !tableName) {
127
- dataTableExplorerStore.getState().setSchemaSuccess([]);
128
- dataTableExplorerStore.getState().setSchemaError(undefined);
129
- dataTableExplorerStore
130
- .getState()
131
- .setSchemaLoading(connection.status === 'loading');
132
- return;
133
- }
134
- void loadDataTableExplorerSchema({
135
- columns,
136
- coordinator: connection.coordinator,
137
- store: dataTableExplorerStore,
138
- tableName,
139
- });
140
- }, [columns, connection, dataTableExplorerStore, tableName]);
141
- useEffect(() => {
142
- if (connection.status !== 'ready' || !tableName || !fieldNames.length) {
143
- dataTableExplorerStore.getState().setPage({ isLoading: false });
144
- return;
145
- }
146
- return connectDataTableExplorerPageClient({
147
- connection,
148
- fieldNames,
149
- filter: rowFilter,
150
- pagination,
151
- sorting,
152
- store: dataTableExplorerStore,
153
- tableName,
154
- });
155
- }, [
156
- connection,
157
- fieldNames,
158
- pagination,
159
- dataTableExplorerStore,
160
- rowFilter,
161
- sorting,
162
- tableName,
163
- ]);
164
- useEffect(() => {
165
- if (connection.status !== 'ready' || !tableName) {
166
- dataTableExplorerStore.getState().setFilteredCount({ isLoading: false });
167
- return;
168
- }
169
- return connectDataTableExplorerCountClient({
170
- connection,
171
- filterStable: true,
172
- selection,
173
- store: dataTableExplorerStore,
174
- tableName,
175
- target: 'filtered',
176
- });
177
- }, [connection, dataTableExplorerStore, selection, tableName]);
178
- useEffect(() => {
179
- if (connection.status !== 'ready' || !tableName) {
180
- dataTableExplorerStore.getState().setTotalCount({ isLoading: false });
181
- return;
182
- }
183
- return connectDataTableExplorerCountClient({
184
- connection,
185
- store: dataTableExplorerStore,
186
- tableName,
187
- target: 'total',
188
- });
189
- }, [connection, dataTableExplorerStore, tableName]);
190
- useEffect(() => {
191
- if (connection.status !== 'ready' || !fields.length) {
192
- dataTableExplorerStore.getState().clearSummaries();
193
- return;
194
- }
195
- return connectDataTableExplorerSummaryClients({
196
- categoryLimit,
197
- connection,
198
- fields,
199
- selection,
200
- store: dataTableExplorerStore,
201
- summaryBins,
202
- tableName,
203
- });
204
- }, [
205
- categoryLimit,
206
- connection,
207
- fields,
208
- dataTableExplorerStore,
209
- selection,
210
- summaryBins,
211
- tableName,
212
- ]);
213
- }
214
- /**
215
- * Maps the schema fields and summary state into the column model consumed by
216
- * the dataTableExplorer header and summary cells.
217
- */
218
- function useDataTableExplorerColumns(options) {
219
- const { fields, summaries } = options;
220
- return useMemo(() => fields.map((field) => ({
221
- field,
222
- kind: isDataTableExplorerUnsupportedSummaryType(field.type)
223
- ? 'unsupported'
224
- : isDataTableExplorerHistogramType(field.type)
225
- ? 'histogram'
226
- : 'category',
227
- name: field.name,
228
- summary: summaries[field.name] ?? createEmptySummaryState(field),
229
- })), [fields, summaries]);
230
- }
231
- /**
232
- * Collapses the aggregated dataTableExplorer client state into the loading and error
233
- * signals exposed from the public hook.
234
- */
235
- function useDataTableExplorerStatus(options) {
236
- const { fields, filteredCount, page, schema, summaries, totalCount } = options;
237
- const hasPendingSummaryInitialization = fields.length > 0 && Object.keys(summaries).length < fields.length;
238
- return {
239
- isLoading: schema.isLoading ||
240
- page.isLoading ||
241
- filteredCount.isLoading ||
242
- totalCount.isLoading ||
243
- hasPendingSummaryInitialization ||
244
- Object.values(summaries).some((summary) => summary.isLoading),
245
- tableError: schema.error ??
246
- page.error ??
247
- filteredCount.error ??
248
- totalCount.error ??
249
- Object.values(summaries).find((summary) => summary.error)?.error,
250
- };
251
- }
252
- /**
253
- * Keeps the last non-empty page result visible while live brushing has moved
254
- * ahead of the deferred row query, avoiding transient "No rows" flashes.
255
- */
256
- function useDataTableExplorerVisiblePageState(options) {
257
- const { lastNonEmptyPageTable, page, pageDatasetId, rowSelectionVersion, selectionVersion, } = options;
258
- const isRowDisplayStale = selectionVersion !== rowSelectionVersion;
259
- const hasCurrentRows = !!page.pageTable && page.pageTable.numRows > 0;
260
- const canReuseLastNonEmptyPage = !!lastNonEmptyPageTable &&
261
- lastNonEmptyPageTable.datasetId === pageDatasetId;
262
- const canShowStableEmpty = !page.isLoading &&
263
- !isRowDisplayStale &&
264
- (!page.pageTable || page.pageTable.numRows === 0);
265
- const showStableEmpty = useDebounce(canShowStableEmpty, 120);
266
- if (hasCurrentRows || !canReuseLastNonEmptyPage) {
267
- return page.pageTable;
268
- }
269
- return showStableEmpty ? page.pageTable : lastNonEmptyPageTable.pageTable;
270
- }
271
- function getTableReference(table) {
272
- return [table.table.database, table.table.schema, table.table.table]
273
- .filter((part) => Boolean(part))
274
- .join('.');
275
- }
4
+ import { useDataTableExplorerSelection } from './hooks/useDataTableExplorerSelection';
5
+ import { useDataTableExplorerStoreState } from './hooks/useDataTableExplorerStoreState';
6
+ import { useDataTableExplorerQueryState } from './hooks/useDataTableExplorerQueryState';
7
+ import { useDataTableExplorerLifecycles } from './hooks/useDataTableExplorerLifecycles';
8
+ import { useDataTableExplorerColumns } from './hooks/useDataTableExplorerColumns';
9
+ import { useDataTableExplorerStatus } from './hooks/useDataTableExplorerStatus';
10
+ import { useDataTableExplorerVisiblePage } from './hooks/useDataTableExplorerVisiblePage';
11
+ import { getMosaicRawSqlTableReference, getMosaicSqlTableReference, getMosaicTableIdentity, } from '../mosaicTableReference';
276
12
  /**
277
13
  * Aggregates Mosaic-backed schema, rows, counts, and summaries into the stable
278
14
  * public dataTableExplorer API consumed by the React table UI.
279
15
  */
280
16
  export function useDataTableExplorer(options) {
281
17
  const { categoryLimit = 20, columns, initialSorting = [], pageSize = 100, selection: providedSelection, selectionName, summaryBins = 18, tableName: table, } = options;
282
- const tableName = getTableReference(table);
18
+ const tableIdentity = useMemo(() => getMosaicTableIdentity(table), [table]);
19
+ const tableName = useMemo(() => getMosaicRawSqlTableReference(table), [table]);
20
+ const tableReference = useMemo(() => getMosaicSqlTableReference(table), [table]);
283
21
  const connection = useStoreWithMosaic((state) => state.mosaic.connection);
284
22
  const { selection, selectionVersion } = useDataTableExplorerSelection({
285
23
  selection: providedSelection,
286
24
  selectionName,
287
25
  });
288
26
  const rowSelectionVersion = useDebounce(selectionVersion, 100);
289
- const { filteredCount, lastNonEmptyPageTable, page, pagination, dataTableExplorerStore, schema: rawSchema, setPagination, setSorting, sorting, summaries, totalCount, } = useDataTableExplorerStoreState({
27
+ const { client, filteredCount, lastNonEmptyPageTable, page, pagination, dataTableExplorerStore, schema: rawSchema, setPagination, setSorting, sorting, summaries, totalCount, } = useDataTableExplorerStoreState({
290
28
  initialSorting,
291
29
  pageSize,
292
30
  });
293
- const schema = rawSchema.tableName === tableName
31
+ const schema = rawSchema.tableName === tableIdentity
294
32
  ? rawSchema
295
33
  : { ...rawSchema, fields: [], isLoading: true };
296
34
  const { baseQuery, datasetId, fieldNames, fields, hasFilters, pageQuery, rowFilter, } = useDataTableExplorerQueryState({
@@ -300,7 +38,8 @@ export function useDataTableExplorer(options) {
300
38
  selection,
301
39
  selectionVersion,
302
40
  sorting,
303
- tableName,
41
+ tableIdentity,
42
+ tableReference,
304
43
  });
305
44
  useDataTableExplorerLifecycles({
306
45
  categoryLimit,
@@ -316,21 +55,22 @@ export function useDataTableExplorer(options) {
316
55
  selectionVersion,
317
56
  sorting,
318
57
  summaryBins,
58
+ tableIdentity,
319
59
  tableName,
60
+ tableReference,
320
61
  });
321
62
  const dataTableExplorerColumns = useDataTableExplorerColumns({
322
63
  fields,
323
64
  summaries,
324
65
  });
325
66
  const { isLoading, tableError } = useDataTableExplorerStatus({
326
- fields,
327
67
  filteredCount,
328
68
  page,
329
69
  schema,
330
70
  summaries,
331
71
  totalCount,
332
72
  });
333
- const visiblePage = useDataTableExplorerVisiblePageState({
73
+ const visiblePage = useDataTableExplorerVisiblePage({
334
74
  lastNonEmptyPageTable,
335
75
  page,
336
76
  pageDatasetId: datasetId,
@@ -338,6 +78,7 @@ export function useDataTableExplorer(options) {
338
78
  selectionVersion,
339
79
  });
340
80
  return {
81
+ client,
341
82
  columns: dataTableExplorerColumns,
342
83
  filteredRowCount: filteredCount.count,
343
84
  hasFilters,
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableExplorer.js","sourceRoot":"","sources":["../../src/data-table-explorer/useDataTableExplorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,SAAS,IAAI,eAAe,GAE7B,MAAM,qBAAqB,CAAC;AAC7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C,CAAC;QACvD,qBAAqB;QACrB,IAAI;QACJ,aAAa,EAAE,SAAS;QACxB,mBAAmB;QACnB,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,wBAAwB;QACjC,gBAAgB,EAAE,aAAa,CAAC,KAAK;QACrC,UAAU;QACV,SAAS;QACT,SAAS;QACT,SAAS,EAAE,WAAW;QACtB,UAAU;QACV,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE;QAC9B,SAAS;QACT,aAAa;QACb,UAAU;QACV,OAAO;QACP,GAAG,EAAE,SAAS,CAAC,QAAQ,EAAE;QACzB,UAAU;QACV,aAAa,EAAE,UAAU,CAAC,KAAK;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import {createId} from '@paralleldrive/cuid2';\nimport {useDebounce} from '@sqlrooms/ui';\nimport {\n Selection as MosaicSelection,\n type Selection,\n} from '@uwdata/mosaic-core';\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n type Dispatch,\n type SetStateAction,\n} from 'react';\nimport {useStore} from 'zustand';\nimport {useStoreWithMosaic, type MosaicSliceState} from '../MosaicSlice';\nimport {\n createDataTableExplorerStore,\n type DataTableExplorerStore,\n type DataTableExplorerStoreState,\n} from './createDataTableExplorerStore';\nimport {\n connectDataTableExplorerCountClient,\n connectDataTableExplorerPageClient,\n connectDataTableExplorerSummaryClients,\n loadDataTableExplorerSchema,\n} from './dataTableExplorerController';\nimport type {\n DataTableExplorerColumnState,\n DataTableExplorerOptions,\n DataTableExplorerPaginationState,\n DataTableExplorerSorting,\n UseDataTableExplorerReturn,\n} from './types';\nimport {\n buildDataTableExplorerBaseQuery,\n buildDataTableExplorerPageQuery,\n createEmptySummaryState,\n isDataTableExplorerHistogramType,\n isDataTableExplorerUnsupportedSummaryType,\n} from './utils';\nimport {DataTable} from '@sqlrooms/db';\n\ntype DataTableExplorerSelectionState = {\n selection: Selection;\n selectionVersion: number;\n};\n\ntype DataTableExplorerStoreSlice = {\n filteredCount: DataTableExplorerStoreState['filteredCount'];\n lastNonEmptyPageTable: DataTableExplorerStoreState['lastNonEmptyPageTable'];\n page: DataTableExplorerStoreState['page'];\n pagination: DataTableExplorerPaginationState;\n dataTableExplorerStore: DataTableExplorerStore;\n schema: DataTableExplorerStoreState['schema'];\n setPagination: Dispatch<SetStateAction<DataTableExplorerPaginationState>>;\n setSorting: Dispatch<SetStateAction<DataTableExplorerSorting>>;\n sorting: DataTableExplorerSorting;\n summaries: DataTableExplorerStoreState['summaries'];\n totalCount: DataTableExplorerStoreState['totalCount'];\n};\n\ntype DataTableExplorerQueryState = {\n baseQuery: ReturnType<typeof buildDataTableExplorerBaseQuery>;\n datasetId: string;\n fieldNames: string[];\n fields: DataTableExplorerStoreState['schema']['fields'];\n hasFilters: boolean;\n pageQuery: string;\n rowFilter: ReturnType<Selection['predicate']>;\n};\n\n/**\n * Tracks Mosaic selection updates as a monotonically increasing version so\n * memoized queries and lifecycle effects can respond to crossfilter changes.\n */\nfunction useSelectionVersion(selection: Selection) {\n const [version, setVersion] = useState(0);\n\n useEffect(() => {\n const handleChange = () => setVersion((value) => value + 1);\n selection.addEventListener('value', handleChange);\n return () => selection.removeEventListener('value', handleChange);\n }, [selection]);\n\n return version;\n}\n\n/**\n * Resolves the dataTableExplorer selection, creating a crossfilter selection when the\n * caller does not supply one, and exposes a version that changes with it.\n */\nfunction useDataTableExplorerSelection(\n options: Pick<DataTableExplorerOptions, 'selection' | 'selectionName'>,\n): DataTableExplorerSelectionState {\n const {selection: providedSelection, selectionName} = options;\n const generatedSelectionName = useMemo(\n () => `mosaic-data-table-explorer-${createId()}`,\n [],\n );\n const selectionKey = selectionName ?? generatedSelectionName;\n const existingSelection = useStoreWithMosaic(\n (state) => state.mosaic.selections[selectionKey],\n );\n const getSelection = useStoreWithMosaic((state) => state.mosaic.getSelection);\n const [fallbackSelection] = useState(() => MosaicSelection.crossfilter());\n\n useEffect(() => {\n if (!providedSelection && !existingSelection) {\n getSelection(selectionKey, 'crossfilter');\n }\n }, [existingSelection, getSelection, providedSelection, selectionKey]);\n\n const selection = providedSelection ?? existingSelection ?? fallbackSelection;\n\n return {\n selection,\n selectionVersion: useSelectionVersion(selection),\n };\n}\n\n/**\n * Creates the per-dataTableExplorer local store and subscribes to the raw state slices\n * that the public dataTableExplorer hook exposes.\n */\nfunction useDataTableExplorerStoreState(options: {\n initialSorting: DataTableExplorerSorting;\n pageSize: number;\n}): DataTableExplorerStoreSlice {\n const [dataTableExplorerStore] = useState(() =>\n createDataTableExplorerStore({\n initialSorting: options.initialSorting,\n pageSize: options.pageSize,\n }),\n );\n\n return {\n filteredCount: useStore(\n dataTableExplorerStore,\n (state) => state.filteredCount,\n ),\n lastNonEmptyPageTable: useStore(\n dataTableExplorerStore,\n (state) => state.lastNonEmptyPageTable,\n ),\n page: useStore(dataTableExplorerStore, (state) => state.page),\n pagination: useStore(dataTableExplorerStore, (state) => state.pagination),\n dataTableExplorerStore,\n schema: useStore(dataTableExplorerStore, (state) => state.schema),\n setPagination: useStore(\n dataTableExplorerStore,\n (state) => state.setPagination,\n ),\n setSorting: useStore(dataTableExplorerStore, (state) => state.setSorting),\n sorting: useStore(dataTableExplorerStore, (state) => state.sorting),\n summaries: useStore(dataTableExplorerStore, (state) => state.summaries),\n totalCount: useStore(dataTableExplorerStore, (state) => state.totalCount),\n };\n}\n\n/**\n * Derives the dataTableExplorer's field and SQL state from the current schema,\n * selection, sorting, and pagination state.\n */\nfunction useDataTableExplorerQueryState(options: {\n pagination: DataTableExplorerPaginationState;\n rowSelectionVersion: number;\n schema: DataTableExplorerStoreState['schema'];\n selection: Selection;\n selectionVersion: number;\n sorting: DataTableExplorerSorting;\n tableName: string;\n}): DataTableExplorerQueryState {\n const {\n pagination,\n rowSelectionVersion,\n schema,\n selection,\n selectionVersion,\n sorting,\n tableName,\n } = options;\n const fields = schema.fields;\n const fieldNames = useMemo(() => fields.map((field) => field.name), [fields]);\n const filter = useMemo(() => {\n void selectionVersion;\n return selection.predicate();\n }, [selection, selectionVersion]);\n const rowFilter = useMemo(() => {\n void rowSelectionVersion;\n return selection.predicate();\n }, [rowSelectionVersion, selection]);\n const baseQuery = useMemo(\n () =>\n buildDataTableExplorerBaseQuery({\n columns: fieldNames,\n filter,\n sorting,\n tableName,\n }),\n [fieldNames, filter, sorting, tableName],\n );\n const pageBaseQuery = useMemo(\n () =>\n buildDataTableExplorerBaseQuery({\n columns: fieldNames,\n filter: rowFilter,\n sorting,\n tableName,\n }),\n [fieldNames, rowFilter, sorting, tableName],\n );\n\n return {\n baseQuery,\n datasetId: [tableName, ...fieldNames].join('\\u0001'),\n fieldNames,\n fields,\n hasFilters: Array.isArray(filter) ? filter.length > 0 : Boolean(filter),\n pageQuery: buildDataTableExplorerPageQuery(\n pageBaseQuery,\n pagination,\n ).toString(),\n rowFilter,\n };\n}\n\n/**\n * Owns the coordinator-backed schema, row, count, and summary client\n * lifecycles for a dataTableExplorer instance.\n */\nfunction useDataTableExplorerLifecycles(options: {\n categoryLimit: number;\n columns?: string[];\n connection: MosaicSliceState['mosaic']['connection'];\n fieldNames: string[];\n fields: DataTableExplorerStoreState['schema']['fields'];\n pageSize: number;\n pagination: DataTableExplorerPaginationState;\n dataTableExplorerStore: DataTableExplorerStore;\n rowFilter: ReturnType<Selection['predicate']>;\n selection: Selection;\n selectionVersion: number;\n sorting: DataTableExplorerSorting;\n summaryBins: number;\n tableName: string;\n}) {\n const {\n categoryLimit,\n columns,\n connection,\n fieldNames,\n fields,\n pageSize,\n pagination,\n dataTableExplorerStore,\n rowFilter,\n selection,\n selectionVersion,\n sorting,\n summaryBins,\n tableName,\n } = options;\n const previousTableNameRef = useRef(tableName);\n\n useEffect(() => {\n dataTableExplorerStore.getState().syncPageSize(pageSize);\n }, [pageSize, dataTableExplorerStore]);\n\n useEffect(() => {\n if (previousTableNameRef.current === tableName) return;\n selection.reset();\n previousTableNameRef.current = tableName;\n }, [selection, tableName]);\n\n useEffect(() => {\n dataTableExplorerStore.getState().resetPageIndex();\n }, [dataTableExplorerStore, selectionVersion, tableName]);\n\n useEffect(() => {\n if (connection.status !== 'ready' || !tableName) {\n dataTableExplorerStore.getState().setSchemaSuccess([]);\n dataTableExplorerStore.getState().setSchemaError(undefined);\n dataTableExplorerStore\n .getState()\n .setSchemaLoading(connection.status === 'loading');\n return;\n }\n\n void loadDataTableExplorerSchema({\n columns,\n coordinator: connection.coordinator,\n store: dataTableExplorerStore,\n tableName,\n });\n }, [columns, connection, dataTableExplorerStore, tableName]);\n\n useEffect(() => {\n if (connection.status !== 'ready' || !tableName || !fieldNames.length) {\n dataTableExplorerStore.getState().setPage({isLoading: false});\n return;\n }\n\n return connectDataTableExplorerPageClient({\n connection,\n fieldNames,\n filter: rowFilter,\n pagination,\n sorting,\n store: dataTableExplorerStore,\n tableName,\n });\n }, [\n connection,\n fieldNames,\n pagination,\n dataTableExplorerStore,\n rowFilter,\n sorting,\n tableName,\n ]);\n\n useEffect(() => {\n if (connection.status !== 'ready' || !tableName) {\n dataTableExplorerStore.getState().setFilteredCount({isLoading: false});\n return;\n }\n\n return connectDataTableExplorerCountClient({\n connection,\n filterStable: true,\n selection,\n store: dataTableExplorerStore,\n tableName,\n target: 'filtered',\n });\n }, [connection, dataTableExplorerStore, selection, tableName]);\n\n useEffect(() => {\n if (connection.status !== 'ready' || !tableName) {\n dataTableExplorerStore.getState().setTotalCount({isLoading: false});\n return;\n }\n\n return connectDataTableExplorerCountClient({\n connection,\n store: dataTableExplorerStore,\n tableName,\n target: 'total',\n });\n }, [connection, dataTableExplorerStore, tableName]);\n\n useEffect(() => {\n if (connection.status !== 'ready' || !fields.length) {\n dataTableExplorerStore.getState().clearSummaries();\n return;\n }\n\n return connectDataTableExplorerSummaryClients({\n categoryLimit,\n connection,\n fields,\n selection,\n store: dataTableExplorerStore,\n summaryBins,\n tableName,\n });\n }, [\n categoryLimit,\n connection,\n fields,\n dataTableExplorerStore,\n selection,\n summaryBins,\n tableName,\n ]);\n}\n\n/**\n * Maps the schema fields and summary state into the column model consumed by\n * the dataTableExplorer header and summary cells.\n */\nfunction useDataTableExplorerColumns(options: {\n fields: DataTableExplorerStoreState['schema']['fields'];\n summaries: DataTableExplorerStoreState['summaries'];\n}) {\n const {fields, summaries} = options;\n\n return useMemo<DataTableExplorerColumnState[]>(\n () =>\n fields.map((field) => ({\n field,\n kind: isDataTableExplorerUnsupportedSummaryType(field.type)\n ? 'unsupported'\n : isDataTableExplorerHistogramType(field.type)\n ? 'histogram'\n : 'category',\n name: field.name,\n summary: summaries[field.name] ?? createEmptySummaryState(field),\n })),\n [fields, summaries],\n );\n}\n\n/**\n * Collapses the aggregated dataTableExplorer client state into the loading and error\n * signals exposed from the public hook.\n */\nfunction useDataTableExplorerStatus(options: {\n filteredCount: DataTableExplorerStoreState['filteredCount'];\n fields: DataTableExplorerStoreState['schema']['fields'];\n page: DataTableExplorerStoreState['page'];\n schema: DataTableExplorerStoreState['schema'];\n summaries: DataTableExplorerStoreState['summaries'];\n totalCount: DataTableExplorerStoreState['totalCount'];\n}) {\n const {fields, filteredCount, page, schema, summaries, totalCount} = options;\n const hasPendingSummaryInitialization =\n fields.length > 0 && Object.keys(summaries).length < fields.length;\n\n return {\n isLoading:\n schema.isLoading ||\n page.isLoading ||\n filteredCount.isLoading ||\n totalCount.isLoading ||\n hasPendingSummaryInitialization ||\n Object.values(summaries).some((summary) => summary.isLoading),\n tableError:\n schema.error ??\n page.error ??\n filteredCount.error ??\n totalCount.error ??\n Object.values(summaries).find((summary) => summary.error)?.error,\n };\n}\n\n/**\n * Keeps the last non-empty page result visible while live brushing has moved\n * ahead of the deferred row query, avoiding transient \"No rows\" flashes.\n */\nfunction useDataTableExplorerVisiblePageState(options: {\n lastNonEmptyPageTable: DataTableExplorerStoreState['lastNonEmptyPageTable'];\n pageDatasetId: string;\n page: DataTableExplorerStoreState['page'];\n rowSelectionVersion: number;\n selectionVersion: number;\n}) {\n const {\n lastNonEmptyPageTable,\n page,\n pageDatasetId,\n rowSelectionVersion,\n selectionVersion,\n } = options;\n const isRowDisplayStale = selectionVersion !== rowSelectionVersion;\n const hasCurrentRows = !!page.pageTable && page.pageTable.numRows > 0;\n const canReuseLastNonEmptyPage =\n !!lastNonEmptyPageTable &&\n lastNonEmptyPageTable.datasetId === pageDatasetId;\n const canShowStableEmpty =\n !page.isLoading &&\n !isRowDisplayStale &&\n (!page.pageTable || page.pageTable.numRows === 0);\n const showStableEmpty = useDebounce(canShowStableEmpty, 120);\n\n if (hasCurrentRows || !canReuseLastNonEmptyPage) {\n return page.pageTable;\n }\n\n return showStableEmpty ? page.pageTable : lastNonEmptyPageTable.pageTable;\n}\n\nfunction getTableReference(table: DataTable): string {\n return [table.table.database, table.table.schema, table.table.table]\n .filter((part): part is string => Boolean(part))\n .join('.');\n}\n\n/**\n * Aggregates Mosaic-backed schema, rows, counts, and summaries into the stable\n * public dataTableExplorer API consumed by the React table UI.\n */\nexport function useDataTableExplorer(\n options: DataTableExplorerOptions,\n): UseDataTableExplorerReturn {\n const {\n categoryLimit = 20,\n columns,\n initialSorting = [],\n pageSize = 100,\n selection: providedSelection,\n selectionName,\n summaryBins = 18,\n tableName: table,\n } = options;\n\n const tableName = getTableReference(table);\n\n const connection = useStoreWithMosaic((state) => state.mosaic.connection);\n const {selection, selectionVersion} = useDataTableExplorerSelection({\n selection: providedSelection,\n selectionName,\n });\n const rowSelectionVersion = useDebounce(selectionVersion, 100);\n const {\n filteredCount,\n lastNonEmptyPageTable,\n page,\n pagination,\n dataTableExplorerStore,\n schema: rawSchema,\n setPagination,\n setSorting,\n sorting,\n summaries,\n totalCount,\n } = useDataTableExplorerStoreState({\n initialSorting,\n pageSize,\n });\n const schema =\n rawSchema.tableName === tableName\n ? rawSchema\n : {...rawSchema, fields: [], isLoading: true};\n const {\n baseQuery,\n datasetId,\n fieldNames,\n fields,\n hasFilters,\n pageQuery,\n rowFilter,\n } = useDataTableExplorerQueryState({\n pagination,\n rowSelectionVersion,\n schema,\n selection,\n selectionVersion,\n sorting,\n tableName,\n });\n useDataTableExplorerLifecycles({\n categoryLimit,\n columns,\n connection,\n fieldNames,\n fields,\n pageSize,\n pagination,\n dataTableExplorerStore,\n rowFilter,\n selection,\n selectionVersion,\n sorting,\n summaryBins,\n tableName,\n });\n const dataTableExplorerColumns = useDataTableExplorerColumns({\n fields,\n summaries,\n });\n const {isLoading, tableError} = useDataTableExplorerStatus({\n fields,\n filteredCount,\n page,\n schema,\n summaries,\n totalCount,\n });\n const visiblePage = useDataTableExplorerVisiblePageState({\n lastNonEmptyPageTable,\n page,\n pageDatasetId: datasetId,\n rowSelectionVersion,\n selectionVersion,\n });\n\n return {\n columns: dataTableExplorerColumns,\n filteredRowCount: filteredCount.count,\n hasFilters,\n isLoading,\n pageQuery,\n pageTable: visiblePage,\n pagination,\n reset: () => selection.reset(),\n selection,\n setPagination,\n setSorting,\n sorting,\n sql: baseQuery.toString(),\n tableError,\n totalRowCount: totalCount.count,\n };\n}\n"]}
1
+ {"version":3,"file":"useDataTableExplorer.js","sourceRoot":"","sources":["../../src/data-table-explorer/useDataTableExplorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAKlD,OAAO,EAAC,6BAA6B,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAC,8BAA8B,EAAC,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAC,8BAA8B,EAAC,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAC,8BAA8B,EAAC,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAC,2BAA2B,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAC,0BAA0B,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAC,+BAA+B,EAAC,MAAM,yCAAyC,CAAC;AACxF,OAAO,EACL,6BAA6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QAAQ,EAAE;QACzB,UAAU;QACV,aAAa,EAAE,UAAU,CAAC,KAAK;KAChC,CAAC;AACJ,CAAC","sourcesContent":["import {useDebounce} from '@sqlrooms/ui';\nimport {useMemo} from 'react';\nimport {useStoreWithMosaic} from '../MosaicSlice';\nimport type {\n DataTableExplorerOptions,\n UseDataTableExplorerReturn,\n} from './types';\nimport {useDataTableExplorerSelection} from './hooks/useDataTableExplorerSelection';\nimport {useDataTableExplorerStoreState} from './hooks/useDataTableExplorerStoreState';\nimport {useDataTableExplorerQueryState} from './hooks/useDataTableExplorerQueryState';\nimport {useDataTableExplorerLifecycles} from './hooks/useDataTableExplorerLifecycles';\nimport {useDataTableExplorerColumns} from './hooks/useDataTableExplorerColumns';\nimport {useDataTableExplorerStatus} from './hooks/useDataTableExplorerStatus';\nimport {useDataTableExplorerVisiblePage} from './hooks/useDataTableExplorerVisiblePage';\nimport {\n getMosaicRawSqlTableReference,\n getMosaicSqlTableReference,\n getMosaicTableIdentity,\n} from '../mosaicTableReference';\n\n/**\n * Aggregates Mosaic-backed schema, rows, counts, and summaries into the stable\n * public dataTableExplorer API consumed by the React table UI.\n */\nexport function useDataTableExplorer(\n options: DataTableExplorerOptions,\n): UseDataTableExplorerReturn {\n const {\n categoryLimit = 20,\n columns,\n initialSorting = [],\n pageSize = 100,\n selection: providedSelection,\n selectionName,\n summaryBins = 18,\n tableName: table,\n } = options;\n\n const tableIdentity = useMemo(() => getMosaicTableIdentity(table), [table]);\n const tableName = useMemo(\n () => getMosaicRawSqlTableReference(table),\n [table],\n );\n const tableReference = useMemo(\n () => getMosaicSqlTableReference(table),\n [table],\n );\n\n const connection = useStoreWithMosaic((state) => state.mosaic.connection);\n const {selection, selectionVersion} = useDataTableExplorerSelection({\n selection: providedSelection,\n selectionName,\n });\n const rowSelectionVersion = useDebounce(selectionVersion, 100);\n const {\n client,\n filteredCount,\n lastNonEmptyPageTable,\n page,\n pagination,\n dataTableExplorerStore,\n schema: rawSchema,\n setPagination,\n setSorting,\n sorting,\n summaries,\n totalCount,\n } = useDataTableExplorerStoreState({\n initialSorting,\n pageSize,\n });\n const schema =\n rawSchema.tableName === tableIdentity\n ? rawSchema\n : {...rawSchema, fields: [], isLoading: true};\n const {\n baseQuery,\n datasetId,\n fieldNames,\n fields,\n hasFilters,\n pageQuery,\n rowFilter,\n } = useDataTableExplorerQueryState({\n pagination,\n rowSelectionVersion,\n schema,\n selection,\n selectionVersion,\n sorting,\n tableIdentity,\n tableReference,\n });\n useDataTableExplorerLifecycles({\n categoryLimit,\n columns,\n connection,\n fieldNames,\n fields,\n pageSize,\n pagination,\n dataTableExplorerStore,\n rowFilter,\n selection,\n selectionVersion,\n sorting,\n summaryBins,\n tableIdentity,\n tableName,\n tableReference,\n });\n const dataTableExplorerColumns = useDataTableExplorerColumns({\n fields,\n summaries,\n });\n const {isLoading, tableError} = useDataTableExplorerStatus({\n filteredCount,\n page,\n schema,\n summaries,\n totalCount,\n });\n const visiblePage = useDataTableExplorerVisiblePage({\n lastNonEmptyPageTable,\n page,\n pageDatasetId: datasetId,\n rowSelectionVersion,\n selectionVersion,\n });\n\n return {\n client,\n columns: dataTableExplorerColumns,\n filteredRowCount: filteredCount.count,\n hasFilters,\n isLoading,\n pageQuery,\n pageTable: visiblePage,\n pagination,\n reset: () => selection.reset(),\n selection,\n setPagination,\n setSorting,\n sorting,\n sql: baseQuery.toString(),\n tableError,\n totalRowCount: totalCount.count,\n };\n}\n"]}