@perses-dev/dashboards 0.0.0-snapshot-time-range-height-80d08fc

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 (372) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cjs/components/Dashboard/Dashboard.js +37 -0
  3. package/dist/cjs/components/Dashboard/index.js +28 -0
  4. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +176 -0
  5. package/dist/cjs/components/DashboardToolbar/index.js +28 -0
  6. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +92 -0
  7. package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
  8. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +88 -0
  9. package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
  10. package/dist/cjs/components/DownloadButton/DownloadButton.js +109 -0
  11. package/dist/cjs/components/DownloadButton/index.js +28 -0
  12. package/dist/cjs/components/GridLayout/GridContainer.js +219 -0
  13. package/dist/cjs/components/GridLayout/GridItemContent.js +41 -0
  14. package/dist/cjs/components/GridLayout/GridLayout.js +104 -0
  15. package/dist/cjs/components/GridLayout/GridTitle.js +100 -0
  16. package/dist/cjs/components/GridLayout/index.js +29 -0
  17. package/dist/cjs/components/Panel/Panel.js +123 -0
  18. package/dist/cjs/components/Panel/Panel.test.js +129 -0
  19. package/dist/cjs/components/Panel/PanelContent.js +44 -0
  20. package/dist/cjs/components/Panel/PanelHeader.js +120 -0
  21. package/dist/cjs/components/Panel/index.js +28 -0
  22. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +98 -0
  23. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +131 -0
  24. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -0
  25. package/dist/cjs/components/PanelDrawer/PanelPreview.js +47 -0
  26. package/dist/cjs/components/PanelDrawer/index.js +28 -0
  27. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +101 -0
  28. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +87 -0
  29. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  30. package/dist/cjs/components/PanelGroupDialog/index.js +28 -0
  31. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +136 -0
  32. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +95 -0
  33. package/dist/cjs/components/TimeRangeControls/index.js +28 -0
  34. package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
  35. package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
  36. package/dist/cjs/components/Variables/Variable.js +194 -0
  37. package/dist/cjs/components/Variables/VariableEditor.js +276 -0
  38. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +459 -0
  39. package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
  40. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +89 -0
  41. package/dist/cjs/components/Variables/VariableList.js +150 -0
  42. package/dist/cjs/components/Variables/index.js +30 -0
  43. package/dist/cjs/components/Variables/variable-model.js +117 -0
  44. package/dist/cjs/components/Variables/variable-model.test.js +106 -0
  45. package/dist/cjs/components/index.js +39 -0
  46. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +95 -0
  47. package/dist/cjs/context/DashboardProvider/common.js +28 -0
  48. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +191 -0
  49. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
  50. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
  51. package/dist/cjs/context/DashboardProvider/index.js +29 -0
  52. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +205 -0
  53. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +85 -0
  54. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +113 -0
  55. package/dist/cjs/context/DashboardProvider/panel-slice.js +25 -0
  56. package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
  57. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +228 -0
  58. package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
  59. package/dist/cjs/context/TemplateVariableProvider/query-params.js +81 -0
  60. package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
  61. package/dist/cjs/context/index.js +31 -0
  62. package/dist/cjs/context/useDashboard.js +94 -0
  63. package/dist/cjs/index.js +30 -0
  64. package/dist/cjs/test/dashboard-provider.js +51 -0
  65. package/dist/cjs/test/index.js +30 -0
  66. package/dist/cjs/test/plugin-registry.js +42 -0
  67. package/dist/cjs/test/render.js +62 -0
  68. package/dist/cjs/test/setup-tests.js +23 -0
  69. package/dist/cjs/test/testDashboard.js +293 -0
  70. package/dist/cjs/utils/functions.js +23 -0
  71. package/dist/cjs/views/ViewDashboard/DashboardApp.js +96 -0
  72. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +68 -0
  73. package/dist/cjs/views/ViewDashboard/index.js +28 -0
  74. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +110 -0
  75. package/dist/cjs/views/index.js +28 -0
  76. package/dist/components/Dashboard/Dashboard.d.ts +8 -0
  77. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
  78. package/dist/components/Dashboard/Dashboard.js +33 -0
  79. package/dist/components/Dashboard/Dashboard.js.map +1 -0
  80. package/dist/components/Dashboard/index.d.ts +2 -0
  81. package/dist/components/Dashboard/index.d.ts.map +1 -0
  82. package/dist/components/Dashboard/index.js +15 -0
  83. package/dist/components/Dashboard/index.js.map +1 -0
  84. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +11 -0
  85. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
  86. package/dist/components/DashboardToolbar/DashboardToolbar.js +165 -0
  87. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
  88. package/dist/components/DashboardToolbar/index.d.ts +2 -0
  89. package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
  90. package/dist/components/DashboardToolbar/index.js +15 -0
  91. package/dist/components/DashboardToolbar/index.js.map +1 -0
  92. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
  93. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
  94. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +81 -0
  95. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
  96. package/dist/components/DeletePanelDialog/index.d.ts +2 -0
  97. package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
  98. package/dist/components/DeletePanelDialog/index.js +15 -0
  99. package/dist/components/DeletePanelDialog/index.js.map +1 -0
  100. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
  101. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  102. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +77 -0
  103. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  104. package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
  105. package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
  106. package/dist/components/DeletePanelGroupDialog/index.js +15 -0
  107. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
  108. package/dist/components/DownloadButton/DownloadButton.d.ts +3 -0
  109. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -0
  110. package/dist/components/DownloadButton/DownloadButton.js +60 -0
  111. package/dist/components/DownloadButton/DownloadButton.js.map +1 -0
  112. package/dist/components/DownloadButton/index.d.ts +2 -0
  113. package/dist/components/DownloadButton/index.d.ts.map +1 -0
  114. package/dist/components/DownloadButton/index.js +15 -0
  115. package/dist/components/DownloadButton/index.js.map +1 -0
  116. package/dist/components/GridLayout/GridContainer.d.ts +6 -0
  117. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
  118. package/dist/components/GridLayout/GridContainer.js +213 -0
  119. package/dist/components/GridLayout/GridContainer.js.map +1 -0
  120. package/dist/components/GridLayout/GridItemContent.d.ts +10 -0
  121. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -0
  122. package/dist/components/GridLayout/GridItemContent.js +37 -0
  123. package/dist/components/GridLayout/GridItemContent.js.map +1 -0
  124. package/dist/components/GridLayout/GridLayout.d.ts +10 -0
  125. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -0
  126. package/dist/components/GridLayout/GridLayout.js +100 -0
  127. package/dist/components/GridLayout/GridLayout.js.map +1 -0
  128. package/dist/components/GridLayout/GridTitle.d.ts +16 -0
  129. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -0
  130. package/dist/components/GridLayout/GridTitle.js +92 -0
  131. package/dist/components/GridLayout/GridTitle.js.map +1 -0
  132. package/dist/components/GridLayout/index.d.ts +3 -0
  133. package/dist/components/GridLayout/index.d.ts.map +1 -0
  134. package/dist/components/GridLayout/index.js +16 -0
  135. package/dist/components/GridLayout/index.js.map +1 -0
  136. package/dist/components/Panel/Panel.d.ts +13 -0
  137. package/dist/components/Panel/Panel.d.ts.map +1 -0
  138. package/dist/components/Panel/Panel.js +114 -0
  139. package/dist/components/Panel/Panel.js.map +1 -0
  140. package/dist/components/Panel/Panel.test.d.ts +2 -0
  141. package/dist/components/Panel/Panel.test.d.ts.map +1 -0
  142. package/dist/components/Panel/Panel.test.js +122 -0
  143. package/dist/components/Panel/Panel.test.js.map +1 -0
  144. package/dist/components/Panel/PanelContent.d.ts +12 -0
  145. package/dist/components/Panel/PanelContent.d.ts.map +1 -0
  146. package/dist/components/Panel/PanelContent.js +41 -0
  147. package/dist/components/Panel/PanelContent.js.map +1 -0
  148. package/dist/components/Panel/PanelHeader.d.ts +16 -0
  149. package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
  150. package/dist/components/Panel/PanelHeader.js +109 -0
  151. package/dist/components/Panel/PanelHeader.js.map +1 -0
  152. package/dist/components/Panel/index.d.ts +2 -0
  153. package/dist/components/Panel/index.d.ts.map +1 -0
  154. package/dist/components/Panel/index.js +15 -0
  155. package/dist/components/Panel/index.js.map +1 -0
  156. package/dist/components/PanelDrawer/PanelDrawer.d.ts +6 -0
  157. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -0
  158. package/dist/components/PanelDrawer/PanelDrawer.js +94 -0
  159. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
  160. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +2 -0
  161. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +1 -0
  162. package/dist/components/PanelDrawer/PanelDrawer.test.js +124 -0
  163. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
  164. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
  165. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
  166. package/dist/components/PanelDrawer/PanelEditorForm.js +192 -0
  167. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
  168. package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
  169. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
  170. package/dist/components/PanelDrawer/PanelPreview.js +41 -0
  171. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
  172. package/dist/components/PanelDrawer/index.d.ts +2 -0
  173. package/dist/components/PanelDrawer/index.d.ts.map +1 -0
  174. package/dist/components/PanelDrawer/index.js +15 -0
  175. package/dist/components/PanelDrawer/index.js.map +1 -0
  176. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +6 -0
  177. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -0
  178. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +92 -0
  179. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
  180. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +2 -0
  181. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +1 -0
  182. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +80 -0
  183. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
  184. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  185. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  186. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  187. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  188. package/dist/components/PanelGroupDialog/index.d.ts +2 -0
  189. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  190. package/dist/components/PanelGroupDialog/index.js +15 -0
  191. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  192. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +9 -0
  193. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  194. package/dist/components/TimeRangeControls/TimeRangeControls.js +119 -0
  195. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  196. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +2 -0
  197. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +1 -0
  198. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +88 -0
  199. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
  200. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  201. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  202. package/dist/components/TimeRangeControls/index.js +15 -0
  203. package/dist/components/TimeRangeControls/index.js.map +1 -0
  204. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
  205. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
  206. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
  207. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
  208. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
  209. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
  210. package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
  211. package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
  212. package/dist/components/Variables/Variable.d.ts +8 -0
  213. package/dist/components/Variables/Variable.d.ts.map +1 -0
  214. package/dist/components/Variables/Variable.js +188 -0
  215. package/dist/components/Variables/Variable.js.map +1 -0
  216. package/dist/components/Variables/VariableEditor.d.ts +8 -0
  217. package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
  218. package/dist/components/Variables/VariableEditor.js +265 -0
  219. package/dist/components/Variables/VariableEditor.js.map +1 -0
  220. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
  221. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
  222. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +409 -0
  223. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  224. package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
  225. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
  226. package/dist/components/Variables/VariableEditorForm/index.js +15 -0
  227. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  228. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +22 -0
  229. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
  230. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +77 -0
  231. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  232. package/dist/components/Variables/VariableList.d.ts +9 -0
  233. package/dist/components/Variables/VariableList.d.ts.map +1 -0
  234. package/dist/components/Variables/VariableList.js +100 -0
  235. package/dist/components/Variables/VariableList.js.map +1 -0
  236. package/dist/components/Variables/index.d.ts +4 -0
  237. package/dist/components/Variables/index.d.ts.map +1 -0
  238. package/dist/components/Variables/index.js +17 -0
  239. package/dist/components/Variables/index.js.map +1 -0
  240. package/dist/components/Variables/variable-model.d.ts +16 -0
  241. package/dist/components/Variables/variable-model.d.ts.map +1 -0
  242. package/dist/components/Variables/variable-model.js +105 -0
  243. package/dist/components/Variables/variable-model.js.map +1 -0
  244. package/dist/components/Variables/variable-model.test.d.ts +2 -0
  245. package/dist/components/Variables/variable-model.test.d.ts.map +1 -0
  246. package/dist/components/Variables/variable-model.test.js +104 -0
  247. package/dist/components/Variables/variable-model.test.js.map +1 -0
  248. package/dist/components/index.d.ts +13 -0
  249. package/dist/components/index.d.ts.map +1 -0
  250. package/dist/components/index.js +26 -0
  251. package/dist/components/index.js.map +1 -0
  252. package/dist/context/DashboardProvider/DashboardProvider.d.ts +28 -0
  253. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
  254. package/dist/context/DashboardProvider/DashboardProvider.js +77 -0
  255. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
  256. package/dist/context/DashboardProvider/common.d.ts +12 -0
  257. package/dist/context/DashboardProvider/common.d.ts.map +1 -0
  258. package/dist/context/DashboardProvider/common.js +24 -0
  259. package/dist/context/DashboardProvider/common.js.map +1 -0
  260. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +74 -0
  261. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
  262. package/dist/context/DashboardProvider/dashboard-provider-api.js +190 -0
  263. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  264. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
  265. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
  266. package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
  267. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
  268. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
  269. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
  270. package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
  271. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
  272. package/dist/context/DashboardProvider/index.d.ts +7 -0
  273. package/dist/context/DashboardProvider/index.d.ts.map +1 -0
  274. package/dist/context/DashboardProvider/index.js +16 -0
  275. package/dist/context/DashboardProvider/index.js.map +1 -0
  276. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +56 -0
  277. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  278. package/dist/context/DashboardProvider/panel-editor-slice.js +201 -0
  279. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  280. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +33 -0
  281. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  282. package/dist/context/DashboardProvider/panel-group-editor-slice.js +79 -0
  283. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  284. package/dist/context/DashboardProvider/panel-group-slice.d.ts +59 -0
  285. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
  286. package/dist/context/DashboardProvider/panel-group-slice.js +105 -0
  287. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
  288. package/dist/context/DashboardProvider/panel-slice.d.ts +14 -0
  289. package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
  290. package/dist/context/DashboardProvider/panel-slice.js +21 -0
  291. package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
  292. package/dist/context/DatasourceStoreProvider.d.ts +24 -0
  293. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
  294. package/dist/context/DatasourceStoreProvider.js +166 -0
  295. package/dist/context/DatasourceStoreProvider.js.map +1 -0
  296. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +30 -0
  297. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
  298. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +212 -0
  299. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
  300. package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
  301. package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
  302. package/dist/context/TemplateVariableProvider/index.js +15 -0
  303. package/dist/context/TemplateVariableProvider/index.js.map +1 -0
  304. package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
  305. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
  306. package/dist/context/TemplateVariableProvider/query-params.js +66 -0
  307. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
  308. package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
  309. package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
  310. package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
  311. package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
  312. package/dist/context/index.d.ts +5 -0
  313. package/dist/context/index.d.ts.map +1 -0
  314. package/dist/context/index.js +18 -0
  315. package/dist/context/index.js.map +1 -0
  316. package/dist/context/useDashboard.d.ts +6 -0
  317. package/dist/context/useDashboard.d.ts.map +1 -0
  318. package/dist/context/useDashboard.js +88 -0
  319. package/dist/context/useDashboard.js.map +1 -0
  320. package/dist/index.d.ts +4 -0
  321. package/dist/index.d.ts.map +1 -0
  322. package/dist/index.js +17 -0
  323. package/dist/index.js.map +1 -0
  324. package/dist/test/dashboard-provider.d.ts +19 -0
  325. package/dist/test/dashboard-provider.d.ts.map +1 -0
  326. package/dist/test/dashboard-provider.js +40 -0
  327. package/dist/test/dashboard-provider.js.map +1 -0
  328. package/dist/test/index.d.ts +4 -0
  329. package/dist/test/index.d.ts.map +1 -0
  330. package/dist/test/index.js +17 -0
  331. package/dist/test/index.js.map +1 -0
  332. package/dist/test/plugin-registry.d.ts +3 -0
  333. package/dist/test/plugin-registry.d.ts.map +1 -0
  334. package/dist/test/plugin-registry.js +37 -0
  335. package/dist/test/plugin-registry.js.map +1 -0
  336. package/dist/test/render.d.ts +8 -0
  337. package/dist/test/render.d.ts.map +1 -0
  338. package/dist/test/render.js +58 -0
  339. package/dist/test/render.js.map +1 -0
  340. package/dist/test/setup-tests.d.ts +2 -0
  341. package/dist/test/setup-tests.d.ts.map +1 -0
  342. package/dist/test/setup-tests.js +22 -0
  343. package/dist/test/setup-tests.js.map +1 -0
  344. package/dist/test/testDashboard.d.ts +4 -0
  345. package/dist/test/testDashboard.d.ts.map +1 -0
  346. package/dist/test/testDashboard.js +287 -0
  347. package/dist/test/testDashboard.js.map +1 -0
  348. package/dist/utils/functions.d.ts +2 -0
  349. package/dist/utils/functions.d.ts.map +1 -0
  350. package/dist/utils/functions.js +17 -0
  351. package/dist/utils/functions.js.map +1 -0
  352. package/dist/views/ViewDashboard/DashboardApp.d.ts +10 -0
  353. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -0
  354. package/dist/views/ViewDashboard/DashboardApp.js +90 -0
  355. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
  356. package/dist/views/ViewDashboard/ViewDashboard.d.ts +16 -0
  357. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -0
  358. package/dist/views/ViewDashboard/ViewDashboard.js +64 -0
  359. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
  360. package/dist/views/ViewDashboard/index.d.ts +2 -0
  361. package/dist/views/ViewDashboard/index.d.ts.map +1 -0
  362. package/dist/views/ViewDashboard/index.js +15 -0
  363. package/dist/views/ViewDashboard/index.js.map +1 -0
  364. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
  365. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
  366. package/dist/views/ViewDashboard/tests/panelGroups.test.js +103 -0
  367. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
  368. package/dist/views/index.d.ts +2 -0
  369. package/dist/views/index.d.ts.map +1 -0
  370. package/dist/views/index.js +15 -0
  371. package/dist/views/index.js.map +1 -0
  372. package/package.json +57 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { IconButton, styled } from '@mui/material';\nimport { DateTimeRangePicker, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { useDefaultTimeRange } from '../../context';\n\nexport const TIME_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // Height of the controls in pixels.\n // The controls look best at heights >= 28 pixels.\n // You can use values less than 28, but it won't look great.\n heightPx?: number;\n}\n\nexport function TimeRangeControls({ heightPx }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n const defaultTimeRange = useDefaultTimeRange();\n\n // Convert height as a number to height as a string, then use this value for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === defaultTimeRange.pastDuration)) {\n if (isDurationString(defaultTimeRange.pastDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: defaultTimeRange.pastDuration },\n display: `Last ${defaultTimeRange.pastDuration}`,\n });\n }\n }\n\n return (\n <>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n <RefreshIconButton aria-label=\"Refresh Dashboard\" onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </RefreshIconButton>\n </>\n );\n}\n\nconst RefreshIconButton = styled(IconButton)(({ theme }) => ({\n border: `1px solid ${theme.palette.grey[300]}`,\n borderRadius: theme.shape.borderRadius,\n padding: theme.spacing(0.5),\n color: theme.palette.grey[900],\n}));\n"],"names":["RefreshIcon","IconButton","styled","DateTimeRangePicker","useTimeRange","isDurationString","useDefaultTimeRange","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","timeRange","setTimeRange","refresh","defaultTimeRange","height","undefined","some","option","push","timeOptions","onChange","RefreshIconButton","aria-label","onClick","sx","theme","border","palette","grey","borderRadius","shape","padding","spacing","color"],"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,OAAOA,WAAW,MAAM,yBAAyB,CAAC;AAClD,SAASC,UAAU,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACnD,SAASC,mBAAmB,QAAoB,wBAAwB,CAAC;AACzE,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAASC,gBAAgB,QAAQ,kBAAkB,CAAC;AACpD,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAEpD,OAAO,MAAMC,YAAY,GAAiB;IACxC;QAAEC,KAAK,EAAE;YAAEC,YAAY,E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sources":["../../../src/components/TimeRangeControls/TimeRangeControls.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,88 @@
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 { generatePath } from 'react-router';
15
+ import { createMemoryHistory } from 'history';
16
+ import userEvent from '@testing-library/user-event';
17
+ import { screen, act } from '@testing-library/react';
18
+ import { TimeRangeProvider } from '@perses-dev/plugin-system';
19
+ import { renderWithContext } from '../../test';
20
+ import testDashboard from '../../test/testDashboard';
21
+ import { DashboardProvider } from '../../context';
22
+ import { TimeRangeControls } from './TimeRangeControls';
23
+ const history = createMemoryHistory({
24
+ initialEntries: [
25
+ generatePath('/home'),
26
+ generatePath('/dashboards/:id', {
27
+ id: 'test'
28
+ })
29
+ ]
30
+ });
31
+ describe('TimeRangeControls', ()=>{
32
+ let initialState;
33
+ const testDefaultTimeRange = {
34
+ pastDuration: testDashboard.spec.duration
35
+ };
36
+ beforeEach(()=>{
37
+ initialState = {
38
+ dashboardResource: testDashboard
39
+ };
40
+ });
41
+ const renderTimeRangeControls = (testURLParams)=>{
42
+ renderWithContext(/*#__PURE__*/ _jsx(DashboardProvider, {
43
+ initialState: initialState,
44
+ children: /*#__PURE__*/ _jsx(TimeRangeProvider, {
45
+ initialTimeRange: testDefaultTimeRange,
46
+ enabledURLParams: testURLParams,
47
+ children: /*#__PURE__*/ _jsx(TimeRangeControls, {})
48
+ })
49
+ }), undefined, history);
50
+ };
51
+ it('should default to dashboard duration and update selected time option when clicked', async ()=>{
52
+ renderTimeRangeControls(false);
53
+ expect(screen.getByText('Last 30 minutes')).toBeInTheDocument();
54
+ const dateButton = screen.getByRole('button', {
55
+ name: /last/i
56
+ });
57
+ userEvent.click(dateButton);
58
+ const firstSelected = screen.getByRole('option', {
59
+ name: 'Last 5 minutes'
60
+ });
61
+ userEvent.click(firstSelected);
62
+ expect(dateButton).toHaveTextContent(/5 minutes/i);
63
+ });
64
+ it('should update URL params with correct time range values', ()=>{
65
+ renderTimeRangeControls(true);
66
+ const dateButton = screen.getByRole('button', {
67
+ name: /last/i
68
+ });
69
+ userEvent.click(dateButton);
70
+ const firstSelected = screen.getByRole('option', {
71
+ name: 'Last 5 minutes'
72
+ });
73
+ userEvent.click(firstSelected);
74
+ expect(history.location.search).toEqual('?start=5m');
75
+ // pick another option from TimeRangeSelector dropdown
76
+ const secondSelected = screen.getByText('Last 12 hours');
77
+ userEvent.click(secondSelected);
78
+ expect(history.location.search).toEqual('?start=12h');
79
+ // back button should return to previous page selected
80
+ act(()=>{
81
+ history.back();
82
+ });
83
+ expect(history.location.pathname).toEqual('/home');
84
+ });
85
+ // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.
86
+ });
87
+
88
+ //# sourceMappingURL=TimeRangeControls.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.test.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 { generatePath } from 'react-router';\nimport { createMemoryHistory } from 'history';\nimport userEvent from '@testing-library/user-event';\nimport { screen, act } from '@testing-library/react';\nimport { TimeRangeProvider } from '@perses-dev/plugin-system';\nimport { renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport { DashboardProvider, DashboardStoreProps } from '../../context';\nimport { TimeRangeControls } from './TimeRangeControls';\n\nconst history = createMemoryHistory({\n initialEntries: [generatePath('/home'), generatePath('/dashboards/:id', { id: 'test' })],\n});\n\ndescribe('TimeRangeControls', () => {\n let initialState: DashboardStoreProps;\n const testDefaultTimeRange = { pastDuration: testDashboard.spec.duration };\n\n beforeEach(() => {\n initialState = {\n dashboardResource: testDashboard,\n };\n });\n\n const renderTimeRangeControls = (testURLParams: boolean) => {\n renderWithContext(\n <DashboardProvider initialState={initialState}>\n <TimeRangeProvider initialTimeRange={testDefaultTimeRange} enabledURLParams={testURLParams}>\n <TimeRangeControls />\n </TimeRangeProvider>\n </DashboardProvider>,\n undefined,\n history\n );\n };\n\n it('should default to dashboard duration and update selected time option when clicked', async () => {\n renderTimeRangeControls(false);\n expect(screen.getByText('Last 30 minutes')).toBeInTheDocument();\n const dateButton = screen.getByRole('button', { name: /last/i });\n userEvent.click(dateButton);\n const firstSelected = screen.getByRole('option', { name: 'Last 5 minutes' });\n userEvent.click(firstSelected);\n expect(dateButton).toHaveTextContent(/5 minutes/i);\n });\n\n it('should update URL params with correct time range values', () => {\n renderTimeRangeControls(true);\n const dateButton = screen.getByRole('button', { name: /last/i });\n userEvent.click(dateButton);\n const firstSelected = screen.getByRole('option', { name: 'Last 5 minutes' });\n userEvent.click(firstSelected);\n expect(history.location.search).toEqual('?start=5m');\n\n // pick another option from TimeRangeSelector dropdown\n const secondSelected = screen.getByText('Last 12 hours');\n userEvent.click(secondSelected);\n expect(history.location.search).toEqual('?start=12h');\n\n // back button should return to previous page selected\n act(() => {\n history.back();\n });\n expect(history.location.pathname).toEqual('/home');\n });\n\n // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.\n});\n"],"names":["generatePath","createMemoryHistory","userEvent","screen","act","TimeRangeProvider","renderWithContext","testDashboard","DashboardProvider","TimeRangeControls","history","initialEntries","id","describe","initialState","testDefaultTimeRange","pastDuration","spec","duration","beforeEach","dashboardResource","renderTimeRangeControls","testURLParams","initialTimeRange","enabledURLParams","undefined","it","expect","getByText","toBeInTheDocument","dateButton","getByRole","name","click","firstSelected","toHaveTextContent","location","search","toEqual","secondSelected","back","pathname"],"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,YAAY,QAAQ,cAAc,CAAC;AAC5C,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAC9C,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,EAAEC,GAAG,QAAQ,wBAAwB,CAAC;AACrD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAC/C,OAAOC,aAAa,MAAM,0BAA0B,CAAC;AACrD,SAASC,iBAAiB,QAA6B,eAAe,CAAC;AACvE,SAASC,iBAAiB,QAAQ,qBAAqB,CAAC;AAExD,MAAMC,OAAO,GAAGT,mBAAmB,CAAC;IAClCU,cAAc,EAAE;QAACX,YAAY,CAAC,OAAO,CAAC;QAAEA,YAAY,CAAC,iBAAiB,EAAE;YAAEY,EAAE,EAAE,MAAM;SAAE,CAAC;KAAC;CACzF,CAAC,AAAC;AAEHC,QAAQ,CAAC,mBAAmB,EAAE,IAAM;IAClC,IAAIC,YAAY,AAAqB,AAAC;IACtC,MAAMC,oBAAoB,GAAG;QAAEC,YAAY,EAAET,aAAa,CAACU,IAAI,CAACC,QAAQ;KAAE,AAAC;IAE3EC,UAAU,CAAC,IAAM;QACfL,YAAY,GAAG;YACbM,iBAAiB,EAAEb,aAAa;SACjC,CAAC;IACJ,CAAC,CAAC,CAAC;IAE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C7E9B,SAAS,CAAC+B,KAAK,CAACC,aAAa,CAAC,CAAC;QAC/BP,MAAM,CAACjB,OAAO,CAAC0B,QAAQ,CAACC,MAAM,CAAC,CAACC,OAAO,CAAC,WAAW,CAAC,CAAC;QAErD,sDAAsD;QACtD,MAAMC,cAAc,GAAGpC,MAAM,CAACyB,SAAS,CAAC,eAAe,CAAC,AAAC;QACzD1B,SAAS,CAAC+B,KAAK,CAACM,cAAc,CAAC,CAAC;QAChCZ,MAAM,CAACjB,OAAO,CAAC0B,QAAQ,CAACC,MAAM,CAAC,CAACC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEtD,sDAAsD;QACtDlC,GAAG,CAAC,IAAM;YACRM,OAAO,CAAC8B,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACHb,MAAM,CAACjB,OAAO,CAAC0B,QAAQ,CAACK,QAAQ,CAAC,CAACH,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AAEH,8FAA8F;AAChG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './TimeRangeControls';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,15 @@
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 './TimeRangeControls';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/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 './TimeRangeControls';\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,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export interface UnsavedChangesConfirmationDialogProps {
3
+ isOpen: boolean;
4
+ onSave: () => void;
5
+ onClose: () => void;
6
+ }
7
+ export declare const UnsavedChangesConfirmationDialog: ({ isOpen, onSave, onClose, }: UnsavedChangesConfirmationDialogProps) => JSX.Element;
8
+ //# sourceMappingURL=UnsavedChangesConfirmationDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnsavedChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAeA,MAAM,WAAW,qCAAqC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,gCAAgC,iCAI1C,qCAAqC,gBA0BvC,CAAC"}
@@ -0,0 +1,56 @@
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, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
15
+ import CloseIcon from 'mdi-material-ui/Close';
16
+ export const UnsavedChangesConfirmationDialog = ({ isOpen , onSave , onClose })=>{
17
+ return /*#__PURE__*/ _jsxs(Dialog, {
18
+ open: isOpen,
19
+ children: [
20
+ /*#__PURE__*/ _jsx(DialogTitle, {
21
+ children: "Unsaved Changes"
22
+ }),
23
+ /*#__PURE__*/ _jsx(IconButton, {
24
+ "aria-label": "Close",
25
+ onClick: onClose,
26
+ sx: (theme)=>({
27
+ position: 'absolute',
28
+ top: theme.spacing(0.5),
29
+ right: theme.spacing(0.5)
30
+ }),
31
+ children: /*#__PURE__*/ _jsx(CloseIcon, {})
32
+ }),
33
+ /*#__PURE__*/ _jsx(DialogContent, {
34
+ sx: {
35
+ width: '500px'
36
+ },
37
+ children: "You have unsaved changes in this dashboard. Would you like to save these changes?"
38
+ }),
39
+ /*#__PURE__*/ _jsxs(DialogActions, {
40
+ children: [
41
+ /*#__PURE__*/ _jsx(Button, {
42
+ variant: "contained",
43
+ onClick: onSave,
44
+ children: "Save"
45
+ }),
46
+ /*#__PURE__*/ _jsx(Button, {
47
+ onClick: onClose,
48
+ children: "Cancel"
49
+ })
50
+ ]
51
+ })
52
+ ]
53
+ });
54
+ };
55
+
56
+ //# sourceMappingURL=UnsavedChangesConfirmationDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.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 { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nexport interface UnsavedChangesConfirmationDialogProps {\n isOpen: boolean;\n onSave: () => void;\n onClose: () => void;\n}\n\nexport const UnsavedChangesConfirmationDialog = ({\n isOpen,\n onSave,\n onClose,\n}: UnsavedChangesConfirmationDialogProps) => {\n return (\n <Dialog open={isOpen}>\n <DialogTitle>Unsaved Changes</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={onClose}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent sx={{ width: '500px' }}>\n You have unsaved changes in this dashboard. Would you like to save these changes?\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button onClick={onClose}>Cancel</Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","UnsavedChangesConfirmationDialog","isOpen","onSave","onClose","open","aria-label","onClick","sx","theme","position","top","spacing","right","width","variant"],"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,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAO9C,OAAO,MAAMC,gCAAgC,GAAG,CAAC,EAC/CC,MAAM,CAAA,EACNC,MAAM,CAAA,EACNC,OAAO,CAAA,EAC+B,GAAK;IAC3C,qBACE,MAACT,MAAM;QAACU,IAAI,EAAEH,MAAM;;0BAClB,KAACN,WAAW;0BAAC,iBAAe;cAAc;0BAC1C,KAACF,UAAU;gBACTY,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAEH,OAAO;gBAChBI,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACZ,SAAS,KAAG;cACF;0BACb,KAACH,aAAa;gBAACW,EAAE,EAAE;oBAAEM,KAAK,EAAE,OAAO;iBAAE;0BAAE,mFAEvC;cAAgB;0BAChB,MAAChB,aAAa;;kCACZ,KAACC,MAAM;wBAACgB,OAAO,EAAC,WAAW;wBAACR,OAAO,EAAEJ,MAAM;kCAAE,MAE7C;sBAAS;kCACT,KAACJ,MAAM;wBAACQ,OAAO,EAAEH,OAAO;kCAAE,QAAM;sBAAS;;cAC3B;;MACT,CACT;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './UnsavedChangesConfirmationDialog';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,15 @@
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 './UnsavedChangesConfirmationDialog';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/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 './UnsavedChangesConfirmationDialog';\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,oCAAoC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { VariableName } from '@perses-dev/core';
3
+ declare type TemplateVariableProps = {
4
+ name: VariableName;
5
+ };
6
+ export declare function TemplateVariable({ name }: TemplateVariableProps): JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=Variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/Variable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAyC,MAAM,kBAAkB,CAAC;AAIvF,aAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE,qBAAqB,eAW/D"}
@@ -0,0 +1,188 @@
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, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { useEffect, useMemo, useState } from 'react';
15
+ import { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';
16
+ import { DEFAULT_ALL_VALUE } from '@perses-dev/plugin-system';
17
+ import { useTemplateVariable, useTemplateVariableActions } from '../../context';
18
+ import { useListVariablePluginValues } from './variable-model';
19
+ export function TemplateVariable({ name }) {
20
+ var ref;
21
+ const ctx = useTemplateVariable(name);
22
+ const kind = (ref = ctx.definition) === null || ref === void 0 ? void 0 : ref.kind;
23
+ switch(kind){
24
+ case 'TextVariable':
25
+ return /*#__PURE__*/ _jsx(TextVariable, {
26
+ name: name
27
+ });
28
+ case 'ListVariable':
29
+ return /*#__PURE__*/ _jsx(ListVariable, {
30
+ name: name
31
+ });
32
+ }
33
+ return /*#__PURE__*/ _jsxs("div", {
34
+ children: [
35
+ "Unsupported Variable Kind: $",
36
+ kind
37
+ ]
38
+ });
39
+ }
40
+ function ListVariable({ name }) {
41
+ var ref, ref1, ref2, ref3;
42
+ const ctx = useTemplateVariable(name);
43
+ const definition = ctx.definition;
44
+ const variablesOptionsQuery = useListVariablePluginValues(definition);
45
+ const { setVariableValue , setVariableLoading , setVariableOptions } = useTemplateVariableActions();
46
+ const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_multiple) === true;
47
+ const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_all_value) === true;
48
+ var ref4;
49
+ const title = (ref4 = (ref = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref4 !== void 0 ? ref4 : name;
50
+ useEffect(()=>{
51
+ setVariableLoading(name, variablesOptionsQuery.isFetching);
52
+ if (variablesOptionsQuery.data) {
53
+ setVariableOptions(name, variablesOptionsQuery.data);
54
+ }
55
+ }, [
56
+ variablesOptionsQuery,
57
+ name,
58
+ setVariableLoading,
59
+ setVariableOptions
60
+ ]);
61
+ let value = (ref1 = ctx.state) === null || ref1 === void 0 ? void 0 : ref1.value;
62
+ const options = (ref2 = ctx.state) === null || ref2 === void 0 ? void 0 : ref2.options;
63
+ const loading = (ref3 = ctx.state) === null || ref3 === void 0 ? void 0 : ref3.loading;
64
+ // Make sure value is an array if allowMultiple is true
65
+ if (allowMultiple && !Array.isArray(value)) {
66
+ value = typeof value === 'string' ? [
67
+ value
68
+ ] : [];
69
+ }
70
+ const finalOptions = useMemo(()=>{
71
+ let computedOptions = options ? [
72
+ ...options
73
+ ] : [];
74
+ // Add the all value if it's allowed
75
+ if (allowAllValue) {
76
+ computedOptions = [
77
+ {
78
+ value: DEFAULT_ALL_VALUE,
79
+ label: 'All'
80
+ },
81
+ ...computedOptions
82
+ ];
83
+ }
84
+ return computedOptions;
85
+ }, [
86
+ options,
87
+ allowAllValue
88
+ ]);
89
+ const valueIsInOptions = useMemo(()=>Boolean(finalOptions.find((v)=>{
90
+ if (allowMultiple) {
91
+ return value.includes(v.value);
92
+ }
93
+ return value === v.value;
94
+ })), [
95
+ finalOptions,
96
+ value,
97
+ allowMultiple
98
+ ]);
99
+ let selectValue = value;
100
+ if (!valueIsInOptions) {
101
+ selectValue = allowMultiple ? [] : '';
102
+ }
103
+ useEffect(()=>{
104
+ const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
105
+ // If there is no value but there are options, set the value to the first option.
106
+ if (!value && firstOption) {
107
+ setVariableValue(name, firstOption.value);
108
+ }
109
+ }, [
110
+ finalOptions,
111
+ setVariableValue,
112
+ value,
113
+ name,
114
+ allowMultiple
115
+ ]);
116
+ return /*#__PURE__*/ _jsx(Box, {
117
+ display: 'flex',
118
+ children: /*#__PURE__*/ _jsxs(FormControl, {
119
+ fullWidth: true,
120
+ children: [
121
+ /*#__PURE__*/ _jsx(InputLabel, {
122
+ id: name,
123
+ children: title
124
+ }),
125
+ /*#__PURE__*/ _jsxs(Select, {
126
+ sx: {
127
+ minWidth: 100,
128
+ maxWidth: 250
129
+ },
130
+ id: name,
131
+ label: name,
132
+ value: selectValue,
133
+ onChange: (e)=>{
134
+ // Must be selected
135
+ if (e.target.value === null || e.target.value.length === 0) {
136
+ if (allowAllValue) {
137
+ setVariableValue(name, DEFAULT_ALL_VALUE);
138
+ }
139
+ return;
140
+ }
141
+ setVariableValue(name, e.target.value);
142
+ },
143
+ multiple: allowMultiple,
144
+ children: [
145
+ loading && /*#__PURE__*/ _jsx(MenuItem, {
146
+ value: "loading",
147
+ disabled: true,
148
+ children: "Loading"
149
+ }),
150
+ finalOptions.length === 0 && /*#__PURE__*/ _jsx(MenuItem, {
151
+ value: "empty",
152
+ disabled: true,
153
+ children: "No options"
154
+ }),
155
+ finalOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
156
+ value: option.value,
157
+ children: option.label
158
+ }, option.value))
159
+ ]
160
+ }),
161
+ loading && /*#__PURE__*/ _jsx(LinearProgress, {})
162
+ ]
163
+ })
164
+ });
165
+ }
166
+ function TextVariable({ name }) {
167
+ var ref;
168
+ const { state , definition } = useTemplateVariable(name);
169
+ var ref1;
170
+ const [tempValue, setTempValue] = useState((ref1 = state === null || state === void 0 ? void 0 : state.value) !== null && ref1 !== void 0 ? ref1 : '');
171
+ const { setVariableValue } = useTemplateVariableActions();
172
+ useEffect(()=>{
173
+ var ref;
174
+ setTempValue((ref = state === null || state === void 0 ? void 0 : state.value) !== null && ref !== void 0 ? ref : '');
175
+ }, [
176
+ state === null || state === void 0 ? void 0 : state.value
177
+ ]);
178
+ var ref2;
179
+ return /*#__PURE__*/ _jsx(TextField, {
180
+ value: tempValue,
181
+ onChange: (e)=>setTempValue(e.target.value),
182
+ onBlur: ()=>setVariableValue(name, tempValue),
183
+ placeholder: name,
184
+ label: (ref2 = (ref = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref2 !== void 0 ? ref2 : name
185
+ });
186
+ }
187
+
188
+ //# sourceMappingURL=Variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Variables/Variable.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 { useEffect, useMemo, useState } from 'react';\nimport { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';\nimport { VariableName, ListVariableDefinition, VariableValue } from '@perses-dev/core';\nimport { DEFAULT_ALL_VALUE } from '@perses-dev/plugin-system';\nimport { useTemplateVariable, useTemplateVariableActions } from '../../context';\nimport { useListVariablePluginValues } from './variable-model';\ntype TemplateVariableProps = {\n name: VariableName;\n};\n\nexport function TemplateVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const kind = ctx.definition?.kind;\n switch (kind) {\n case 'TextVariable':\n return <TextVariable name={name} />;\n case 'ListVariable':\n return <ListVariable name={name} />;\n }\n\n return <div>Unsupported Variable Kind: ${kind}</div>;\n}\n\nfunction ListVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const definition = ctx.definition as ListVariableDefinition;\n const variablesOptionsQuery = useListVariablePluginValues(definition);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();\n\n const allowMultiple = definition?.spec.allow_multiple === true;\n const allowAllValue = definition?.spec.allow_all_value === true;\n const title = definition?.spec.display?.name ?? name;\n\n useEffect(() => {\n setVariableLoading(name, variablesOptionsQuery.isFetching);\n if (variablesOptionsQuery.data) {\n setVariableOptions(name, variablesOptionsQuery.data);\n }\n }, [variablesOptionsQuery, name, setVariableLoading, setVariableOptions]);\n\n let value = ctx.state?.value;\n const options = ctx.state?.options;\n const loading = ctx.state?.loading;\n\n // Make sure value is an array if allowMultiple is true\n if (allowMultiple && !Array.isArray(value)) {\n value = typeof value === 'string' ? [value] : [];\n }\n\n const finalOptions = useMemo(() => {\n let computedOptions = options ? [...options] : [];\n\n // Add the all value if it's allowed\n if (allowAllValue) {\n computedOptions = [{ value: DEFAULT_ALL_VALUE, label: 'All' }, ...computedOptions];\n }\n return computedOptions;\n }, [options, allowAllValue]);\n\n const valueIsInOptions = useMemo(\n () =>\n Boolean(\n finalOptions.find((v) => {\n if (allowMultiple) {\n return (value as string[]).includes(v.value);\n }\n return value === v.value;\n })\n ),\n [finalOptions, value, allowMultiple]\n );\n\n let selectValue = value;\n if (!valueIsInOptions) {\n selectValue = allowMultiple ? [] : '';\n }\n\n useEffect(() => {\n const firstOption = finalOptions?.[0];\n\n // If there is no value but there are options, set the value to the first option.\n if (!value && firstOption) {\n setVariableValue(name, firstOption.value);\n }\n }, [finalOptions, setVariableValue, value, name, allowMultiple]);\n\n return (\n <Box display={'flex'}>\n <FormControl fullWidth>\n <InputLabel id={name}>{title}</InputLabel>\n <Select\n sx={{ minWidth: 100, maxWidth: 250 }}\n id={name}\n label={name}\n value={selectValue}\n onChange={(e) => {\n // Must be selected\n if (e.target.value === null || e.target.value.length === 0) {\n if (allowAllValue) {\n setVariableValue(name, DEFAULT_ALL_VALUE);\n }\n return;\n }\n setVariableValue(name, e.target.value as VariableValue);\n }}\n multiple={allowMultiple}\n >\n {loading && (\n <MenuItem value=\"loading\" disabled>\n Loading\n </MenuItem>\n )}\n\n {finalOptions.length === 0 && (\n <MenuItem value=\"empty\" disabled>\n No options\n </MenuItem>\n )}\n {finalOptions.map((option) => (\n <MenuItem key={option.value} value={option.value}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n {loading && <LinearProgress />}\n </FormControl>\n </Box>\n );\n}\n\nfunction TextVariable({ name }: TemplateVariableProps) {\n const { state, definition } = useTemplateVariable(name);\n const [tempValue, setTempValue] = useState(state?.value ?? '');\n const { setVariableValue } = useTemplateVariableActions();\n\n useEffect(() => {\n setTempValue(state?.value ?? '');\n }, [state?.value]);\n\n return (\n <TextField\n value={tempValue}\n onChange={(e) => setTempValue(e.target.value)}\n onBlur={() => setVariableValue(name, tempValue)}\n placeholder={name}\n label={definition?.spec.display?.name ?? name}\n />\n );\n}\n"],"names":["useEffect","useMemo","useState","Select","FormControl","InputLabel","MenuItem","Box","LinearProgress","TextField","DEFAULT_ALL_VALUE","useTemplateVariable","useTemplateVariableActions","useListVariablePluginValues","TemplateVariable","name","ctx","kind","definition","TextVariable","ListVariable","div","variablesOptionsQuery","setVariableValue","setVariableLoading","setVariableOptions","allowMultiple","spec","allow_multiple","allowAllValue","allow_all_value","title","display","isFetching","data","value","state","options","loading","Array","isArray","finalOptions","computedOptions","label","valueIsInOptions","Boolean","find","v","includes","selectValue","firstOption","fullWidth","id","sx","minWidth","maxWidth","onChange","e","target","length","multiple","disabled","map","option","tempValue","setTempValue","onBlur","placeholder"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,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QAQRjB,IAA8B;IANzC,qBACE,KAACT,SAAS;QACR0B,KAAK,EAAE6B,SAAS;QAChBR,QAAQ,EAAE,CAACC,CAAC,GAAKQ,YAAY,CAACR,CAAC,CAACC,MAAM,CAACvB,KAAK,CAAC;QAC7C+B,MAAM,EAAE,IAAM3C,gBAAgB,CAACR,IAAI,EAAEiD,SAAS,CAAC;QAC/CG,WAAW,EAAEpD,IAAI;QACjB4B,KAAK,EAAEzB,CAAAA,IAA8B,GAA9BA,OAAAA,UAAU,aAAVA,UAAU,WAAM,GAAhBA,KAAAA,CAAgB,GAAhBA,UAAU,CAAES,IAAI,CAACK,OAAO,4BAAM,GAA9Bd,KAAAA,CAA8B,OAAJH,IAAI,cAA9BG,IAA8B,cAA9BA,IAA8B,GAAIH,IAAI;MAC7C,CACF;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { VariableDefinition } from '@perses-dev/core';
3
+ export declare function VariableEditor(props: {
4
+ variableDefinitions: VariableDefinition[];
5
+ onChange: (variableDefinitions: VariableDefinition[]) => void;
6
+ onCancel: () => void;
7
+ }): JSX.Element;
8
+ //# sourceMappingURL=VariableEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VariableEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/VariableEditor.tsx"],"names":[],"mappings":";AA8BA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AA6BtD,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,QAAQ,EAAE,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IAC9D,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,eAiLA"}