@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
@@ -14,6 +14,7 @@ export * from './Dashboard';
14
14
  export * from './GridLayout';
15
15
  export * from './Panel';
16
16
  export * from './PanelDrawer';
17
+ export * from './PanelGroupDialog';
17
18
  export * from './TimeRangeControls';
18
19
  export * from './Variables';
19
20
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './Dashboard';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './TimeRangeControls';\nexport * from './Variables';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './Dashboard';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './TimeRangeControls';\nexport * from './Variables';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ import type { StoreApi } from 'zustand';
3
+ import { DashboardSpec, RelativeTimeRange } from '@perses-dev/core';
4
+ import { PanelGroupEditorSlice } from './panel-group-editor-slice';
5
+ import { PanelGroupSlice } from './panel-group-slice';
6
+ import { PanelEditorSlice } from './panel-editor-slice';
7
+ export interface DashboardStoreState extends PanelGroupEditorSlice, PanelGroupSlice, PanelEditorSlice {
8
+ isEditMode: boolean;
9
+ setEditMode: (isEditMode: boolean) => void;
10
+ defaultTimeRange: RelativeTimeRange;
11
+ reset: () => void;
12
+ save: () => void;
13
+ }
14
+ export interface DashboardStoreProps {
15
+ dashboardSpec: DashboardSpec;
16
+ isEditMode?: boolean;
17
+ }
18
+ export interface DashboardProviderProps {
19
+ initialState: DashboardStoreProps;
20
+ children?: React.ReactNode;
21
+ }
22
+ export declare const DashboardContext: import("react").Context<StoreApi<DashboardStoreState> | undefined>;
23
+ export declare function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T;
24
+ export declare function DashboardProvider(props: DashboardProviderProps): JSX.Element;
25
+ //# sourceMappingURL=DashboardProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAyB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB,EAAE,eAAe,EAAE,gBAAgB;IACnG,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,gBAAgB,oEAAsE,CAAC;AAEpG,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,KAM/E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAuC9D"}
@@ -0,0 +1,64 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { createStore, useStore } from 'zustand';
15
+ import { devtools } from 'zustand/middleware';
16
+ import { immer } from 'zustand/middleware/immer';
17
+ import shallow from 'zustand/shallow';
18
+ import { createContext, useContext } from 'react';
19
+ import { createPanelGroupEditorSlice } from './panel-group-editor-slice';
20
+ import { createPanelGroupSlice } from './panel-group-slice';
21
+ import { createPanelEditorSlice } from './panel-editor-slice';
22
+ export const DashboardContext = /*#__PURE__*/ createContext(undefined);
23
+ export function useDashboardStore(selector) {
24
+ const store = useContext(DashboardContext);
25
+ if (store === undefined) {
26
+ throw new Error('No DashboardContext found. Did you forget a Provider?');
27
+ }
28
+ return useStore(store, selector, shallow);
29
+ }
30
+ export function DashboardProvider(props) {
31
+ const { children , initialState: { dashboardSpec , isEditMode } , } = props;
32
+ const { layouts , panels } = dashboardSpec;
33
+ const dashboardStore = createStore()(immer(devtools((...args)=>{
34
+ const [set, get] = args;
35
+ return {
36
+ ...createPanelGroupEditorSlice(...args),
37
+ ...createPanelGroupSlice(layouts)(...args),
38
+ ...createPanelEditorSlice(panels)(...args),
39
+ defaultTimeRange: {
40
+ pastDuration: dashboardSpec.duration
41
+ },
42
+ isEditMode: !!isEditMode,
43
+ setEditMode: (isEditMode)=>set({
44
+ isEditMode
45
+ }),
46
+ reset: ()=>{
47
+ const { resetPanels , resetPanelGroups } = get();
48
+ resetPanels();
49
+ resetPanelGroups();
50
+ },
51
+ save: ()=>{
52
+ const { savePanels , savePanelGroups } = get();
53
+ savePanels();
54
+ savePanelGroups();
55
+ }
56
+ };
57
+ })));
58
+ return /*#__PURE__*/ _jsx(DashboardContext.Provider, {
59
+ value: dashboardStore,
60
+ children: children
61
+ });
62
+ }
63
+
64
+ //# sourceMappingURL=DashboardProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useContext } from 'react';\nimport { DashboardSpec, RelativeTimeRange } from '@perses-dev/core';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\n\nexport interface DashboardStoreState extends PanelGroupEditorSlice, PanelGroupSlice, PanelEditorSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n defaultTimeRange: RelativeTimeRange;\n reset: () => void;\n save: () => void;\n}\n\nexport interface DashboardStoreProps {\n dashboardSpec: DashboardSpec;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: React.ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const {\n children,\n initialState: { dashboardSpec, isEditMode },\n } = props;\n\n const { layouts, panels } = dashboardSpec;\n\n const dashboardStore = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set, get] = args;\n return {\n ...createPanelGroupEditorSlice(...args),\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelEditorSlice(panels)(...args),\n defaultTimeRange: { pastDuration: dashboardSpec.duration },\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n reset: () => {\n const { resetPanels, resetPanelGroups } = get();\n resetPanels();\n resetPanelGroups();\n },\n save: () => {\n const { savePanels, savePanelGroups } = get();\n savePanels();\n savePanelGroups();\n },\n };\n })\n )\n );\n\n return (\n <DashboardContext.Provider value={dashboardStore as StoreApi<DashboardStoreState>}>\n {children}\n </DashboardContext.Provider>\n );\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useContext","createPanelGroupEditorSlice","createPanelGroupSlice","createPanelEditorSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","children","initialState","dashboardSpec","isEditMode","layouts","panels","dashboardStore","args","set","get","defaultTimeRange","pastDuration","duration","setEditMode","reset","resetPanels","resetPanelGroups","save","savePanels","savePanelGroups","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,SAAS,CAAC;AAEhD,SAASC,QAAQ,QAAQ,oBAAoB,CAAC;AAC9C,SAASC,KAAK,QAAQ,0BAA0B,CAAC;AACjD,OAAOC,OAAO,MAAM,iBAAiB,CAAC;AACtC,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAElD,SAASC,2BAA2B,QAA+B,4BAA4B,CAAC;AAChG,SAASC,qBAAqB,QAAyB,qBAAqB,CAAC;AAC7E,SAASC,sBAAsB,QAA0B,sBAAsB,CAAC;AAoBhF,OAAO,MAAMC,gBAAgB,iBAAGL,aAAa,CAA4CM,SAAS,CAAC,CAAC;AAEpG,OAAO,SAASC,iBAAiB,CAAIC,QAA2C,EAAE;IAChF,MAAMC,KAAK,GAAGR,UAAU,CAACI,gBAAgB,CAAC,AAAC;IAC3C,IAAII,KAAK,KAAKH,SAAS,EAAE;QACvB,MAAM,IAAII,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAOd,QAAQ,CAACa,KAAK,EAAED,QAAQ,EAAET,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,OAAO,SAASY,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EACJC,QAAQ,CAAA,EACRC,YAAY,EAAE,EAAEC,aAAa,CAAA,EAAEC,UAAU,CAAA,EAAE,CAAA,IAC5C,GAAGJ,KAAK,AAAC;IAEV,MAAM,EAAEK,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGH,aAAa,AAAC;IAE1C,MAAMI,cAAc,GAAGxB,WAAW,EAAuB,CACvDG,KAAK,CACHD,QAAQ,CAAC,CAAIuB,GAAAA,IAAI,GAAK;QACpB,MAAM,CAACC,GAAG,EAAEC,GAAG,CAAC,GAAGF,IAAI,AAAC;QACxB,OAAO;YACL,GAAGlB,2BAA2B,IAAIkB,IAAI,CAAC;YACvC,GAAGjB,qBAAqB,CAACc,OAAO,CAAC,IAAIG,IAAI,CAAC;YAC1C,GAAGhB,sBAAsB,CAACc,MAAM,CAAC,IAAIE,IAAI,CAAC;YAC1CG,gBAAgB,EAAE;gBAAEC,YAAY,EAAET,aAAa,CAACU,QAAQ;aAAE;YAC1DT,UAAU,EAAE,CAAC,CAACA,UAAU;YACxBU,WAAW,EAAE,CAACV,UAAmB,GAAKK,GAAG,CAAC;oBAAEL,UAAU;iBAAE,CAAC;YACzDW,KAAK,EAAE,IAAM;gBACX,MAAM,EAAEC,WAAW,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGP,GAAG,EAAE,AAAC;gBAChDM,WAAW,EAAE,CAAC;gBACdC,gBAAgB,EAAE,CAAC;YACrB,CAAC;YACDC,IAAI,EAAE,IAAM;gBACV,MAAM,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGV,GAAG,EAAE,AAAC;gBAC9CS,UAAU,EAAE,CAAC;gBACbC,eAAe,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CACF,AAAC;IAEF,qBACE,KAAC3B,gBAAgB,CAAC4B,QAAQ;QAACC,KAAK,EAAEf,cAAc;kBAC7CN,QAAQ;MACiB,CAC5B;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
3
+ */
4
+ export declare type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];
5
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,oBAAY,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
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
+ /**
14
+ * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
15
+ */ export { };
16
+
17
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;CAEC,GACD,WAAiF"}
@@ -0,0 +1,74 @@
1
+ import { PanelGroupItemId, PanelGroupId } from './panel-group-slice';
2
+ export declare function useEditMode(): {
3
+ isEditMode: boolean;
4
+ setEditMode: (isEditMode: boolean) => void;
5
+ };
6
+ /**
7
+ * Returns actions that can be performed on the current dashboard.
8
+ */
9
+ export declare function useDashboardActions(): {
10
+ save: () => void;
11
+ reset: () => void;
12
+ openAddPanelGroup: () => void;
13
+ openAddPanel: () => void;
14
+ };
15
+ /**
16
+ * Returns an array of PanelGroupIds in the order they appear in the dashboard.
17
+ */
18
+ export declare function usePanelGroupIds(): number[];
19
+ /**
20
+ * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.
21
+ */
22
+ export declare function useListPanelGroups(): import("./panel-group-slice").PanelGroupDefinition[];
23
+ /**
24
+ * Gets a specific panel group by its id. Throws if the panel group does not exist.
25
+ */
26
+ export declare function usePanelGroup(panelGroupId: PanelGroupId): import("./panel-group-slice").PanelGroupDefinition;
27
+ /**
28
+ * Returns actions that can be performed on the given panel group.
29
+ */
30
+ export declare function usePanelGroupActions(panelGroupId: PanelGroupId): {
31
+ openEditPanelGroup: () => void;
32
+ deletePanelGroup: () => void;
33
+ openAddPanel: () => void;
34
+ moveUp: (() => void) | undefined;
35
+ moveDown: (() => void) | undefined;
36
+ };
37
+ /**
38
+ * Gets the Panel Group editor state.
39
+ */
40
+ export declare function usePanelGroupEditor(): import("./panel-group-editor-slice").PanelGroupEditor | undefined;
41
+ /**
42
+ * Gets the Delete Panel Group dialog state.
43
+ */
44
+ export declare function useDeletePanelGroupDialog(): {
45
+ deletePanelGroupDialog: import("./panel-group-editor-slice").DeletePanelGroupDialog | undefined;
46
+ openDeletePanelGroupDialog: (panelGroupId: number) => void;
47
+ closeDeletePanelGroupDialog: () => void;
48
+ deletePanelGroup: (panelGroupId: number) => void;
49
+ };
50
+ /**
51
+ * Gets an individual panel in the store. Throws if the panel can't be found.
52
+ */
53
+ export declare function usePanel(panelGroupItemId: PanelGroupItemId): import("@perses-dev/core").PanelDefinition<import("@perses-dev/core").UnknownSpec>;
54
+ /**
55
+ * Returns actions that can be performed on the given Panel.
56
+ */
57
+ export declare function usePanelActions(panelGroupItemId: PanelGroupItemId): {
58
+ openEditPanel: () => void;
59
+ openDeletePanelDialog: () => void;
60
+ };
61
+ /**
62
+ * Gets the state for the Panel Editor.
63
+ */
64
+ export declare function usePanelEditor(): import("./panel-editor-slice").PanelEditorState | undefined;
65
+ /**
66
+ * Gets the state for the Delete Panel dialog.
67
+ */
68
+ export declare function useDeletePanelDialog(): {
69
+ deletePanelDialog: import("./panel-editor-slice").DeletePanelDialog | undefined;
70
+ deletePanels: (panels: PanelGroupItemId[]) => void;
71
+ closeDeletePanelDialog: () => void;
72
+ };
73
+ export declare function useDefaultTimeRange(): import("@perses-dev/core").RelativeTimeRange;
74
+ //# sourceMappingURL=dashboard-provider-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAErE,wBAAgB,WAAW;;;EAE1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB;;;;;EAYlC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,aAE/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,yDAYjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,sDAMvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY;;;;;;EAa9D;AAuBD;;GAEG;AACH,wBAAgB,mBAAmB,sEAElC;AAED;;GAEG;AACH,wBAAgB,yBAAyB;;;;;EASxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,sFAc1D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;EAOjE;AAED;;GAEG;AACH,wBAAgB,cAAc,gEAE7B;AAED;;GAEG;AACH,wBAAgB,oBAAoB;;;;EAWnC;AAED,wBAAgB,mBAAmB,iDAElC"}
@@ -0,0 +1,163 @@
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
+ import { getPanelKeyFromRef } from '@perses-dev/core';
14
+ import { useMemo } from 'react';
15
+ import { useDashboardStore } from './DashboardProvider';
16
+ export function useEditMode() {
17
+ return useDashboardStore(({ isEditMode , setEditMode })=>({
18
+ isEditMode,
19
+ setEditMode
20
+ }));
21
+ }
22
+ /**
23
+ * Returns actions that can be performed on the current dashboard.
24
+ */ export function useDashboardActions() {
25
+ const save = useDashboardStore((store)=>store.save);
26
+ const reset = useDashboardStore((store)=>store.reset);
27
+ const openAddPanelGroup = useDashboardStore((store)=>store.openAddPanelGroup);
28
+ const openAddPanel = useDashboardStore((store)=>store.openAddPanel);
29
+ return {
30
+ save,
31
+ reset,
32
+ openAddPanelGroup,
33
+ openAddPanel: ()=>openAddPanel(undefined)
34
+ };
35
+ }
36
+ /**
37
+ * Returns an array of PanelGroupIds in the order they appear in the dashboard.
38
+ */ export function usePanelGroupIds() {
39
+ return useDashboardStore((store)=>store.panelGroupIdOrder);
40
+ }
41
+ /**
42
+ * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.
43
+ */ export function useListPanelGroups() {
44
+ const panelGroupIds = usePanelGroupIds();
45
+ const panelGroups = useDashboardStore((store)=>store.panelGroups);
46
+ return useMemo(()=>{
47
+ return panelGroupIds.map((id)=>{
48
+ const group = panelGroups[id];
49
+ if (group === undefined) {
50
+ throw new Error(`Invalid panel group Id found ${id}`);
51
+ }
52
+ return group;
53
+ });
54
+ }, [
55
+ panelGroupIds,
56
+ panelGroups
57
+ ]);
58
+ }
59
+ /**
60
+ * Gets a specific panel group by its id. Throws if the panel group does not exist.
61
+ */ export function usePanelGroup(panelGroupId) {
62
+ const panelGroup = useDashboardStore((store)=>store.panelGroups[panelGroupId]);
63
+ if (panelGroup === undefined) {
64
+ throw new Error(`Panel group with Id ${panelGroupId} was not found`);
65
+ }
66
+ return panelGroup;
67
+ }
68
+ /**
69
+ * Returns actions that can be performed on the given panel group.
70
+ */ export function usePanelGroupActions(panelGroupId) {
71
+ const { moveUp , moveDown } = useMovePanelGroup(panelGroupId);
72
+ const openEditPanelGroup = useDashboardStore((store)=>store.openEditPanelGroup);
73
+ const deletePanelGroup = useDashboardStore((store)=>store.openDeletePanelGroupDialog);
74
+ const openAddPanel = useDashboardStore((store)=>store.openAddPanel);
75
+ return {
76
+ openEditPanelGroup: ()=>openEditPanelGroup(panelGroupId),
77
+ deletePanelGroup: ()=>deletePanelGroup(panelGroupId),
78
+ openAddPanel: ()=>openAddPanel(panelGroupId),
79
+ moveUp,
80
+ moveDown
81
+ };
82
+ }
83
+ /**
84
+ * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be
85
+ * moved in that direction.
86
+ */ function useMovePanelGroup(panelGroupId) {
87
+ const currentIndex = useDashboardStore((store)=>store.panelGroupIdOrder.findIndex((id)=>id === panelGroupId));
88
+ const panelGroupsLength = useDashboardStore((store)=>store.panelGroupIdOrder.length);
89
+ const swapPanelGroups = useDashboardStore((store)=>store.swapPanelGroups);
90
+ if (currentIndex < 0) {
91
+ throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);
92
+ }
93
+ const moveUp = ()=>swapPanelGroups(currentIndex, currentIndex - 1);
94
+ const moveDown = ()=>swapPanelGroups(currentIndex, currentIndex + 1);
95
+ return {
96
+ moveUp: currentIndex > 0 ? moveUp : undefined,
97
+ moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined
98
+ };
99
+ }
100
+ /**
101
+ * Gets the Panel Group editor state.
102
+ */ export function usePanelGroupEditor() {
103
+ return useDashboardStore((store)=>store.panelGroupEditor);
104
+ }
105
+ /**
106
+ * Gets the Delete Panel Group dialog state.
107
+ */ export function useDeletePanelGroupDialog() {
108
+ return useDashboardStore(({ deletePanelGroupDialog , openDeletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup })=>({
109
+ deletePanelGroupDialog,
110
+ openDeletePanelGroupDialog,
111
+ closeDeletePanelGroupDialog,
112
+ deletePanelGroup
113
+ }));
114
+ }
115
+ /**
116
+ * Gets an individual panel in the store. Throws if the panel can't be found.
117
+ */ export function usePanel(panelGroupItemId) {
118
+ const { panelGroupId , itemIndex } = panelGroupItemId;
119
+ const panel = useDashboardStore((store)=>{
120
+ var ref, ref1;
121
+ const panelRef = (ref1 = (ref = store.panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.items[itemIndex]) === null || ref1 === void 0 ? void 0 : ref1.content;
122
+ if (panelRef === undefined) return;
123
+ const panelKey = getPanelKeyFromRef(panelRef);
124
+ return store.panels[panelKey];
125
+ });
126
+ if (panel === undefined) {
127
+ throw new Error(`Could not find panel for Id ${panelGroupItemId}`);
128
+ }
129
+ return panel;
130
+ }
131
+ /**
132
+ * Returns actions that can be performed on the given Panel.
133
+ */ export function usePanelActions(panelGroupItemId) {
134
+ const openEditPanel = useDashboardStore((store)=>store.openEditPanel);
135
+ const openDeletePanelDialog = useDashboardStore((store)=>store.openDeletePanelDialog);
136
+ return {
137
+ openEditPanel: ()=>openEditPanel(panelGroupItemId),
138
+ openDeletePanelDialog: ()=>openDeletePanelDialog(panelGroupItemId)
139
+ };
140
+ }
141
+ /**
142
+ * Gets the state for the Panel Editor.
143
+ */ export function usePanelEditor() {
144
+ return useDashboardStore((store)=>store.panelEditor);
145
+ }
146
+ /**
147
+ * Gets the state for the Delete Panel dialog.
148
+ */ export function useDeletePanelDialog() {
149
+ const deletePanelDialog = useDashboardStore((store)=>store.deletePanelDialog);
150
+ // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself
151
+ const deletePanels = useDashboardStore((store)=>store.deletePanels);
152
+ const closeDeletePanelDialog = useDashboardStore((store)=>store.closeDeletePanelDialog);
153
+ return {
154
+ deletePanelDialog,
155
+ deletePanels,
156
+ closeDeletePanelDialog
157
+ };
158
+ }
159
+ export function useDefaultTimeRange() {
160
+ return useDashboardStore((state)=>state.defaultTimeRange);
161
+ }
162
+
163
+ //# sourceMappingURL=dashboard-provider-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getPanelKeyFromRef } from '@perses-dev/core';\nimport { useMemo } from 'react';\nimport { useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId } from './panel-group-slice';\n\nexport function useEditMode() {\n return useDashboardStore(({ isEditMode, setEditMode }) => ({ isEditMode, setEditMode }));\n}\n\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const save = useDashboardStore((store) => store.save);\n const reset = useDashboardStore((store) => store.reset);\n const openAddPanelGroup = useDashboardStore((store) => store.openAddPanelGroup);\n const openAddPanel = useDashboardStore((store) => store.openAddPanel);\n\n return {\n save,\n reset,\n openAddPanelGroup,\n openAddPanel: () => openAddPanel(undefined),\n };\n}\n\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore((store) => store.panelGroupIdOrder);\n}\n\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore((store) => store.panelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore((store) => store.panelGroups[panelGroupId]);\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const openEditPanelGroup = useDashboardStore((store) => store.openEditPanelGroup);\n const deletePanelGroup = useDashboardStore((store) => store.openDeletePanelGroupDialog);\n const openAddPanel = useDashboardStore((store) => store.openAddPanel);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n };\n}\n\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore((store) => store.panelGroupIdOrder.findIndex((id) => id === panelGroupId));\n const panelGroupsLength = useDashboardStore((store) => store.panelGroupIdOrder.length);\n const swapPanelGroups = useDashboardStore((store) => store.swapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore((store) => store.panelGroupEditor);\n}\n\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n return useDashboardStore(\n ({ deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup }) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n })\n );\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, itemIndex } = panelGroupItemId;\n\n const panel = useDashboardStore((store) => {\n const panelRef = store.panelGroups[panelGroupId]?.items[itemIndex]?.content;\n if (panelRef === undefined) return;\n const panelKey = getPanelKeyFromRef(panelRef);\n return store.panels[panelKey];\n });\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const openEditPanel = useDashboardStore((store) => store.openEditPanel);\n const openDeletePanelDialog = useDashboardStore((store) => store.openDeletePanelDialog);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n };\n}\n\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore((store) => store.panelEditor);\n}\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n const deletePanelDialog = useDashboardStore((store) => store.deletePanelDialog);\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n const deletePanels = useDashboardStore((store) => store.deletePanels);\n const closeDeletePanelDialog = useDashboardStore((store) => store.closeDeletePanelDialog);\n\n return {\n deletePanelDialog,\n deletePanels,\n closeDeletePanelDialog,\n };\n}\n\nexport function useDefaultTimeRange() {\n return useDashboardStore((state) => state.defaultTimeRange);\n}\n"],"names":["getPanelKeyFromRef","useMemo","useDashboardStore","useEditMode","isEditMode","setEditMode","useDashboardActions","save","store","reset","openAddPanelGroup","openAddPanel","undefined","usePanelGroupIds","panelGroupIdOrder","useListPanelGroups","panelGroupIds","panelGroups","map","id","group","Error","usePanelGroup","panelGroupId","panelGroup","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","openEditPanelGroup","deletePanelGroup","openDeletePanelGroupDialog","currentIndex","findIndex","panelGroupsLength","length","swapPanelGroups","usePanelGroupEditor","panelGroupEditor","useDeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","usePanel","panelGroupItemId","itemIndex","panel","panelRef","items","content","panelKey","panels","usePanelActions","openEditPanel","openDeletePanelDialog","usePanelEditor","panelEditor","useDeletePanelDialog","deletePanelDialog","deletePanels","closeDeletePanelDialog","useDefaultTimeRange","state","defaultTimeRange"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkB,QAAQ,kBAAkB,CAAC;AACtD,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,iBAAiB,QAAQ,qBAAqB,CAAC;AAGxD,OAAO,SAASC,WAAW,GAAG;IAC5B,OAAOD,iBAAiB,CAAC,CAAC,EAAEE,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAE,GAA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D,OAAO,SAASW,cAAc,GAAG;IAC/B,OAAOpD,iBAAiB,CAAC,CAACM,KAAK,GAAKA,KAAK,CAAC+C,WAAW,CAAC,CAAC;AACzD,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,oBAAoB,GAAG;IACrC,MAAMC,iBAAiB,GAAGvD,iBAAiB,CAAC,CAACM,KAAK,GAAKA,KAAK,CAACiD,iBAAiB,CAAC,AAAC;IAChF,0FAA0F;IAC1F,MAAMC,YAAY,GAAGxD,iBAAiB,CAAC,CAACM,KAAK,GAAKA,KAAK,CAACkD,YAAY,CAAC,AAAC;IACtE,MAAMC,sBAAsB,GAAGzD,iBAAiB,CAAC,CAACM,KAAK,GAAKA,KAAK,CAACmD,sBAAsB,CAAC,AAAC;IAE1F,OAAO;QACLF,iBAAiB;QACjBC,YAAY;QACZC,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED,OAAO,SAASC,mBAAmB,GAAG;IACpC,OAAO1D,iBAAiB,CAAC,CAAC2D,KAAK,GAAKA,KAAK,CAACC,gBAAgB,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './dashboard-provider-api';
2
+ export * from './DashboardProvider';
3
+ export type { PanelGroupId, PanelGroupDefinition, PanelGroupItemId as LayoutItem } from './panel-group-slice';
4
+ export type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC9G,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,16 @@
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
+ export * from './dashboard-provider-api';
14
+ export * from './DashboardProvider';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './dashboard-provider-api';\nexport * from './DashboardProvider';\nexport type { PanelGroupId, PanelGroupDefinition, PanelGroupItemId as LayoutItem } from './panel-group-slice';\nexport type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { PanelDefinition, UnknownSpec } from '@perses-dev/core';
2
+ import { StateCreator } from 'zustand';
3
+ import { Middleware } from './common';
4
+ import { PanelGroupSlice, PanelGroupItemId, PanelGroupId } from './panel-group-slice';
5
+ /**
6
+ * Slice that handles the visual editor state and actions for Panels (i.e. add, edit, delete).
7
+ */
8
+ export interface PanelEditorSlice {
9
+ panels: Record<string, PanelDefinition>;
10
+ previousPanels: Record<string, PanelDefinition>;
11
+ /**
12
+ * State for the panel editor when its open, otherwise undefined when it's closed.
13
+ */
14
+ panelEditor?: PanelEditorState;
15
+ /**
16
+ * Opens the editor for editing an existing panel by providing its layout coordinates.
17
+ */
18
+ openEditPanel: (item: PanelGroupItemId) => void;
19
+ /**
20
+ * Opens the editor for adding a new Panel to a panel group.
21
+ */
22
+ openAddPanel: (panelGroupId?: PanelGroupId) => void;
23
+ /**
24
+ * Delete panels
25
+ */
26
+ deletePanels: (panels: PanelGroupItemId[]) => void;
27
+ /**
28
+ * Reset panels to previous state
29
+ */
30
+ resetPanels: () => void;
31
+ /**
32
+ * Save panels
33
+ */
34
+ savePanels: () => void;
35
+ /**
36
+ * State for the delete panel dialog when it's open, otherwise undefined when it's closed.
37
+ */
38
+ deletePanelDialog?: DeletePanelDialog;
39
+ /**
40
+ * Open delete panel dialog
41
+ */
42
+ openDeletePanelDialog: (item: PanelGroupItemId) => void;
43
+ /**
44
+ * Close delete panel dialog
45
+ */
46
+ closeDeletePanelDialog: () => void;
47
+ }
48
+ export interface DeletePanelDialog {
49
+ panelGroupItemId: PanelGroupItemId;
50
+ panelName: string;
51
+ panelGroupName: string;
52
+ }
53
+ export interface PanelEditorState {
54
+ /**
55
+ * Whether we're adding a new panel, or editing an existing panel.
56
+ */
57
+ mode: 'Add' | 'Edit';
58
+ /**
59
+ * Initial values for the things that can be edited about a panel.
60
+ */
61
+ initialValues: PanelEditorValues;
62
+ /**
63
+ * Applies changes, but doesn't close the editor.
64
+ */
65
+ applyChanges: (next: PanelEditorValues) => void;
66
+ /**
67
+ * Close the editor.
68
+ */
69
+ close: () => void;
70
+ }
71
+ /**
72
+ * Panel values that can be edited in the panel editor.
73
+ */
74
+ export interface PanelEditorValues {
75
+ name: string;
76
+ description: string;
77
+ groupId: PanelGroupId;
78
+ kind: string;
79
+ spec: UnknownSpec;
80
+ }
81
+ /**
82
+ * Curried function for creating the PanelEditorSlice.
83
+ */
84
+ export declare function createPanelEditorSlice(panels: PanelEditorSlice['panels']): StateCreator<PanelEditorSlice & PanelGroupSlice, Middleware, [], PanelEditorSlice>;
85
+ //# sourceMappingURL=panel-editor-slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAE/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAEhD;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAEpD;;OAEG;IACH,YAAY,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;IAEnD;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC;;OAEG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