@perses-dev/dashboards 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/cjs/components/Dashboard.js +6 -11
  2. package/dist/cjs/components/DashboardToolbar.js +12 -6
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +7 -15
  4. package/dist/cjs/components/GridLayout/GridLayout.js +27 -22
  5. package/dist/cjs/components/GridLayout/GridTitle.js +27 -7
  6. package/dist/cjs/components/Panel/DeletePanelDialog.js +95 -0
  7. package/dist/cjs/components/Panel/Panel.js +12 -10
  8. package/dist/cjs/components/Panel/Panel.test.js +15 -6
  9. package/dist/cjs/components/Panel/PanelContent.js +3 -2
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
  11. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -13
  12. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +87 -39
  13. package/dist/cjs/components/PanelDrawer/PanelPreview.js +54 -0
  14. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +88 -0
  15. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -118
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -36
  17. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  18. package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
  20. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
  21. package/dist/cjs/components/Variables/Variable.js +20 -11
  22. package/dist/cjs/components/Variables/VariableEditor.js +240 -0
  23. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
  24. package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
  25. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
  26. package/dist/cjs/components/Variables/VariableList.js +49 -69
  27. package/dist/cjs/components/Variables/index.js +1 -0
  28. package/dist/cjs/components/index.js +1 -0
  29. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +82 -0
  30. package/dist/cjs/context/DashboardProvider/common.js +18 -0
  31. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +164 -0
  32. package/dist/cjs/context/DashboardProvider/index.js +29 -0
  33. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +175 -0
  34. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
  35. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +208 -0
  36. package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
  37. package/dist/cjs/context/TemplateVariableProvider.js +8 -1
  38. package/dist/cjs/context/TimeRangeProvider.js +20 -44
  39. package/dist/cjs/context/index.js +1 -3
  40. package/dist/cjs/context/useDashboardSpec.js +61 -0
  41. package/dist/cjs/index.js +1 -0
  42. package/dist/cjs/test/render.js +25 -5
  43. package/dist/cjs/test/setup-tests.js +4 -1
  44. package/dist/cjs/test/testDashboard.js +24 -11
  45. package/dist/cjs/utils/index.js +28 -0
  46. package/dist/cjs/utils/time-range-params.js +145 -0
  47. package/dist/cjs/views/ViewDashboard/DashboardApp.js +5 -8
  48. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
  49. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +114 -0
  50. package/dist/components/Dashboard.d.ts +1 -4
  51. package/dist/components/Dashboard.d.ts.map +1 -1
  52. package/dist/components/Dashboard.js +7 -12
  53. package/dist/components/Dashboard.js.map +1 -1
  54. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  55. package/dist/components/DashboardToolbar.js +14 -8
  56. package/dist/components/DashboardToolbar.js.map +1 -1
  57. package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
  58. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  59. package/dist/components/GridLayout/GridItemContent.js +7 -15
  60. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  61. package/dist/components/GridLayout/GridLayout.d.ts +2 -4
  62. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  63. package/dist/components/GridLayout/GridLayout.js +28 -23
  64. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  65. package/dist/components/GridLayout/GridTitle.d.ts +2 -1
  66. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  67. package/dist/components/GridLayout/GridTitle.js +28 -8
  68. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  69. package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
  70. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
  71. package/dist/components/Panel/DeletePanelDialog.js +84 -0
  72. package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
  73. package/dist/components/Panel/Panel.d.ts +2 -2
  74. package/dist/components/Panel/Panel.d.ts.map +1 -1
  75. package/dist/components/Panel/Panel.js +13 -11
  76. package/dist/components/Panel/Panel.js.map +1 -1
  77. package/dist/components/Panel/Panel.test.d.ts +1 -1
  78. package/dist/components/Panel/Panel.test.d.ts.map +1 -1
  79. package/dist/components/Panel/Panel.test.js +10 -6
  80. package/dist/components/Panel/Panel.test.js.map +1 -1
  81. package/dist/components/Panel/PanelContent.d.ts +4 -1
  82. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  83. package/dist/components/Panel/PanelContent.js +3 -2
  84. package/dist/components/Panel/PanelContent.js.map +1 -1
  85. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  86. package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
  87. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  88. package/dist/components/PanelDrawer/PanelDrawer.test.js +9 -13
  89. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  90. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  91. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  92. package/dist/components/PanelDrawer/PanelEditorForm.js +89 -41
  93. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  94. package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
  95. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
  96. package/dist/components/PanelDrawer/PanelPreview.js +48 -0
  97. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
  98. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
  99. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  100. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +77 -0
  101. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  102. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
  103. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  104. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -119
  105. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  106. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +20 -35
  107. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  108. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  109. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  110. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  111. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  112. package/dist/components/PanelGroupDialog/index.d.ts +3 -0
  113. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  114. package/dist/components/PanelGroupDialog/index.js +16 -0
  115. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  116. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  117. package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
  118. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  119. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
  120. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  121. package/dist/components/Variables/Variable.js +22 -13
  122. package/dist/components/Variables/Variable.js.map +1 -1
  123. package/dist/components/Variables/VariableEditor.d.ts +8 -0
  124. package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
  125. package/dist/components/Variables/VariableEditor.js +229 -0
  126. package/dist/components/Variables/VariableEditor.js.map +1 -0
  127. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
  128. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
  129. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
  130. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  131. package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
  132. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
  133. package/dist/components/Variables/VariableEditorForm/index.js +15 -0
  134. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  135. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
  136. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
  137. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
  138. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  139. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  140. package/dist/components/Variables/VariableList.js +47 -72
  141. package/dist/components/Variables/VariableList.js.map +1 -1
  142. package/dist/components/Variables/index.d.ts +1 -0
  143. package/dist/components/Variables/index.d.ts.map +1 -1
  144. package/dist/components/Variables/index.js +1 -0
  145. package/dist/components/Variables/index.js.map +1 -1
  146. package/dist/components/index.d.ts +1 -0
  147. package/dist/components/index.d.ts.map +1 -1
  148. package/dist/components/index.js +1 -0
  149. package/dist/components/index.js.map +1 -1
  150. package/dist/context/DashboardProvider/DashboardProvider.d.ts +25 -0
  151. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
  152. package/dist/context/DashboardProvider/DashboardProvider.js +64 -0
  153. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
  154. package/dist/context/DashboardProvider/common.d.ts +5 -0
  155. package/dist/context/DashboardProvider/common.d.ts.map +1 -0
  156. package/dist/context/DashboardProvider/common.js +17 -0
  157. package/dist/context/DashboardProvider/common.js.map +1 -0
  158. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +74 -0
  159. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
  160. package/dist/context/DashboardProvider/dashboard-provider-api.js +163 -0
  161. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  162. package/dist/context/DashboardProvider/index.d.ts +5 -0
  163. package/dist/context/DashboardProvider/index.d.ts.map +1 -0
  164. package/dist/context/DashboardProvider/index.js +16 -0
  165. package/dist/context/DashboardProvider/index.js.map +1 -0
  166. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +85 -0
  167. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  168. package/dist/context/DashboardProvider/panel-editor-slice.js +171 -0
  169. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  170. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
  171. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  172. package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
  173. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  174. package/dist/context/DashboardProvider/panel-group-slice.d.ts +80 -0
  175. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
  176. package/dist/context/DashboardProvider/panel-group-slice.js +204 -0
  177. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
  178. package/dist/context/DatasourceStoreProvider.d.ts +10 -2
  179. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  180. package/dist/context/DatasourceStoreProvider.js +111 -9
  181. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  182. package/dist/context/TemplateVariableProvider.d.ts +2 -0
  183. package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
  184. package/dist/context/TemplateVariableProvider.js +8 -1
  185. package/dist/context/TemplateVariableProvider.js.map +1 -1
  186. package/dist/context/TimeRangeProvider.d.ts +9 -2
  187. package/dist/context/TimeRangeProvider.d.ts.map +1 -1
  188. package/dist/context/TimeRangeProvider.js +15 -43
  189. package/dist/context/TimeRangeProvider.js.map +1 -1
  190. package/dist/context/index.d.ts +1 -3
  191. package/dist/context/index.d.ts.map +1 -1
  192. package/dist/context/index.js +1 -3
  193. package/dist/context/index.js.map +1 -1
  194. package/dist/context/useDashboardSpec.d.ts +3 -0
  195. package/dist/context/useDashboardSpec.d.ts.map +1 -0
  196. package/dist/context/useDashboardSpec.js +55 -0
  197. package/dist/context/useDashboardSpec.js.map +1 -0
  198. package/dist/index.d.ts +1 -0
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +1 -0
  201. package/dist/index.js.map +1 -1
  202. package/dist/test/plugin-registry.d.ts +2 -2
  203. package/dist/test/plugin-registry.d.ts.map +1 -1
  204. package/dist/test/plugin-registry.js.map +1 -1
  205. package/dist/test/render.d.ts +2 -1
  206. package/dist/test/render.d.ts.map +1 -1
  207. package/dist/test/render.js +25 -5
  208. package/dist/test/render.js.map +1 -1
  209. package/dist/test/setup-tests.d.ts.map +1 -1
  210. package/dist/test/setup-tests.js +4 -0
  211. package/dist/test/setup-tests.js.map +1 -1
  212. package/dist/test/testDashboard.d.ts.map +1 -1
  213. package/dist/test/testDashboard.js +24 -11
  214. package/dist/test/testDashboard.js.map +1 -1
  215. package/dist/utils/index.d.ts +2 -0
  216. package/dist/utils/index.d.ts.map +1 -0
  217. package/dist/utils/index.js +15 -0
  218. package/dist/utils/index.js.map +1 -0
  219. package/dist/utils/time-range-params.d.ts +25 -0
  220. package/dist/utils/time-range-params.d.ts.map +1 -0
  221. package/dist/utils/time-range-params.js +137 -0
  222. package/dist/utils/time-range-params.js.map +1 -0
  223. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  224. package/dist/views/ViewDashboard/DashboardApp.js +6 -9
  225. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  226. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  227. package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
  228. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  229. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
  230. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
  231. package/dist/views/ViewDashboard/tests/panelGroups.test.js +107 -0
  232. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
  233. package/package.json +5 -4
  234. package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
  235. package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
  236. package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
  237. package/dist/cjs/context/DashboardAppSlice.js +0 -57
  238. package/dist/cjs/context/DashboardProvider.js +0 -128
  239. package/dist/cjs/context/LayoutsSlice.js +0 -55
  240. package/dist/cjs/context/QueryStringProvider.js +0 -89
  241. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
  242. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
  243. package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
  244. package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
  245. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
  246. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
  247. package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
  248. package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
  249. package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
  250. package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
  251. package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
  252. package/dist/components/PanelDrawer/panel-editor-model.js.map +0 -1
  253. package/dist/context/DashboardAppSlice.d.ts +0 -26
  254. package/dist/context/DashboardAppSlice.d.ts.map +0 -1
  255. package/dist/context/DashboardAppSlice.js +0 -45
  256. package/dist/context/DashboardAppSlice.js.map +0 -1
  257. package/dist/context/DashboardProvider.d.ts +0 -36
  258. package/dist/context/DashboardProvider.d.ts.map +0 -1
  259. package/dist/context/DashboardProvider.js +0 -107
  260. package/dist/context/DashboardProvider.js.map +0 -1
  261. package/dist/context/LayoutsSlice.d.ts +0 -12
  262. package/dist/context/LayoutsSlice.d.ts.map +0 -1
  263. package/dist/context/LayoutsSlice.js +0 -43
  264. package/dist/context/LayoutsSlice.js.map +0 -1
  265. package/dist/context/QueryStringProvider.d.ts +0 -13
  266. package/dist/context/QueryStringProvider.d.ts.map +0 -1
  267. package/dist/context/QueryStringProvider.js +0 -40
  268. package/dist/context/QueryStringProvider.js.map +0 -1
@@ -0,0 +1,164 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ useEditMode: ()=>useEditMode,
25
+ useDashboardActions: ()=>useDashboardActions,
26
+ usePanelGroupIds: ()=>usePanelGroupIds,
27
+ useListPanelGroups: ()=>useListPanelGroups,
28
+ usePanelGroup: ()=>usePanelGroup,
29
+ usePanelGroupActions: ()=>usePanelGroupActions,
30
+ usePanelGroupEditor: ()=>usePanelGroupEditor,
31
+ useDeletePanelGroupDialog: ()=>useDeletePanelGroupDialog,
32
+ usePanel: ()=>usePanel,
33
+ usePanelActions: ()=>usePanelActions,
34
+ usePanelEditor: ()=>usePanelEditor,
35
+ useDeletePanelDialog: ()=>useDeletePanelDialog,
36
+ useDefaultTimeRange: ()=>useDefaultTimeRange
37
+ });
38
+ const _core = require("@perses-dev/core");
39
+ const _react = require("react");
40
+ const _dashboardProvider = require("./DashboardProvider");
41
+ function useEditMode() {
42
+ return (0, _dashboardProvider.useDashboardStore)(({ isEditMode , setEditMode })=>({
43
+ isEditMode,
44
+ setEditMode
45
+ }));
46
+ }
47
+ function useDashboardActions() {
48
+ const save = (0, _dashboardProvider.useDashboardStore)((store)=>store.save);
49
+ const reset = (0, _dashboardProvider.useDashboardStore)((store)=>store.reset);
50
+ const openAddPanelGroup = (0, _dashboardProvider.useDashboardStore)((store)=>store.openAddPanelGroup);
51
+ const openAddPanel = (0, _dashboardProvider.useDashboardStore)((store)=>store.openAddPanel);
52
+ return {
53
+ save,
54
+ reset,
55
+ openAddPanelGroup,
56
+ openAddPanel: ()=>openAddPanel(undefined)
57
+ };
58
+ }
59
+ function usePanelGroupIds() {
60
+ return (0, _dashboardProvider.useDashboardStore)((store)=>store.panelGroupIdOrder);
61
+ }
62
+ function useListPanelGroups() {
63
+ const panelGroupIds = usePanelGroupIds();
64
+ const panelGroups = (0, _dashboardProvider.useDashboardStore)((store)=>store.panelGroups);
65
+ return (0, _react.useMemo)(()=>{
66
+ return panelGroupIds.map((id)=>{
67
+ const group = panelGroups[id];
68
+ if (group === undefined) {
69
+ throw new Error(`Invalid panel group Id found ${id}`);
70
+ }
71
+ return group;
72
+ });
73
+ }, [
74
+ panelGroupIds,
75
+ panelGroups
76
+ ]);
77
+ }
78
+ function usePanelGroup(panelGroupId) {
79
+ const panelGroup = (0, _dashboardProvider.useDashboardStore)((store)=>store.panelGroups[panelGroupId]);
80
+ if (panelGroup === undefined) {
81
+ throw new Error(`Panel group with Id ${panelGroupId} was not found`);
82
+ }
83
+ return panelGroup;
84
+ }
85
+ function usePanelGroupActions(panelGroupId) {
86
+ const { moveUp , moveDown } = useMovePanelGroup(panelGroupId);
87
+ const openEditPanelGroup = (0, _dashboardProvider.useDashboardStore)((store)=>store.openEditPanelGroup);
88
+ const deletePanelGroup = (0, _dashboardProvider.useDashboardStore)((store)=>store.openDeletePanelGroupDialog);
89
+ const openAddPanel = (0, _dashboardProvider.useDashboardStore)((store)=>store.openAddPanel);
90
+ return {
91
+ openEditPanelGroup: ()=>openEditPanelGroup(panelGroupId),
92
+ deletePanelGroup: ()=>deletePanelGroup(panelGroupId),
93
+ openAddPanel: ()=>openAddPanel(panelGroupId),
94
+ moveUp,
95
+ moveDown
96
+ };
97
+ }
98
+ /**
99
+ * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be
100
+ * moved in that direction.
101
+ */ function useMovePanelGroup(panelGroupId) {
102
+ const currentIndex = (0, _dashboardProvider.useDashboardStore)((store)=>store.panelGroupIdOrder.findIndex((id)=>id === panelGroupId));
103
+ const panelGroupsLength = (0, _dashboardProvider.useDashboardStore)((store)=>store.panelGroupIdOrder.length);
104
+ const swapPanelGroups = (0, _dashboardProvider.useDashboardStore)((store)=>store.swapPanelGroups);
105
+ if (currentIndex < 0) {
106
+ throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);
107
+ }
108
+ const moveUp = ()=>swapPanelGroups(currentIndex, currentIndex - 1);
109
+ const moveDown = ()=>swapPanelGroups(currentIndex, currentIndex + 1);
110
+ return {
111
+ moveUp: currentIndex > 0 ? moveUp : undefined,
112
+ moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined
113
+ };
114
+ }
115
+ function usePanelGroupEditor() {
116
+ return (0, _dashboardProvider.useDashboardStore)((store)=>store.panelGroupEditor);
117
+ }
118
+ function useDeletePanelGroupDialog() {
119
+ return (0, _dashboardProvider.useDashboardStore)(({ deletePanelGroupDialog , openDeletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup })=>({
120
+ deletePanelGroupDialog,
121
+ openDeletePanelGroupDialog,
122
+ closeDeletePanelGroupDialog,
123
+ deletePanelGroup
124
+ }));
125
+ }
126
+ function usePanel(panelGroupItemId) {
127
+ const { panelGroupId , itemIndex } = panelGroupItemId;
128
+ const panel = (0, _dashboardProvider.useDashboardStore)((store)=>{
129
+ var ref, ref1;
130
+ const panelRef = (ref1 = (ref = store.panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.items[itemIndex]) === null || ref1 === void 0 ? void 0 : ref1.content;
131
+ if (panelRef === undefined) return;
132
+ const panelKey = (0, _core.getPanelKeyFromRef)(panelRef);
133
+ return store.panels[panelKey];
134
+ });
135
+ if (panel === undefined) {
136
+ throw new Error(`Could not find panel for Id ${panelGroupItemId}`);
137
+ }
138
+ return panel;
139
+ }
140
+ function usePanelActions(panelGroupItemId) {
141
+ const openEditPanel = (0, _dashboardProvider.useDashboardStore)((store)=>store.openEditPanel);
142
+ const openDeletePanelDialog = (0, _dashboardProvider.useDashboardStore)((store)=>store.openDeletePanelDialog);
143
+ return {
144
+ openEditPanel: ()=>openEditPanel(panelGroupItemId),
145
+ openDeletePanelDialog: ()=>openDeletePanelDialog(panelGroupItemId)
146
+ };
147
+ }
148
+ function usePanelEditor() {
149
+ return (0, _dashboardProvider.useDashboardStore)((store)=>store.panelEditor);
150
+ }
151
+ function useDeletePanelDialog() {
152
+ const deletePanelDialog = (0, _dashboardProvider.useDashboardStore)((store)=>store.deletePanelDialog);
153
+ // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself
154
+ const deletePanels = (0, _dashboardProvider.useDashboardStore)((store)=>store.deletePanels);
155
+ const closeDeletePanelDialog = (0, _dashboardProvider.useDashboardStore)((store)=>store.closeDeletePanelDialog);
156
+ return {
157
+ deletePanelDialog,
158
+ deletePanels,
159
+ closeDeletePanelDialog
160
+ };
161
+ }
162
+ function useDefaultTimeRange() {
163
+ return (0, _dashboardProvider.useDashboardStore)((state)=>state.defaultTimeRange);
164
+ }
@@ -0,0 +1,29 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./dashboard-provider-api"), exports);
18
+ _exportStar(require("./DashboardProvider"), exports);
19
+ function _exportStar(from, to) {
20
+ Object.keys(from).forEach(function(k) {
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ });
28
+ return from;
29
+ }
@@ -0,0 +1,175 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "createPanelEditorSlice", {
18
+ enumerable: true,
19
+ get: ()=>createPanelEditorSlice
20
+ });
21
+ const _functions = require("../../utils/functions");
22
+ function createPanelEditorSlice(panels) {
23
+ // Return the state creator function for Zustand that uses the panels provided as intitial state
24
+ return (set, get)=>{
25
+ return {
26
+ previousPanels: panels,
27
+ panels,
28
+ panelEditor: undefined,
29
+ savePanels () {
30
+ set((state)=>{
31
+ state.previousPanels = state.panels;
32
+ });
33
+ },
34
+ resetPanels () {
35
+ set((state)=>{
36
+ state.panels = state.previousPanels;
37
+ });
38
+ },
39
+ openEditPanel (item) {
40
+ const { panels , getPanelKey } = get();
41
+ // Ask the layout store for the panel key at that location
42
+ const panelKey = getPanelKey(item);
43
+ // Find the panel to edit
44
+ const panelToEdit = panels[panelKey];
45
+ if (panelToEdit === undefined) {
46
+ throw new Error(`Cannot find Panel with key '${panelKey}'`);
47
+ }
48
+ var _description;
49
+ const editorState = {
50
+ mode: 'Edit',
51
+ initialValues: {
52
+ name: panelToEdit.spec.display.name,
53
+ description: (_description = panelToEdit.spec.display.description) !== null && _description !== void 0 ? _description : '',
54
+ groupId: item.panelGroupId,
55
+ kind: panelToEdit.spec.plugin.kind,
56
+ spec: panelToEdit.spec.plugin.spec
57
+ },
58
+ applyChanges: (next)=>{
59
+ const panelDefinititon = createPanelDefinitionFromEditorValues(next);
60
+ set((state)=>{
61
+ state.panels[panelKey] = panelDefinititon;
62
+ });
63
+ // Move the panel to another group if it changed
64
+ if (next.groupId !== item.panelGroupId) {
65
+ get().movePanelToGroup(item, next.groupId);
66
+ }
67
+ },
68
+ close: ()=>{
69
+ set((state)=>{
70
+ state.panelEditor = undefined;
71
+ });
72
+ }
73
+ };
74
+ // Open the editor with the new state
75
+ set((state)=>{
76
+ state.panelEditor = editorState;
77
+ });
78
+ },
79
+ openAddPanel (panelGroupId) {
80
+ // If a panel group isn't supplied, add to the first group
81
+ if (panelGroupId === undefined) {
82
+ const firstGroupId = get().panelGroupIdOrder[0];
83
+ if (firstGroupId === undefined) {
84
+ throw new Error('No panel groups to add a panel to');
85
+ }
86
+ panelGroupId = firstGroupId;
87
+ }
88
+ const editorState = {
89
+ mode: 'Add',
90
+ initialValues: {
91
+ name: '',
92
+ description: '',
93
+ groupId: panelGroupId,
94
+ // TODO: If we knew what plugins were available (and how to create the initial spec), we might be able to
95
+ // set a smarter default here?
96
+ kind: '',
97
+ spec: {}
98
+ },
99
+ applyChanges: (next)=>{
100
+ const panelDef = createPanelDefinitionFromEditorValues(next);
101
+ const panelKey = (0, _functions.removeWhiteSpacesAndSpecialCharacters)(next.name);
102
+ set((state)=>{
103
+ state.panels[panelKey] = panelDef;
104
+ });
105
+ get().addPanelToGroup(panelKey, next.groupId);
106
+ },
107
+ close: ()=>{
108
+ set((state)=>{
109
+ state.panelEditor = undefined;
110
+ });
111
+ }
112
+ };
113
+ // Open the editor with the new state
114
+ set((state)=>{
115
+ state.panelEditor = editorState;
116
+ });
117
+ },
118
+ deletePanels (items) {
119
+ const { mapPanelToPanelGroups , deletePanelInPanelGroup , getPanelKey } = get();
120
+ const map = mapPanelToPanelGroups();
121
+ // get panel key first before deleting panel from panel group since getPanelKey relies on index
122
+ const panels = items.map((panel)=>{
123
+ return {
124
+ ...panel,
125
+ panelKey: getPanelKey(panel)
126
+ };
127
+ });
128
+ panels.forEach(({ panelKey , ...panel })=>{
129
+ var ref;
130
+ deletePanelInPanelGroup(panel);
131
+ // make sure panel is only referenced in one panel group before deleting it from state.panels
132
+ if (map[panelKey] && ((ref = map[panelKey]) === null || ref === void 0 ? void 0 : ref.length) === 1) {
133
+ set((state)=>{
134
+ delete state.panels[panelKey];
135
+ });
136
+ }
137
+ });
138
+ },
139
+ openDeletePanelDialog (item) {
140
+ const { panels , getPanelKey , panelGroups } = get();
141
+ const panelKey = getPanelKey(item);
142
+ set((state)=>{
143
+ var ref, ref1;
144
+ var _name, ref2;
145
+ state.deletePanelDialog = {
146
+ panelGroupItemId: item,
147
+ panelName: (_name = (ref = panels[panelKey]) === null || ref === void 0 ? void 0 : ref.spec.display.name) !== null && _name !== void 0 ? _name : '',
148
+ panelGroupName: (ref2 = (ref1 = panelGroups[item.panelGroupId]) === null || ref1 === void 0 ? void 0 : ref1.title) !== null && ref2 !== void 0 ? ref2 : ''
149
+ };
150
+ });
151
+ },
152
+ closeDeletePanelDialog () {
153
+ set((state)=>{
154
+ state.deletePanelDialog = undefined;
155
+ });
156
+ }
157
+ };
158
+ };
159
+ }
160
+ // Helper to create PanelDefinitions when saving
161
+ function createPanelDefinitionFromEditorValues(editorValues) {
162
+ return {
163
+ kind: 'Panel',
164
+ spec: {
165
+ display: {
166
+ name: editorValues.name,
167
+ description: editorValues.description !== '' ? editorValues.description : undefined
168
+ },
169
+ plugin: {
170
+ kind: editorValues.kind,
171
+ spec: editorValues.spec
172
+ }
173
+ }
174
+ };
175
+ }
@@ -0,0 +1,102 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "createPanelGroupEditorSlice", {
18
+ enumerable: true,
19
+ get: ()=>createPanelGroupEditorSlice
20
+ });
21
+ const createPanelGroupEditorSlice = (set, get)=>({
22
+ panelGroupEditor: undefined,
23
+ openAddPanelGroup: ()=>{
24
+ // Create the editor state
25
+ const editor = {
26
+ mode: 'Add',
27
+ initialValues: {
28
+ title: '',
29
+ isCollapsed: false
30
+ },
31
+ applyChanges (next) {
32
+ const newGroup = {
33
+ id: get().createPanelGroupId(),
34
+ items: [],
35
+ ...next
36
+ };
37
+ set((draft)=>{
38
+ draft.panelGroups[newGroup.id] = newGroup;
39
+ draft.panelGroupIdOrder.unshift(newGroup.id);
40
+ });
41
+ },
42
+ close () {
43
+ set((draft)=>{
44
+ draft.panelGroupEditor = undefined;
45
+ });
46
+ }
47
+ };
48
+ // Open the editor
49
+ set((draft)=>{
50
+ draft.panelGroupEditor = editor;
51
+ });
52
+ },
53
+ openEditPanelGroup: (panelGroupId)=>{
54
+ const existingGroup = get().panelGroups[panelGroupId];
55
+ if (existingGroup === undefined) {
56
+ throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
57
+ }
58
+ var _title;
59
+ // Create the editor state
60
+ const editor = {
61
+ mode: 'Edit',
62
+ initialValues: {
63
+ title: (_title = existingGroup.title) !== null && _title !== void 0 ? _title : '',
64
+ isCollapsed: existingGroup.isCollapsed
65
+ },
66
+ applyChanges (next) {
67
+ set((draft)=>{
68
+ const group = draft.panelGroups[panelGroupId];
69
+ if (group === undefined) {
70
+ throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
71
+ }
72
+ group.title = next.title;
73
+ group.isCollapsed = next.isCollapsed;
74
+ });
75
+ },
76
+ close () {
77
+ set((draft)=>{
78
+ draft.panelGroupEditor = undefined;
79
+ });
80
+ }
81
+ };
82
+ // Open the editor
83
+ set((draft)=>{
84
+ draft.panelGroupEditor = editor;
85
+ });
86
+ },
87
+ openDeletePanelGroupDialog: (panelGroupId)=>{
88
+ const panelGroup = get().panelGroups[panelGroupId];
89
+ if (panelGroup === undefined) {
90
+ throw new Error(`Panel group with Id ${panelGroupId} not found`);
91
+ }
92
+ set((state)=>{
93
+ state.deletePanelGroupDialog = {
94
+ panelGroupId,
95
+ panelGroupName: panelGroup.title
96
+ };
97
+ });
98
+ },
99
+ closeDeletePanelGroupDialog: ()=>set((state)=>{
100
+ state.deletePanelGroupDialog = undefined;
101
+ })
102
+ });
@@ -0,0 +1,208 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "createPanelGroupSlice", {
18
+ enumerable: true,
19
+ get: ()=>createPanelGroupSlice
20
+ });
21
+ const _core = require("@perses-dev/core");
22
+ function createPanelGroupSlice(layouts) {
23
+ // Helper function for generating unique IDs for a PanelGroup
24
+ let id = -1;
25
+ function createPanelGroupId() {
26
+ id++;
27
+ return id;
28
+ }
29
+ // Convert the initial layouts from the JSON to panel groups and keep track of the order
30
+ const panelGroups = {};
31
+ const panelGroupIdOrder = [];
32
+ for (const layout of layouts){
33
+ var ref, ref1, ref2;
34
+ const id1 = createPanelGroupId();
35
+ panelGroups[id1] = {
36
+ id: id1,
37
+ items: layout.spec.items,
38
+ isCollapsed: ((ref = layout.spec.display) === null || ref === void 0 ? void 0 : (ref1 = ref.collapse) === null || ref1 === void 0 ? void 0 : ref1.open) === false,
39
+ title: (ref2 = layout.spec.display) === null || ref2 === void 0 ? void 0 : ref2.title
40
+ };
41
+ panelGroupIdOrder.push(id1);
42
+ }
43
+ // Return the state creator function for Zustand
44
+ return (set, get)=>{
45
+ return {
46
+ panelGroups,
47
+ panelGroupIdOrder,
48
+ previousPanelGroupStates: {
49
+ panelGroups,
50
+ panelGroupIdOrder
51
+ },
52
+ // TODO: Reorder init logic so this isn't exposed
53
+ createPanelGroupId,
54
+ savePanelGroups () {
55
+ set((state)=>{
56
+ state.previousPanelGroupStates = {
57
+ panelGroups: state.panelGroups,
58
+ panelGroupIdOrder: state.panelGroupIdOrder
59
+ };
60
+ });
61
+ },
62
+ resetPanelGroups () {
63
+ set((state)=>{
64
+ state.panelGroups = state.previousPanelGroupStates.panelGroups;
65
+ state.panelGroupIdOrder = state.previousPanelGroupStates.panelGroupIdOrder;
66
+ });
67
+ },
68
+ getPanelKey ({ panelGroupId , itemIndex }) {
69
+ const { panelGroups } = get();
70
+ const group = findGroup(panelGroups, panelGroupId);
71
+ const item = findItem(group, itemIndex);
72
+ return (0, _core.getPanelKeyFromRef)(item.content);
73
+ },
74
+ addPanelToGroup (panelKey, panelGroupId) {
75
+ const { panelGroups } = get();
76
+ const group = findGroup(panelGroups, panelGroupId);
77
+ const gridItem = {
78
+ x: 0,
79
+ y: getYForNewRow(group),
80
+ width: 12,
81
+ height: 6,
82
+ content: (0, _core.createPanelRef)(panelKey)
83
+ };
84
+ set((state)=>{
85
+ var ref;
86
+ (ref = state.panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.items.push(gridItem);
87
+ });
88
+ },
89
+ movePanelToGroup ({ panelGroupId , itemIndex }, newPanelGroupId) {
90
+ const { panelGroups } = get();
91
+ // Find the existing item to make sure it exists
92
+ const group = findGroup(panelGroups, panelGroupId);
93
+ const item = findItem(group, itemIndex);
94
+ // Find the new group and figure out where a new row should go
95
+ const newGroup = findGroup(panelGroups, newPanelGroupId);
96
+ const newGroupY = getYForNewRow(newGroup);
97
+ set((state)=>{
98
+ var // Remove the item from its current group
99
+ ref, // Add a new item to the new group
100
+ ref1;
101
+ (ref = state.panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.items.splice(itemIndex, 1);
102
+ (ref1 = state.panelGroups[newPanelGroupId]) === null || ref1 === void 0 ? void 0 : ref1.items.push({
103
+ x: 0,
104
+ y: newGroupY,
105
+ width: item.width,
106
+ height: item.height,
107
+ content: item.content
108
+ });
109
+ });
110
+ },
111
+ swapPanelGroups (x, y) {
112
+ set((state)=>{
113
+ if (x < 0 || x >= state.panelGroupIdOrder.length || y < 0 || y >= state.panelGroupIdOrder.length) {
114
+ throw new Error('index out of bound');
115
+ }
116
+ const xPanelGroup = state.panelGroupIdOrder[x];
117
+ const yPanelGroup = state.panelGroupIdOrder[y];
118
+ if (xPanelGroup === undefined || yPanelGroup === undefined) {
119
+ throw new Error('panel group is undefined');
120
+ }
121
+ // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups
122
+ [state.panelGroupIdOrder[x], state.panelGroupIdOrder[y]] = [
123
+ yPanelGroup,
124
+ xPanelGroup
125
+ ];
126
+ });
127
+ },
128
+ deletePanelInPanelGroup ({ panelGroupId , itemIndex }) {
129
+ set((state)=>{
130
+ const group = state.panelGroups[panelGroupId];
131
+ if (group === undefined) {
132
+ throw new Error(`No panel group found: ${panelGroupId}`);
133
+ }
134
+ // remove panel from panel group
135
+ group.items.splice(itemIndex, 1);
136
+ });
137
+ },
138
+ deletePanelGroup (panelGroupId) {
139
+ const { panelGroups , panelGroupIdOrder: panelGroupOrder , deletePanels } = get();
140
+ const group = findGroup(panelGroups, panelGroupId);
141
+ const orderIdx = panelGroupOrder.findIndex((id)=>id === panelGroupId);
142
+ if (orderIdx === -1) {
143
+ throw new Error(`Could not find panel group Id ${panelGroupId} in order array`);
144
+ }
145
+ // remove panels from group first
146
+ const panelsToBeDeleted = [];
147
+ for(let i = 0; i < group.items.length; i++){
148
+ panelsToBeDeleted.push({
149
+ panelGroupId,
150
+ itemIndex: i
151
+ });
152
+ }
153
+ deletePanels(panelsToBeDeleted);
154
+ // remove group from both panelGroups and panelGroupOrder
155
+ set((state)=>{
156
+ state.panelGroupIdOrder.splice(orderIdx, 1);
157
+ delete state.panelGroups[panelGroupId];
158
+ });
159
+ },
160
+ // Return an object that maps each panel to the groups it belongs
161
+ mapPanelToPanelGroups () {
162
+ const map = {}; // { panel key: [group ids] }
163
+ Object.values(get().panelGroups).forEach((group)=>{
164
+ // for each panel in a group, add the group id to map[panelKey]
165
+ group.items.forEach((panel)=>{
166
+ const panelKey = (0, _core.getPanelKeyFromRef)(panel.content);
167
+ if (map[panelKey]) {
168
+ var ref;
169
+ (ref = map[panelKey]) === null || ref === void 0 ? void 0 : ref.push(group.id);
170
+ } else {
171
+ map[panelKey] = [
172
+ group.id
173
+ ];
174
+ }
175
+ });
176
+ });
177
+ return map;
178
+ }
179
+ };
180
+ };
181
+ }
182
+ // Helper to find a group and throw if not found
183
+ function findGroup(panelGroups, groupId) {
184
+ const group = panelGroups[groupId];
185
+ if (group === undefined) {
186
+ throw new Error(`No panel group found for Id ${groupId}`);
187
+ }
188
+ return group;
189
+ }
190
+ // Helper to get an item in a group and throw if not found
191
+ function findItem(group, itemIndex) {
192
+ const item = group.items[itemIndex];
193
+ if (item === undefined) {
194
+ throw new Error(`No grid item found at position ${itemIndex}`);
195
+ }
196
+ return item;
197
+ }
198
+ // Given a Grid, will find the Y coordinate for adding a new row to the grid, taking into account the items present
199
+ function getYForNewRow(group) {
200
+ let newRowY = 0;
201
+ for (const item of group.items){
202
+ const itemMaxY = item.y + item.height;
203
+ if (itemMaxY > newRowY) {
204
+ newRowY = itemMaxY;
205
+ }
206
+ }
207
+ return newRowY;
208
+ }