@perses-dev/dashboards 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-explorer-plugin-c4a7621

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 (348) hide show
  1. package/dist/cjs/components/Dashboard/Dashboard.js +8 -1
  2. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +1 -1
  4. package/dist/cjs/components/Datasources/DatasourceEditor.js +18 -18
  5. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +2 -5
  6. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +3 -4
  7. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +10 -13
  8. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +2 -2
  9. package/dist/cjs/components/GridLayout/GridContainer.js +15 -10
  10. package/dist/cjs/components/GridLayout/GridItemContent.js +19 -4
  11. package/dist/cjs/components/GridLayout/GridLayout.js +61 -12
  12. package/dist/cjs/components/GridLayout/GridTitle.js +3 -3
  13. package/dist/cjs/{validation/panel.js → components/Panel/HeaderIconButton.js} +8 -10
  14. package/dist/cjs/components/Panel/Panel.js +14 -10
  15. package/dist/cjs/components/Panel/PanelActions.js +216 -0
  16. package/dist/cjs/components/Panel/PanelContent.js +4 -4
  17. package/dist/cjs/components/Panel/PanelHeader.js +36 -103
  18. package/dist/cjs/components/Panel/PanelLinks.js +136 -0
  19. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +9 -6
  20. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +67 -65
  21. package/dist/cjs/components/PanelDrawer/PanelPreview.js +7 -3
  22. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +9 -6
  23. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  24. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  25. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -6
  26. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +2 -2
  27. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +7 -14
  28. package/dist/cjs/components/Variables/EditVariablesButton.js +4 -4
  29. package/dist/cjs/components/Variables/{TemplateVariable.js → Variable.js} +43 -60
  30. package/dist/cjs/components/Variables/VariableEditor.js +34 -40
  31. package/dist/cjs/components/Variables/VariableList.js +23 -22
  32. package/dist/cjs/components/Variables/index.js +2 -2
  33. package/dist/cjs/constants/styles.js +15 -7
  34. package/dist/cjs/constants/user-interface-text.js +3 -0
  35. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +10 -8
  36. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +36 -0
  37. package/dist/cjs/context/DashboardProvider/common.js +2 -2
  38. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +14 -6
  39. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -2
  40. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +7 -10
  41. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  42. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +8 -3
  43. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +79 -0
  44. package/dist/cjs/context/DatasourceStoreProvider.js +18 -23
  45. package/dist/cjs/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +62 -69
  46. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +11 -14
  47. package/dist/cjs/{validation → context/VariableProvider}/index.js +2 -2
  48. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  49. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  50. package/dist/cjs/context/index.js +2 -2
  51. package/dist/cjs/context/useDashboard.js +4 -4
  52. package/dist/cjs/stories/decorators/WithDashboard.js +1 -1
  53. package/dist/cjs/stories/decorators/WithDatasourceStore.js +1 -1
  54. package/dist/cjs/stories/decorators/{WithTemplateVariables.js → WithVariables.js} +9 -9
  55. package/dist/cjs/stories/decorators/index.js +2 -2
  56. package/dist/cjs/test/plugin-registry.js +4 -2
  57. package/dist/cjs/test/render.js +13 -11
  58. package/dist/cjs/views/ViewDashboard/DashboardApp.js +3 -3
  59. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +7 -8
  60. package/dist/components/AddGroupButton/AddGroupButton.d.ts +2 -1
  61. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  62. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  63. package/dist/components/AddPanelButton/AddPanelButton.d.ts +2 -1
  64. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  65. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  66. package/dist/components/Dashboard/Dashboard.d.ts +2 -1
  67. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  68. package/dist/components/Dashboard/Dashboard.js +8 -1
  69. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  70. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +2 -1
  71. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  72. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +3 -3
  73. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  74. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  75. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  76. package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
  77. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  78. package/dist/components/Datasources/DatasourceEditor.d.ts +2 -1
  79. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  80. package/dist/components/Datasources/DatasourceEditor.js +19 -19
  81. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  82. package/dist/components/Datasources/EditDatasourcesButton.d.ts +2 -1
  83. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  84. package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
  85. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  86. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +2 -1
  87. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  88. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  89. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +2 -1
  90. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  91. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +3 -4
  92. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  93. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +2 -1
  94. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  95. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  96. package/dist/components/DownloadButton/DownloadButton.d.ts +2 -1
  97. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  98. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  99. package/dist/components/EditButton/EditButton.d.ts +2 -1
  100. package/dist/components/EditButton/EditButton.d.ts.map +1 -1
  101. package/dist/components/EditButton/EditButton.js.map +1 -1
  102. package/dist/components/EditJsonButton/EditJsonButton.d.ts +2 -1
  103. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  104. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  105. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +2 -1
  106. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  107. package/dist/components/EditJsonDialog/EditJsonDialog.js +7 -10
  108. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  109. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +3 -3
  110. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
  111. package/dist/components/EmptyDashboard/EmptyDashboard.js +2 -2
  112. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  113. package/dist/components/GridLayout/GridContainer.d.ts +5 -3
  114. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  115. package/dist/components/GridLayout/GridContainer.js +15 -10
  116. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  117. package/dist/components/GridLayout/GridItemContent.d.ts +2 -1
  118. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  119. package/dist/components/GridLayout/GridItemContent.js +21 -6
  120. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  121. package/dist/components/GridLayout/GridLayout.d.ts +4 -2
  122. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  123. package/dist/components/GridLayout/GridLayout.js +63 -14
  124. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  125. package/dist/components/GridLayout/GridTitle.d.ts +3 -2
  126. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  127. package/dist/components/GridLayout/GridTitle.js +3 -3
  128. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  129. package/dist/components/Panel/HeaderIconButton.d.ts +5 -0
  130. package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -0
  131. package/dist/{context/TemplateVariableProvider/index.js → components/Panel/HeaderIconButton.js} +7 -3
  132. package/dist/components/Panel/HeaderIconButton.js.map +1 -0
  133. package/dist/components/Panel/Panel.d.ts +11 -5
  134. package/dist/components/Panel/Panel.d.ts.map +1 -1
  135. package/dist/components/Panel/Panel.js +15 -11
  136. package/dist/components/Panel/Panel.js.map +1 -1
  137. package/dist/components/Panel/PanelActions.d.ts +16 -0
  138. package/dist/components/Panel/PanelActions.d.ts.map +1 -0
  139. package/dist/components/Panel/PanelActions.js +203 -0
  140. package/dist/components/Panel/PanelActions.js.map +1 -0
  141. package/dist/components/Panel/PanelContent.d.ts +2 -1
  142. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  143. package/dist/components/Panel/PanelContent.js +4 -4
  144. package/dist/components/Panel/PanelContent.js.map +1 -1
  145. package/dist/components/Panel/PanelHeader.d.ts +8 -8
  146. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  147. package/dist/components/Panel/PanelHeader.js +39 -106
  148. package/dist/components/Panel/PanelHeader.js.map +1 -1
  149. package/dist/components/Panel/PanelLinks.d.ts +6 -0
  150. package/dist/components/Panel/PanelLinks.d.ts.map +1 -0
  151. package/dist/components/Panel/PanelLinks.js +123 -0
  152. package/dist/components/Panel/PanelLinks.js.map +1 -0
  153. package/dist/components/PanelDrawer/PanelDrawer.d.ts +2 -1
  154. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  155. package/dist/components/PanelDrawer/PanelDrawer.js +10 -7
  156. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  157. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  158. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  159. package/dist/components/PanelDrawer/PanelEditorForm.js +70 -68
  160. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  161. package/dist/components/PanelDrawer/PanelPreview.d.ts +3 -2
  162. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  163. package/dist/components/PanelDrawer/PanelPreview.js +8 -4
  164. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  165. package/dist/components/PanelDrawer/usePanelEditor.d.ts +12 -10
  166. package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -1
  167. package/dist/components/PanelDrawer/usePanelEditor.js +9 -6
  168. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  169. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +2 -1
  170. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  171. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  172. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  173. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +2 -1
  174. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  175. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  176. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +2 -1
  177. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
  178. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  179. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  180. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +2 -1
  181. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  182. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +5 -7
  183. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  184. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +2 -1
  185. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  186. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -3
  187. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  188. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +2 -1
  189. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -1
  190. package/dist/components/Variables/BuiltinVariableAccordions.js +7 -14
  191. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  192. package/dist/components/Variables/EditVariablesButton.d.ts +2 -1
  193. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  194. package/dist/components/Variables/EditVariablesButton.js +5 -5
  195. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  196. package/dist/components/Variables/{TemplateVariable.d.ts → Variable.d.ts} +6 -5
  197. package/dist/components/Variables/Variable.d.ts.map +1 -0
  198. package/dist/components/Variables/{TemplateVariable.js → Variable.js} +44 -61
  199. package/dist/components/Variables/Variable.js.map +1 -0
  200. package/dist/components/Variables/VariableEditor.d.ts +3 -2
  201. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  202. package/dist/components/Variables/VariableEditor.js +35 -41
  203. package/dist/components/Variables/VariableEditor.js.map +1 -1
  204. package/dist/components/Variables/VariableList.d.ts +4 -3
  205. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  206. package/dist/components/Variables/VariableList.js +21 -20
  207. package/dist/components/Variables/VariableList.js.map +1 -1
  208. package/dist/components/Variables/index.d.ts +1 -1
  209. package/dist/components/Variables/index.d.ts.map +1 -1
  210. package/dist/components/Variables/index.js +2 -2
  211. package/dist/components/Variables/index.js.map +1 -1
  212. package/dist/constants/styles.d.ts +4 -2
  213. package/dist/constants/styles.d.ts.map +1 -1
  214. package/dist/constants/styles.js +5 -3
  215. package/dist/constants/styles.js.map +1 -1
  216. package/dist/constants/user-interface-text.d.ts +3 -0
  217. package/dist/constants/user-interface-text.d.ts.map +1 -1
  218. package/dist/constants/user-interface-text.js +3 -0
  219. package/dist/constants/user-interface-text.js.map +1 -1
  220. package/dist/context/DashboardProvider/DashboardProvider.d.ts +6 -3
  221. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  222. package/dist/context/DashboardProvider/DashboardProvider.js +11 -9
  223. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  224. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts +4 -0
  225. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -0
  226. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +28 -0
  227. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -0
  228. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  229. package/dist/context/DashboardProvider/common.js +2 -2
  230. package/dist/context/DashboardProvider/common.js.map +1 -1
  231. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +36 -23
  232. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  233. package/dist/context/DashboardProvider/dashboard-provider-api.js +13 -6
  234. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  235. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +2 -1
  236. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -1
  237. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  238. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -2
  239. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  240. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  241. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  242. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  243. package/dist/context/DashboardProvider/index.d.ts +1 -2
  244. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  245. package/dist/context/DashboardProvider/index.js.map +1 -1
  246. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -9
  247. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  248. package/dist/context/DashboardProvider/panel-editor-slice.js +4 -7
  249. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  250. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +2 -1
  251. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  252. package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  253. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  254. package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -2
  255. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  256. package/dist/context/DashboardProvider/panel-group-slice.js +7 -3
  257. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  258. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  259. package/dist/context/DashboardProvider/view-panel-slice.d.ts +21 -0
  260. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -0
  261. package/dist/context/DashboardProvider/view-panel-slice.js +73 -0
  262. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -0
  263. package/dist/context/DatasourceStoreProvider.d.ts +7 -7
  264. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  265. package/dist/context/DatasourceStoreProvider.js +18 -23
  266. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  267. package/dist/context/VariableProvider/VariableProvider.d.ts +119 -0
  268. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -0
  269. package/dist/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +51 -54
  270. package/dist/context/VariableProvider/VariableProvider.js.map +1 -0
  271. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.d.ts +1 -1
  272. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -0
  273. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +9 -12
  274. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -0
  275. package/dist/context/VariableProvider/index.d.ts +2 -0
  276. package/dist/context/VariableProvider/index.d.ts.map +1 -0
  277. package/dist/{validation → context/VariableProvider}/index.js +2 -2
  278. package/dist/context/VariableProvider/index.js.map +1 -0
  279. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.d.ts +2 -6
  280. package/dist/context/VariableProvider/query-params.d.ts.map +1 -0
  281. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  282. package/dist/context/VariableProvider/query-params.js.map +1 -0
  283. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.d.ts +1 -1
  284. package/dist/context/VariableProvider/utils.d.ts.map +1 -0
  285. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  286. package/dist/context/VariableProvider/utils.js.map +1 -0
  287. package/dist/context/index.d.ts +1 -1
  288. package/dist/context/index.d.ts.map +1 -1
  289. package/dist/context/index.js +2 -2
  290. package/dist/context/index.js.map +1 -1
  291. package/dist/context/useDashboard.d.ts.map +1 -1
  292. package/dist/context/useDashboard.js +4 -4
  293. package/dist/context/useDashboard.js.map +1 -1
  294. package/dist/stories/decorators/WithDashboard.js +1 -1
  295. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  296. package/dist/stories/decorators/WithDatasourceStore.js +1 -1
  297. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  298. package/dist/stories/decorators/{WithTemplateVariables.js → WithVariables.js} +9 -9
  299. package/dist/stories/decorators/WithVariables.js.map +1 -0
  300. package/dist/stories/decorators/index.js +2 -2
  301. package/dist/stories/decorators/index.js.map +1 -1
  302. package/dist/test/dashboard-provider.d.ts +1 -1
  303. package/dist/test/dashboard-provider.d.ts.map +1 -1
  304. package/dist/test/dashboard-provider.js.map +1 -1
  305. package/dist/test/datasource-provider.d.ts +2 -2
  306. package/dist/test/datasource-provider.d.ts.map +1 -1
  307. package/dist/test/datasource-provider.js.map +1 -1
  308. package/dist/test/plugin-registry.d.ts.map +1 -1
  309. package/dist/test/plugin-registry.js +4 -2
  310. package/dist/test/plugin-registry.js.map +1 -1
  311. package/dist/test/render.d.ts +2 -2
  312. package/dist/test/render.d.ts.map +1 -1
  313. package/dist/test/render.js +9 -7
  314. package/dist/test/render.js.map +1 -1
  315. package/dist/utils/panelUtils.d.ts.map +1 -1
  316. package/dist/utils/panelUtils.js.map +1 -1
  317. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -2
  318. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  319. package/dist/views/ViewDashboard/DashboardApp.js +3 -3
  320. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  321. package/dist/views/ViewDashboard/ViewDashboard.d.ts +4 -3
  322. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  323. package/dist/views/ViewDashboard/ViewDashboard.js +8 -9
  324. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  325. package/package.json +9 -9
  326. package/dist/cjs/context/TemplateVariableProvider/index.js +0 -30
  327. package/dist/components/Variables/TemplateVariable.d.ts.map +0 -1
  328. package/dist/components/Variables/TemplateVariable.js.map +0 -1
  329. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +0 -77
  330. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +0 -1
  331. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +0 -1
  332. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +0 -1
  333. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +0 -1
  334. package/dist/context/TemplateVariableProvider/index.d.ts +0 -2
  335. package/dist/context/TemplateVariableProvider/index.d.ts.map +0 -1
  336. package/dist/context/TemplateVariableProvider/index.js.map +0 -1
  337. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +0 -1
  338. package/dist/context/TemplateVariableProvider/query-params.js.map +0 -1
  339. package/dist/context/TemplateVariableProvider/utils.d.ts.map +0 -1
  340. package/dist/context/TemplateVariableProvider/utils.js.map +0 -1
  341. package/dist/stories/decorators/WithTemplateVariables.js.map +0 -1
  342. package/dist/validation/index.d.ts +0 -2
  343. package/dist/validation/index.d.ts.map +0 -1
  344. package/dist/validation/index.js.map +0 -1
  345. package/dist/validation/panel.d.ts +0 -19
  346. package/dist/validation/panel.d.ts.map +0 -1
  347. package/dist/validation/panel.js +0 -21
  348. package/dist/validation/panel.js.map +0 -1
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -15,11 +15,11 @@ import { useState } from 'react';
15
15
  import { Button } from '@mui/material';
16
16
  import { isRelativeTimeRange } from '@perses-dev/core';
17
17
  import { useTimeRange } from '@perses-dev/plugin-system';
18
- import { useDashboard, useEditMode, useSaveChangesConfirmationDialog, useTemplateVariableActions } from '../../context';
18
+ import { useDashboard, useEditMode, useSaveChangesConfirmationDialog, useVariableDefinitionActions } from '../../context';
19
19
  export const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' })=>{
20
20
  const [isSavingDashboard, setSavingDashboard] = useState(false);
21
21
  const { dashboard, setDashboard } = useDashboard();
22
- const { getSavedVariablesStatus, setVariableDefaultValues } = useTemplateVariableActions();
22
+ const { getSavedVariablesStatus, setVariableDefaultValues } = useVariableDefinitionActions();
23
23
  const { isSavedVariableModified } = getSavedVariablesStatus();
24
24
  const { timeRange } = useTimeRange();
25
25
  const { setEditMode } = useEditMode();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"sourcesContent":["// Copyright 2023 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 { useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport { isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport {\n OnSaveDashboard,\n useDashboard,\n useEditMode,\n useSaveChangesConfirmationDialog,\n useTemplateVariableActions,\n} from '../../context';\n\nexport interface SaveDashboardButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n onSave?: OnSaveDashboard;\n isDisabled: boolean;\n variant?: 'contained' | 'text' | 'outlined';\n}\n\nexport const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' }: SaveDashboardButtonProps) => {\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const { dashboard, setDashboard } = useDashboard();\n const { getSavedVariablesStatus, setVariableDefaultValues } = useTemplateVariableActions();\n const { isSavedVariableModified } = getSavedVariablesStatus();\n const { timeRange } = useTimeRange();\n const { setEditMode } = useEditMode();\n const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();\n\n const onSaveButtonClick = () => {\n const isSavedDurationModified =\n isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;\n\n // Save dashboard\n // - if active timeRange from plugin-system is relative and different from currently saved\n // - or if the saved variables are different from currently saved\n if (isSavedDurationModified || isSavedVariableModified) {\n openSaveChangesConfirmationDialog({\n onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables) => {\n if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange === true) {\n dashboard.spec.duration = timeRange.pastDuration;\n }\n if (saveDefaultVariables === true) {\n const variables = setVariableDefaultValues();\n dashboard.spec.variables = variables;\n }\n setDashboard(dashboard);\n saveDashboard();\n },\n onCancel: () => {\n closeSaveChangesConfirmationDialog();\n },\n isSavedDurationModified,\n isSavedVariableModified,\n });\n } else {\n saveDashboard();\n }\n };\n\n const saveDashboard = async () => {\n if (onSave) {\n try {\n setSavingDashboard(true);\n await onSave(dashboard);\n closeSaveChangesConfirmationDialog();\n setEditMode(false);\n } catch (error) {\n throw new Error(`An error occurred while saving the dashboard. ${error}`);\n } finally {\n setSavingDashboard(false);\n }\n } else {\n setEditMode(false);\n }\n };\n\n return (\n <Button variant={variant} onClick={onSaveButtonClick} disabled={isDisabled || isSavingDashboard}>\n Save\n </Button>\n );\n};\n"],"names":["useState","Button","isRelativeTimeRange","useTimeRange","useDashboard","useEditMode","useSaveChangesConfirmationDialog","useTemplateVariableActions","SaveDashboardButton","onSave","isDisabled","variant","isSavingDashboard","setSavingDashboard","dashboard","setDashboard","getSavedVariablesStatus","setVariableDefaultValues","isSavedVariableModified","timeRange","setEditMode","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","onSaveButtonClick","isSavedDurationModified","spec","duration","pastDuration","onSaveChanges","saveDefaultTimeRange","saveDefaultVariables","variables","saveDashboard","onCancel","error","Error","onClick","disabled"],"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,QAAQ,QAAQ,QAAQ;AACjC,SAASC,MAAM,QAAqB,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAEEC,YAAY,EACZC,WAAW,EACXC,gCAAgC,EAChCC,0BAA0B,QACrB,gBAAgB;AAQvB,OAAO,MAAMC,sBAAsB,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAEC,UAAU,WAAW,EAA4B;IACzG,MAAM,CAACC,mBAAmBC,mBAAmB,GAAGb,SAAkB;IAClE,MAAM,EAAEc,SAAS,EAAEC,YAAY,EAAE,GAAGX;IACpC,MAAM,EAAEY,uBAAuB,EAAEC,wBAAwB,EAAE,GAAGV;IAC9D,MAAM,EAAEW,uBAAuB,EAAE,GAAGF;IACpC,MAAM,EAAEG,SAAS,EAAE,GAAGhB;IACtB,MAAM,EAAEiB,WAAW,EAAE,GAAGf;IACxB,MAAM,EAAEgB,iCAAiC,EAAEC,kCAAkC,EAAE,GAAGhB;IAElF,MAAMiB,oBAAoB;QACxB,MAAMC,0BACJtB,oBAAoBiB,cAAcL,UAAUW,IAAI,CAACC,QAAQ,KAAKP,UAAUQ,YAAY;QAEtF,iBAAiB;QACjB,0FAA0F;QAC1F,iEAAiE;QACjE,IAAIH,2BAA2BN,yBAAyB;YACtDG,kCAAkC;gBAChCO,eAAe,CAACC,sBAAsBC;oBACpC,IAAI5B,oBAAoBiB,cAAcU,yBAAyB,MAAM;wBACnEf,UAAUW,IAAI,CAACC,QAAQ,GAAGP,UAAUQ,YAAY;oBAClD;oBACA,IAAIG,yBAAyB,MAAM;wBACjC,MAAMC,YAAYd;wBAClBH,UAAUW,IAAI,CAACM,SAAS,GAAGA;oBAC7B;oBACAhB,aAAaD;oBACbkB;gBACF;gBACAC,UAAU;oBACRX;gBACF;gBACAE;gBACAN;YACF;QACF,OAAO;YACLc;QACF;IACF;IAEA,MAAMA,gBAAgB;QACpB,IAAIvB,QAAQ;YACV,IAAI;gBACFI,mBAAmB;gBACnB,MAAMJ,OAAOK;gBACbQ;gBACAF,YAAY;YACd,EAAE,OAAOc,OAAO;gBACd,MAAM,IAAIC,MAAM,CAAC,8CAA8C,EAAED,MAAM,CAAC;YAC1E,SAAU;gBACRrB,mBAAmB;YACrB;QACF,OAAO;YACLO,YAAY;QACd;IACF;IAEA,qBACE,KAACnB;QAAOU,SAASA;QAASyB,SAASb;QAAmBc,UAAU3B,cAAcE;kBAAmB;;AAIrG,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.tsx"],"sourcesContent":["// Copyright 2024 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 { ReactElement, useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport { isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport {\n OnSaveDashboard,\n useDashboard,\n useEditMode,\n useSaveChangesConfirmationDialog,\n useVariableDefinitionActions,\n} from '../../context';\n\nexport interface SaveDashboardButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n onSave?: OnSaveDashboard;\n isDisabled: boolean;\n variant?: 'contained' | 'text' | 'outlined';\n}\n\nexport const SaveDashboardButton = ({\n onSave,\n isDisabled,\n variant = 'contained',\n}: SaveDashboardButtonProps): ReactElement => {\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const { dashboard, setDashboard } = useDashboard();\n const { getSavedVariablesStatus, setVariableDefaultValues } = useVariableDefinitionActions();\n const { isSavedVariableModified } = getSavedVariablesStatus();\n const { timeRange } = useTimeRange();\n const { setEditMode } = useEditMode();\n const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();\n\n const onSaveButtonClick = (): void => {\n const isSavedDurationModified =\n isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;\n\n // Save dashboard\n // - if active timeRange from plugin-system is relative and different from currently saved\n // - or if the saved variables are different from currently saved\n if (isSavedDurationModified || isSavedVariableModified) {\n openSaveChangesConfirmationDialog({\n onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables) => {\n if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange === true) {\n dashboard.spec.duration = timeRange.pastDuration;\n }\n if (saveDefaultVariables === true) {\n const variables = setVariableDefaultValues();\n dashboard.spec.variables = variables;\n }\n setDashboard(dashboard);\n saveDashboard();\n },\n onCancel: () => {\n closeSaveChangesConfirmationDialog();\n },\n isSavedDurationModified,\n isSavedVariableModified,\n });\n } else {\n saveDashboard();\n }\n };\n\n const saveDashboard = async (): Promise<void> => {\n if (onSave) {\n try {\n setSavingDashboard(true);\n await onSave(dashboard);\n closeSaveChangesConfirmationDialog();\n setEditMode(false);\n } catch (error) {\n throw new Error(`An error occurred while saving the dashboard. ${error}`);\n } finally {\n setSavingDashboard(false);\n }\n } else {\n setEditMode(false);\n }\n };\n\n return (\n <Button variant={variant} onClick={onSaveButtonClick} disabled={isDisabled || isSavingDashboard}>\n Save\n </Button>\n );\n};\n"],"names":["useState","Button","isRelativeTimeRange","useTimeRange","useDashboard","useEditMode","useSaveChangesConfirmationDialog","useVariableDefinitionActions","SaveDashboardButton","onSave","isDisabled","variant","isSavingDashboard","setSavingDashboard","dashboard","setDashboard","getSavedVariablesStatus","setVariableDefaultValues","isSavedVariableModified","timeRange","setEditMode","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","onSaveButtonClick","isSavedDurationModified","spec","duration","pastDuration","onSaveChanges","saveDefaultTimeRange","saveDefaultVariables","variables","saveDashboard","onCancel","error","Error","onClick","disabled"],"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,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAEEC,YAAY,EACZC,WAAW,EACXC,gCAAgC,EAChCC,4BAA4B,QACvB,gBAAgB;AAQvB,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,MAAM,EACNC,UAAU,EACVC,UAAU,WAAW,EACI;IACzB,MAAM,CAACC,mBAAmBC,mBAAmB,GAAGb,SAAkB;IAClE,MAAM,EAAEc,SAAS,EAAEC,YAAY,EAAE,GAAGX;IACpC,MAAM,EAAEY,uBAAuB,EAAEC,wBAAwB,EAAE,GAAGV;IAC9D,MAAM,EAAEW,uBAAuB,EAAE,GAAGF;IACpC,MAAM,EAAEG,SAAS,EAAE,GAAGhB;IACtB,MAAM,EAAEiB,WAAW,EAAE,GAAGf;IACxB,MAAM,EAAEgB,iCAAiC,EAAEC,kCAAkC,EAAE,GAAGhB;IAElF,MAAMiB,oBAAoB;QACxB,MAAMC,0BACJtB,oBAAoBiB,cAAcL,UAAUW,IAAI,CAACC,QAAQ,KAAKP,UAAUQ,YAAY;QAEtF,iBAAiB;QACjB,0FAA0F;QAC1F,iEAAiE;QACjE,IAAIH,2BAA2BN,yBAAyB;YACtDG,kCAAkC;gBAChCO,eAAe,CAACC,sBAAsBC;oBACpC,IAAI5B,oBAAoBiB,cAAcU,yBAAyB,MAAM;wBACnEf,UAAUW,IAAI,CAACC,QAAQ,GAAGP,UAAUQ,YAAY;oBAClD;oBACA,IAAIG,yBAAyB,MAAM;wBACjC,MAAMC,YAAYd;wBAClBH,UAAUW,IAAI,CAACM,SAAS,GAAGA;oBAC7B;oBACAhB,aAAaD;oBACbkB;gBACF;gBACAC,UAAU;oBACRX;gBACF;gBACAE;gBACAN;YACF;QACF,OAAO;YACLc;QACF;IACF;IAEA,MAAMA,gBAAgB;QACpB,IAAIvB,QAAQ;YACV,IAAI;gBACFI,mBAAmB;gBACnB,MAAMJ,OAAOK;gBACbQ;gBACAF,YAAY;YACd,EAAE,OAAOc,OAAO;gBACd,MAAM,IAAIC,MAAM,CAAC,8CAA8C,EAAED,MAAM,CAAC;YAC1E,SAAU;gBACRrB,mBAAmB;YACrB;QACF,OAAO;YACLO,YAAY;QACd;IACF;IAEA,qBACE,KAACnB;QAAOU,SAASA;QAASyB,SAASb;QAAmBc,UAAU3B,cAAcE;kBAAmB;;AAIrG,EAAE"}
@@ -1,7 +1,8 @@
1
1
  import { BuiltinVariableDefinition } from '@perses-dev/core';
2
+ import { ReactElement } from 'react';
2
3
  type BuiltinVariableAccordionsProps = {
3
4
  builtinVariableDefinitions: BuiltinVariableDefinition[];
4
5
  };
5
- export declare function BuiltinVariableAccordions({ builtinVariableDefinitions }: BuiltinVariableAccordionsProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function BuiltinVariableAccordions({ builtinVariableDefinitions, }: BuiltinVariableAccordionsProps): ReactElement;
6
7
  export {};
7
8
  //# sourceMappingURL=BuiltinVariableAccordions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuiltinVariableAccordions.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/BuiltinVariableAccordions.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAiB7D,KAAK,8BAA8B,GAAG;IACpC,0BAA0B,EAAE,yBAAyB,EAAE,CAAC;CACzD,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,EAAE,0BAA0B,EAAE,EAAE,8BAA8B,2CA0EvG"}
1
+ {"version":3,"file":"BuiltinVariableAccordions.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/BuiltinVariableAccordions.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAe7D,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,KAAK,8BAA8B,GAAG;IACpC,0BAA0B,EAAE,yBAAyB,EAAE,CAAC;CACzD,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,EACxC,0BAA0B,GAC3B,EAAE,8BAA8B,GAAG,YAAY,CA0E/C"}
@@ -44,9 +44,7 @@ export function BuiltinVariableAccordions({ builtinVariableDefinitions }) {
44
44
  builtinVariablesBySource
45
45
  ]);
46
46
  return /*#__PURE__*/ _jsx(_Fragment, {
47
- children: sources.map((source)=>/*#__PURE__*/ {
48
- var _builtinVariablesBySource_source;
49
- return _jsxs(Accordion, {
47
+ children: sources.map((source)=>/*#__PURE__*/ _jsxs(Accordion, {
50
48
  sx: (theme)=>({
51
49
  '.MuiAccordionSummary-root': {
52
50
  backgroundColor: theme.palette.background.lighter
@@ -63,12 +61,12 @@ export function BuiltinVariableAccordions({ builtinVariableDefinitions }) {
63
61
  children: /*#__PURE__*/ _jsx(Typography, {
64
62
  variant: "h2",
65
63
  children: /*#__PURE__*/ _jsx(InfoTooltip, {
66
- title: `${source} Builtin Variables`,
64
+ title: `${source} Built-in Variables`,
67
65
  description: "Variables computed during dashboard rendering.",
68
66
  children: /*#__PURE__*/ _jsxs("span", {
69
67
  children: [
70
68
  source,
71
- " Builtin Variables"
69
+ " Built-in Variables"
72
70
  ]
73
71
  })
74
72
  })
@@ -95,10 +93,7 @@ export function BuiltinVariableAccordions({ builtinVariableDefinitions }) {
95
93
  })
96
94
  }),
97
95
  /*#__PURE__*/ _jsx(TableBody, {
98
- children: ((_builtinVariablesBySource_source = builtinVariablesBySource[source]) !== null && _builtinVariablesBySource_source !== void 0 ? _builtinVariablesBySource_source : []).map((v)=>/*#__PURE__*/ {
99
- var _v_spec_display;
100
- var _v_spec_display_description;
101
- return _jsxs(TableRow, {
96
+ children: (builtinVariablesBySource[source] ?? []).map((v)=>/*#__PURE__*/ _jsxs(TableRow, {
102
97
  children: [
103
98
  /*#__PURE__*/ _jsx(TableCell, {
104
99
  component: "th",
@@ -109,19 +104,17 @@ export function BuiltinVariableAccordions({ builtinVariableDefinitions }) {
109
104
  children: v.spec.name
110
105
  }),
111
106
  /*#__PURE__*/ _jsx(TableCell, {
112
- children: (_v_spec_display_description = (_v_spec_display = v.spec.display) === null || _v_spec_display === void 0 ? void 0 : _v_spec_display.description) !== null && _v_spec_display_description !== void 0 ? _v_spec_display_description : ''
107
+ children: v.spec.display?.description ?? ''
113
108
  })
114
109
  ]
115
- }, source + '-' + v.spec.name);
116
- })
110
+ }, source + '-' + v.spec.name))
117
111
  })
118
112
  ]
119
113
  })
120
114
  })
121
115
  })
122
116
  ]
123
- }, source);
124
- })
117
+ }, source))
125
118
  });
126
119
  }
127
120
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Variables/BuiltinVariableAccordions.tsx"],"sourcesContent":["// Copyright 2023 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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material';\nimport ExpandMoreIcon from 'mdi-material-ui/ChevronUp';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { useMemo } from 'react';\n\ntype BuiltinVariableAccordionsProps = {\n builtinVariableDefinitions: BuiltinVariableDefinition[];\n};\n\nexport function BuiltinVariableAccordions({ builtinVariableDefinitions }: BuiltinVariableAccordionsProps) {\n const builtinVariablesBySource = useMemo(() => {\n const result: Record<string, BuiltinVariableDefinition[]> = {};\n for (const definition of builtinVariableDefinitions) {\n const value = result[definition.spec.source];\n if (value) {\n value.push(definition);\n continue;\n }\n result[definition.spec.source] = [definition];\n }\n return result;\n }, [builtinVariableDefinitions]);\n\n const sources = useMemo(() => {\n const result: string[] = [];\n for (const source in builtinVariablesBySource) {\n if (!result.includes(source)) {\n result.push(source);\n }\n }\n return result;\n }, [builtinVariablesBySource]);\n\n return (\n <>\n {sources.map((source) => (\n <Accordion\n key={source}\n sx={(theme) => ({\n '.MuiAccordionSummary-root': {\n backgroundColor: theme.palette.background.lighter,\n },\n '.MuiAccordionDetails-root': {\n backgroundColor: theme.palette.background.lighter,\n },\n })}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />} aria-controls=\"builtin\" id=\"builtin\">\n <Typography variant=\"h2\">\n <InfoTooltip\n title={`${source} Builtin Variables`}\n description=\"Variables computed during dashboard rendering.\"\n >\n <span>{source} Builtin Variables</span>\n </InfoTooltip>\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of external variables\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Description</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {(builtinVariablesBySource[source] ?? []).map((v) => (\n <TableRow key={source + '-' + v.spec.name}>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {v.spec.name}\n </TableCell>\n <TableCell>{v.spec.display?.description ?? ''}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </TableContainer>\n </AccordionDetails>\n </Accordion>\n ))}\n </>\n );\n}\n"],"names":["Accordion","AccordionDetails","AccordionSummary","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","ExpandMoreIcon","InfoTooltip","useMemo","BuiltinVariableAccordions","builtinVariableDefinitions","builtinVariablesBySource","result","definition","value","spec","source","push","sources","includes","map","sx","theme","backgroundColor","palette","background","lighter","expandIcon","aria-controls","id","variant","title","description","span","minWidth","aria-label","v","component","scope","fontWeight","name","display"],"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;;AAGjC,SACEA,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAgB;AACvB,OAAOC,oBAAoB,4BAA4B;AACvD,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,OAAO,QAAQ,QAAQ;AAMhC,OAAO,SAASC,0BAA0B,EAAEC,0BAA0B,EAAkC;IACtG,MAAMC,2BAA2BH,QAAQ;QACvC,MAAMI,SAAsD,CAAC;QAC7D,KAAK,MAAMC,cAAcH,2BAA4B;YACnD,MAAMI,QAAQF,MAAM,CAACC,WAAWE,IAAI,CAACC,MAAM,CAAC;YAC5C,IAAIF,OAAO;gBACTA,MAAMG,IAAI,CAACJ;gBACX;YACF;YACAD,MAAM,C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;4DAAEkB,YAAY;wDAAO;kEAC5DH,EAAErB,IAAI,CAACyB,IAAI;;kEAEd,KAACvC;kEAAWmC,CAAAA,+BAAAA,kBAAAA,EAAErB,IAAI,CAAC0B,OAAO,cAAdL,sCAAAA,gBAAgBJ,WAAW,cAA3BI,yCAAAA,8BAA+B;;;+CAJ9BpB,SAAS,MAAMoB,EAAErB,IAAI,CAACyB,IAAI;wCAK/B;;;;;;;eApCfxB;QA0CI;;AAInB"}
1
+ {"version":3,"sources":["../../../src/components/Variables/BuiltinVariableAccordions.tsx"],"sourcesContent":["// Copyright 2023 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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material';\nimport ExpandMoreIcon from 'mdi-material-ui/ChevronUp';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement, useMemo } from 'react';\n\ntype BuiltinVariableAccordionsProps = {\n builtinVariableDefinitions: BuiltinVariableDefinition[];\n};\n\nexport function BuiltinVariableAccordions({\n builtinVariableDefinitions,\n}: BuiltinVariableAccordionsProps): ReactElement {\n const builtinVariablesBySource = useMemo(() => {\n const result: Record<string, BuiltinVariableDefinition[]> = {};\n for (const definition of builtinVariableDefinitions) {\n const value = result[definition.spec.source];\n if (value) {\n value.push(definition);\n continue;\n }\n result[definition.spec.source] = [definition];\n }\n return result;\n }, [builtinVariableDefinitions]);\n\n const sources = useMemo(() => {\n const result: string[] = [];\n for (const source in builtinVariablesBySource) {\n if (!result.includes(source)) {\n result.push(source);\n }\n }\n return result;\n }, [builtinVariablesBySource]);\n\n return (\n <>\n {sources.map((source) => (\n <Accordion\n key={source}\n sx={(theme) => ({\n '.MuiAccordionSummary-root': {\n backgroundColor: theme.palette.background.lighter,\n },\n '.MuiAccordionDetails-root': {\n backgroundColor: theme.palette.background.lighter,\n },\n })}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />} aria-controls=\"builtin\" id=\"builtin\">\n <Typography variant=\"h2\">\n <InfoTooltip\n title={`${source} Built-in Variables`}\n description=\"Variables computed during dashboard rendering.\"\n >\n <span>{source} Built-in Variables</span>\n </InfoTooltip>\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of external variables\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Description</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {(builtinVariablesBySource[source] ?? []).map((v) => (\n <TableRow key={source + '-' + v.spec.name}>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {v.spec.name}\n </TableCell>\n <TableCell>{v.spec.display?.description ?? ''}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </TableContainer>\n </AccordionDetails>\n </Accordion>\n ))}\n </>\n );\n}\n"],"names":["Accordion","AccordionDetails","AccordionSummary","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","ExpandMoreIcon","InfoTooltip","useMemo","BuiltinVariableAccordions","builtinVariableDefinitions","builtinVariablesBySource","result","definition","value","spec","source","push","sources","includes","map","sx","theme","backgroundColor","palette","background","lighter","expandIcon","aria-controls","id","variant","title","description","span","minWidth","aria-label","v","component","scope","fontWeight","name","display"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;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A,KAACxB;4BAAWyB,SAAQ;sCAClB,cAAA,KAACvB;gCACCwB,OAAO,CAAC,EAAEf,OAAO,mBAAmB,CAAC;gCACrCgB,aAAY;0CAEZ,cAAA,MAACC;;wCAAMjB;wCAAO;;;;;;kCAIpB,KAACnB;kCACC,cAAA,KAACK;sCACC,cAAA,MAACH;gCAAMsB,IAAI;oCAAEa,UAAU;gCAAI;gCAAGC,cAAW;;kDACvC,KAAChC;kDACC,cAAA,MAACC;;8DACC,KAACH;8DAAU;;8DACX,KAACA;8DAAU;;;;;kDAGf,KAACD;kDACE,AAACW,CAAAA,wBAAwB,CAACK,OAAO,IAAI,EAAE,AAAD,EAAGI,GAAG,CAAC,CAACgB,kBAC7C,MAAChC;;kEACC,KAACH;wDAAUoC,WAAU;wDAAKC,OAAM;wDAAMjB,IAAI;4DAAEkB,YAAY;wDAAO;kEAC5DH,EAAErB,IAAI,CAACyB,IAAI;;kEAEd,KAACvC;kEAAWmC,EAAErB,IAAI,CAAC0B,OAAO,EAAET,eAAe;;;+CAJ9BhB,SAAS,MAAMoB,EAAErB,IAAI,CAACyB,IAAI;;;;;;;eA/B9CxB;;AA8Cf"}
@@ -1,3 +1,4 @@
1
+ import { ReactElement } from 'react';
1
2
  import { ButtonProps } from '@mui/material';
2
3
  export interface EditVariablesButtonProps extends Pick<ButtonProps, 'fullWidth'> {
3
4
  /**
@@ -13,5 +14,5 @@ export interface EditVariablesButtonProps extends Pick<ButtonProps, 'fullWidth'>
13
14
  */
14
15
  label?: string;
15
16
  }
16
- export declare function EditVariablesButton({ variant, label, color, fullWidth, }: EditVariablesButtonProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function EditVariablesButton({ variant, label, color, fullWidth, }: EditVariablesButtonProps): ReactElement;
17
18
  //# sourceMappingURL=EditVariablesButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditVariablesButton.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAcpD,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9E;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAgB,EAChB,KAAmB,EACnB,KAAiB,EACjB,SAAS,GACV,EAAE,wBAAwB,2CAiD1B"}
1
+ {"version":3,"file":"EditVariablesButton.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAcpD,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9E;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAgB,EAChB,KAAmB,EACnB,KAAiB,EACjB,SAAS,GACV,EAAE,wBAAwB,GAAG,YAAY,CAiDzC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -17,14 +17,14 @@ import PencilIcon from 'mdi-material-ui/PencilOutline';
17
17
  import { Drawer, InfoTooltip } from '@perses-dev/components';
18
18
  import { useBuiltinVariableDefinitions } from '@perses-dev/plugin-system';
19
19
  import { TOOLTIP_TEXT, editButtonStyle } from '../../constants';
20
- import { useTemplateExternalVariableDefinitions, useTemplateVariableActions, useTemplateVariableDefinitions } from '../../context';
20
+ import { useExternalVariableDefinitions, useVariableDefinitionActions, useVariableDefinitions } from '../../context';
21
21
  import { VariableEditor } from './VariableEditor';
22
22
  export function EditVariablesButton({ variant = 'text', label = 'Variables', color = 'primary', fullWidth }) {
23
23
  const [isVariableEditorOpen, setIsVariableEditorOpen] = useState(false);
24
- const variableDefinitions = useTemplateVariableDefinitions();
25
- const externalVariableDefinitions = useTemplateExternalVariableDefinitions();
24
+ const variableDefinitions = useVariableDefinitions();
25
+ const externalVariableDefinitions = useExternalVariableDefinitions();
26
26
  const builtinVariableDefinitions = useBuiltinVariableDefinitions();
27
- const { setVariableDefinitions } = useTemplateVariableActions();
27
+ const { setVariableDefinitions } = useVariableDefinitionActions();
28
28
  const openVariableEditor = ()=>{
29
29
  setIsVariableEditorOpen(true);
30
30
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"sourcesContent":["// Copyright 2023 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 { useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { BuiltinVariableDefinition, VariableDefinition } from '@perses-dev/core';\nimport { useBuiltinVariableDefinitions } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport {\n ExternalVariableDefinition,\n useTemplateExternalVariableDefinitions,\n useTemplateVariableActions,\n useTemplateVariableDefinitions,\n} from '../../context';\nimport { VariableEditor } from './VariableEditor';\n\nexport interface EditVariablesButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport function EditVariablesButton({\n variant = 'text',\n label = 'Variables',\n color = 'primary',\n fullWidth,\n}: EditVariablesButtonProps) {\n const [isVariableEditorOpen, setIsVariableEditorOpen] = useState(false);\n const variableDefinitions: VariableDefinition[] = useTemplateVariableDefinitions();\n const externalVariableDefinitions: ExternalVariableDefinition[] = useTemplateExternalVariableDefinitions();\n const builtinVariableDefinitions: BuiltinVariableDefinition[] = useBuiltinVariableDefinitions();\n const { setVariableDefinitions } = useTemplateVariableActions();\n\n const openVariableEditor = () => {\n setIsVariableEditorOpen(true);\n };\n\n const closeVariableEditor = () => {\n setIsVariableEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editVariables}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openVariableEditor}\n aria-label={TOOLTIP_TEXT.editVariables}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isVariableEditorOpen}\n onClose={closeVariableEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"variable-editor\"\n >\n <VariableEditor\n variableDefinitions={variableDefinitions}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariableDefinitions}\n onCancel={closeVariableEditor}\n onChange={(variables: VariableDefinition[]) => {\n setVariableDefinitions(variables);\n setIsVariableEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useBuiltinVariableDefinitions","TOOLTIP_TEXT","editButtonStyle","useTemplateExternalVariableDefinitions","useTemplateVariableActions","useTemplateVariableDefinitions","VariableEditor","EditVariablesButton","variant","label","color","fullWidth","isVariableEditorOpen","setIsVariableEditorOpen","variableDefinitions","externalVariableDefinitions","builtinVariableDefinitions","setVariableDefinitions","openVariableEditor","closeVariableEditor","description","editVariables","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","variables"],"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,QAAQ,QAAQ,QAAQ;AACjC,SAASC,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,6BAA6B,QAAQ,4BAA4B;AAC1E,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAEEC,sCAAsC,EACtCC,0BAA0B,EAC1BC,8BAA8B,QACzB,gBAAgB;AACvB,SAASC,cAAc,QAAQ,mBAAmB;AAmBlD,OAAO,SAASC,oBAAoB,EAClCC,UAAU,MAAM,EAChBC,QAAQ,WAAW,EACnBC,QAAQ,SAAS,EACjBC,SAAS,EACgB;IACzB,MAAM,CAACC,sBAAsBC,wBAAwB,GAAGlB,SAAS;IACjE,MAAMmB,sBAA4CT;IAClD,MAAMU,8BAA4DZ;IAClE,MAAMa,6BAA0DhB;IAChE,MAAM,EAAEiB,sBAAsB,EAAE,GAAGb;IAEnC,MAAMc,qBAAqB;QACzBL,wBAAwB;IAC1B;IAEA,MAAMM,sBAAsB;QAC1BN,wBAAwB;IAC1B;IAEA,qBACE;;0BACE,KAACd;gBAAYqB,aAAanB,aAAaoB,aAAa;0BAClD,cAAA,KAACzB;oBACC0B,yBAAW,KAACzB;oBACZ0B,SAASL;oBACTM,cAAYvB,aAAaoB,aAAa;oBACtCb,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXc,IAAIvB;8BAEHO;;;0BAGL,KAACX;gBACC4B,QAAQd;gBACRe,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACxB;oBACCQ,qBAAqBA;oBACrBC,6BAA6BA;oBAC7BC,4BAA4BA;oBAC5Be,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,uBAAuBgB;wBACvBpB,wBAAwB;oBAC1B;;;;;AAKV"}
1
+ {"version":3,"sources":["../../../src/components/Variables/EditVariablesButton.tsx"],"sourcesContent":["// Copyright 2024 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 { ReactElement, useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { BuiltinVariableDefinition, VariableDefinition } from '@perses-dev/core';\nimport { useBuiltinVariableDefinitions } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport {\n ExternalVariableDefinition,\n useExternalVariableDefinitions,\n useVariableDefinitionActions,\n useVariableDefinitions,\n} from '../../context';\nimport { VariableEditor } from './VariableEditor';\n\nexport interface EditVariablesButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport function EditVariablesButton({\n variant = 'text',\n label = 'Variables',\n color = 'primary',\n fullWidth,\n}: EditVariablesButtonProps): ReactElement {\n const [isVariableEditorOpen, setIsVariableEditorOpen] = useState(false);\n const variableDefinitions: VariableDefinition[] = useVariableDefinitions();\n const externalVariableDefinitions: ExternalVariableDefinition[] = useExternalVariableDefinitions();\n const builtinVariableDefinitions: BuiltinVariableDefinition[] = useBuiltinVariableDefinitions();\n const { setVariableDefinitions } = useVariableDefinitionActions();\n\n const openVariableEditor = (): void => {\n setIsVariableEditorOpen(true);\n };\n\n const closeVariableEditor = (): void => {\n setIsVariableEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editVariables}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openVariableEditor}\n aria-label={TOOLTIP_TEXT.editVariables}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isVariableEditorOpen}\n onClose={closeVariableEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"variable-editor\"\n >\n <VariableEditor\n variableDefinitions={variableDefinitions}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariableDefinitions}\n onCancel={closeVariableEditor}\n onChange={(variables: VariableDefinition[]) => {\n setVariableDefinitions(variables);\n setIsVariableEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useBuiltinVariableDefinitions","TOOLTIP_TEXT","editButtonStyle","useExternalVariableDefinitions","useVariableDefinitionActions","useVariableDefinitions","VariableEditor","EditVariablesButton","variant","label","color","fullWidth","isVariableEditorOpen","setIsVariableEditorOpen","variableDefinitions","externalVariableDefinitions","builtinVariableDefinitions","setVariableDefinitions","openVariableEditor","closeVariableEditor","description","editVariables","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","variables"],"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,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,6BAA6B,QAAQ,4BAA4B;AAC1E,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAEEC,8BAA8B,EAC9BC,4BAA4B,EAC5BC,sBAAsB,QACjB,gBAAgB;AACvB,SAASC,cAAc,QAAQ,mBAAmB;AAmBlD,OAAO,SAASC,oBAAoB,EAClCC,UAAU,MAAM,EAChBC,QAAQ,WAAW,EACnBC,QAAQ,SAAS,EACjBC,SAAS,EACgB;IACzB,MAAM,CAACC,sBAAsBC,wBAAwB,GAAGlB,SAAS;IACjE,MAAMmB,sBAA4CT;IAClD,MAAMU,8BAA4DZ;IAClE,MAAMa,6BAA0DhB;IAChE,MAAM,EAAEiB,sBAAsB,EAAE,GAAGb;IAEnC,MAAMc,qBAAqB;QACzBL,wBAAwB;IAC1B;IAEA,MAAMM,sBAAsB;QAC1BN,wBAAwB;IAC1B;IAEA,qBACE;;0BACE,KAACd;gBAAYqB,aAAanB,aAAaoB,aAAa;0BAClD,cAAA,KAACzB;oBACC0B,yBAAW,KAACzB;oBACZ0B,SAASL;oBACTM,cAAYvB,aAAaoB,aAAa;oBACtCb,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXc,IAAIvB;8BAEHO;;;0BAGL,KAACX;gBACC4B,QAAQd;gBACRe,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACxB;oBACCQ,qBAAqBA;oBACrBC,6BAA6BA;oBAC7BC,4BAA4BA;oBAC5Be,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,uBAAuBgB;wBACvBpB,wBAAwB;oBAC1B;;;;;AAKV"}
@@ -1,12 +1,13 @@
1
- import { ListVariableSpec, UnknownSpec, VariableName, VariableValue } from '@perses-dev/core';
1
+ import { ReactElement } from 'react';
2
+ import { ListVariableSpec, VariableName, VariableValue } from '@perses-dev/core';
2
3
  import { VariableOption, VariableState } from '@perses-dev/plugin-system';
3
4
  import { UseQueryResult } from '@tanstack/react-query';
4
- type TemplateVariableProps = {
5
+ type VariableProps = {
5
6
  name: VariableName;
6
7
  source?: string;
7
8
  };
8
- export declare function TemplateVariable({ name, source }: TemplateVariableProps): import("react/jsx-runtime").JSX.Element;
9
- export declare function useListVariableState(spec: ListVariableSpec<UnknownSpec> | undefined, state: VariableState | undefined, variablesOptionsQuery: Partial<UseQueryResult<VariableOption[]>>): {
9
+ export declare function Variable({ name, source }: VariableProps): ReactElement;
10
+ export declare function useListVariableState(spec: ListVariableSpec | undefined, state: VariableState | undefined, variablesOptionsQuery: Partial<UseQueryResult<VariableOption[]>>): {
10
11
  value: VariableValue | undefined;
11
12
  loading: boolean;
12
13
  options: VariableOption[] | undefined;
@@ -14,4 +15,4 @@ export declare function useListVariableState(spec: ListVariableSpec<UnknownSpec>
14
15
  viewOptions: VariableOption[];
15
16
  };
16
17
  export {};
17
- //# sourceMappingURL=TemplateVariable.d.ts.map
18
+ //# sourceMappingURL=Variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/Variable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAgC,MAAM,OAAO,CAAC;AAEnE,OAAO,EAGL,gBAAgB,EAEhB,YAAY,EACZ,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA+B,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAcF,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,YAAY,CAWtE;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,gBAAgB,GAAG,SAAS,EAClC,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,qBAAqB,EAAE,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,GAC/D;IAED,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IAEtC,eAAe,EAAE,cAAc,GAAG,cAAc,EAAE,CAAC;IAEnD,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B,CA2FA"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -15,8 +15,8 @@ import { useEffect, useMemo, useState } from 'react';
15
15
  import { LinearProgress, TextField, Autocomplete, Popper } from '@mui/material';
16
16
  import { DEFAULT_ALL_VALUE } from '@perses-dev/core';
17
17
  import { useListVariablePluginValues } from '@perses-dev/plugin-system';
18
- import { useTemplateVariable, useTemplateVariableActions } from '../../context';
19
- import { MAX_TEMPLATE_VARIABLE_WIDTH, MIN_TEMPLATE_VARIABLE_WIDTH } from '../../constants';
18
+ import { useVariableDefinitionAndState, useVariableDefinitionActions } from '../../context';
19
+ import { MAX_VARIABLE_WIDTH, MIN_VARIABLE_WIDTH } from '../../constants';
20
20
  function variableOptionToVariableValue(options) {
21
21
  if (options === null) {
22
22
  return null;
@@ -28,10 +28,9 @@ function variableOptionToVariableValue(options) {
28
28
  }
29
29
  return options.value;
30
30
  }
31
- export function TemplateVariable({ name, source }) {
32
- var _ctx_definition;
33
- const ctx = useTemplateVariable(name, source);
34
- const kind = (_ctx_definition = ctx.definition) === null || _ctx_definition === void 0 ? void 0 : _ctx_definition.kind;
31
+ export function Variable({ name, source }) {
32
+ const ctx = useVariableDefinitionAndState(name, source);
33
+ const kind = ctx.definition?.kind;
35
34
  switch(kind){
36
35
  case 'TextVariable':
37
36
  return /*#__PURE__*/ _jsx(TextVariable, {
@@ -52,22 +51,16 @@ export function TemplateVariable({ name, source }) {
52
51
  });
53
52
  }
54
53
  export function useListVariableState(spec, state, variablesOptionsQuery) {
55
- const allowMultiple = (spec === null || spec === void 0 ? void 0 : spec.allowMultiple) === true;
56
- const allowAllValue = (spec === null || spec === void 0 ? void 0 : spec.allowAllValue) === true;
57
- const sort = spec === null || spec === void 0 ? void 0 : spec.sort;
58
- const loading = useMemo(()=>{
59
- var _variablesOptionsQuery_isFetching;
60
- return (_variablesOptionsQuery_isFetching = variablesOptionsQuery.isFetching) !== null && _variablesOptionsQuery_isFetching !== void 0 ? _variablesOptionsQuery_isFetching : false;
61
- }, [
54
+ const allowMultiple = spec?.allowMultiple === true;
55
+ const allowAllValue = spec?.allowAllValue === true;
56
+ const sort = spec?.sort;
57
+ const loading = useMemo(()=>variablesOptionsQuery.isFetching ?? false, [
62
58
  variablesOptionsQuery.isFetching
63
59
  ]);
64
- const options = useMemo(()=>{
65
- var _variablesOptionsQuery_data;
66
- return (_variablesOptionsQuery_data = variablesOptionsQuery.data) !== null && _variablesOptionsQuery_data !== void 0 ? _variablesOptionsQuery_data : [];
67
- }, [
60
+ const options = useMemo(()=>variablesOptionsQuery.data ?? [], [
68
61
  variablesOptionsQuery.data
69
62
  ]);
70
- let value = state === null || state === void 0 ? void 0 : state.value;
63
+ let value = state?.value;
71
64
  // Make sure value is an array if allowMultiple is true
72
65
  if (allowMultiple && !Array.isArray(value)) {
73
66
  value = typeof value === 'string' ? [
@@ -128,8 +121,7 @@ export function useListVariableState(spec, state, variablesOptionsQuery) {
128
121
  allowMultiple
129
122
  ]);
130
123
  value = useMemo(()=>{
131
- var _viewOptions_;
132
- const firstOptionValue = viewOptions === null || viewOptions === void 0 ? void 0 : (_viewOptions_ = viewOptions[allowAllValue ? 1 : 0]) === null || _viewOptions_ === void 0 ? void 0 : _viewOptions_.value;
124
+ const firstOptionValue = viewOptions?.[allowAllValue ? 1 : 0]?.value;
133
125
  // If there is no value but there are options, or the value is not in options, we set the value to the first option.
134
126
  if (firstOptionValue) {
135
127
  if (!valueIsInOptions || !value || value.length === 0) {
@@ -151,13 +143,12 @@ export function useListVariableState(spec, state, variablesOptionsQuery) {
151
143
  // an array, hence this conditional
152
144
  if (Array.isArray(value)) {
153
145
  return viewOptions.filter((o)=>{
154
- return value === null || value === void 0 ? void 0 : value.includes(o.value);
146
+ return value?.includes(o.value);
155
147
  });
156
148
  } else {
157
- var _viewOptions_find;
158
- return (_viewOptions_find = viewOptions.find((o)=>{
149
+ return viewOptions.find((o)=>{
159
150
  return value === o.value;
160
- })) !== null && _viewOptions_find !== void 0 ? _viewOptions_find : {
151
+ }) ?? {
161
152
  value: '',
162
153
  label: ''
163
154
  };
@@ -175,7 +166,6 @@ export function useListVariableState(spec, state, variablesOptionsQuery) {
175
166
  };
176
167
  }
177
168
  const StyledPopper = (props)=>/*#__PURE__*/ _jsx(Popper, {
178
- placeholder: undefined,
179
169
  ...props,
180
170
  sx: {
181
171
  minWidth: 'fit-content'
@@ -185,28 +175,25 @@ const StyledPopper = (props)=>/*#__PURE__*/ _jsx(Popper, {
185
175
  const LETTER_HSIZE = 8; // approximation
186
176
  const ARROW_OFFSET = 40; // right offset for list variables (= take into account the dropdown toggle size)
187
177
  const getWidthPx = (inputValue, kind)=>{
188
- const width = (inputValue.length + 1) * LETTER_HSIZE + (kind == 'list' ? ARROW_OFFSET : 0);
189
- if (width < MIN_TEMPLATE_VARIABLE_WIDTH) {
190
- return MIN_TEMPLATE_VARIABLE_WIDTH;
191
- } else if (width > MAX_TEMPLATE_VARIABLE_WIDTH) {
192
- return MAX_TEMPLATE_VARIABLE_WIDTH;
178
+ const width = (inputValue.length + 1) * LETTER_HSIZE + (kind === 'list' ? ARROW_OFFSET : 0);
179
+ if (width < MIN_VARIABLE_WIDTH) {
180
+ return MIN_VARIABLE_WIDTH;
181
+ } else if (width > MAX_VARIABLE_WIDTH) {
182
+ return MAX_VARIABLE_WIDTH;
193
183
  } else {
194
184
  return width;
195
185
  }
196
186
  };
197
187
  function ListVariable({ name, source }) {
198
- var _definition_spec_display;
199
- const ctx = useTemplateVariable(name, source);
188
+ const ctx = useVariableDefinitionAndState(name, source);
200
189
  const definition = ctx.definition;
201
190
  const variablesOptionsQuery = useListVariablePluginValues(definition);
202
- const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();
203
- const { selectedOptions, value, loading, options, viewOptions } = useListVariableState(definition === null || definition === void 0 ? void 0 : definition.spec, ctx.state, variablesOptionsQuery);
204
- const [inputValue, setInputValue] = useState('');
205
- const [inputWidth, setInputWidth] = useState(MIN_TEMPLATE_VARIABLE_WIDTH);
206
- var _definition_spec_display_name;
207
- const title = (_definition_spec_display_name = definition === null || definition === void 0 ? void 0 : (_definition_spec_display = definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name;
208
- const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allowMultiple) === true;
209
- const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allowAllValue) === true;
191
+ const { setVariableValue, setVariableLoading, setVariableOptions } = useVariableDefinitionActions();
192
+ const { selectedOptions, value, loading, options, viewOptions } = useListVariableState(definition?.spec, ctx.state, variablesOptionsQuery);
193
+ const [inputWidth, setInputWidth] = useState(MIN_VARIABLE_WIDTH);
194
+ const title = definition?.spec.display?.name ?? name;
195
+ const allowMultiple = definition?.spec.allowMultiple === true;
196
+ const allowAllValue = definition?.spec.allowAllValue === true;
210
197
  // Update value when changed
211
198
  useEffect(()=>{
212
199
  if (value) {
@@ -248,7 +235,9 @@ function ListVariable({ name, source }) {
248
235
  limitTags: 3,
249
236
  size: "small",
250
237
  disableClearable: true,
251
- PopperComponent: StyledPopper,
238
+ slots: {
239
+ popper: StyledPopper
240
+ },
252
241
  renderInput: (params)=>{
253
242
  return allowMultiple ? /*#__PURE__*/ _jsx(TextField, {
254
243
  ...params,
@@ -265,9 +254,8 @@ function ListVariable({ name, source }) {
265
254
  '& .MuiInputBase-root': {
266
255
  minHeight: '38px'
267
256
  },
268
- '& .MuiInputBase-root.MuiOutlinedInput-root.MuiInputBase-sizeSmall': {
269
- paddingY: '5px',
270
- paddingLeft: '5px'
257
+ '& .MuiAutocomplete-tag': {
258
+ margin: '1px 2px'
271
259
  }
272
260
  },
273
261
  value: selectedOptions,
@@ -278,9 +266,7 @@ function ListVariable({ name, source }) {
278
266
  setVariableValue(name, variableOptionToVariableValue(value), source);
279
267
  }
280
268
  },
281
- inputValue: inputValue,
282
269
  onInputChange: (_, newInputValue)=>{
283
- setInputValue(newInputValue);
284
270
  if (!allowMultiple) {
285
271
  setInputWidth(getWidthPx(newInputValue, 'list'));
286
272
  }
@@ -292,34 +278,31 @@ function ListVariable({ name, source }) {
292
278
  });
293
279
  }
294
280
  function TextVariable({ name, source }) {
295
- var _definition_spec_display;
296
- const ctx = useTemplateVariable(name, source);
281
+ const ctx = useVariableDefinitionAndState(name, source);
297
282
  const state = ctx.state;
298
283
  const definition = ctx.definition;
299
- var _state_value;
300
- const [tempValue, setTempValue] = useState((_state_value = state === null || state === void 0 ? void 0 : state.value) !== null && _state_value !== void 0 ? _state_value : '');
284
+ const [tempValue, setTempValue] = useState(state?.value ?? '');
301
285
  const [inputWidth, setInputWidth] = useState(getWidthPx(tempValue, 'text'));
302
- const { setVariableValue } = useTemplateVariableActions();
286
+ const { setVariableValue } = useVariableDefinitionActions();
303
287
  useEffect(()=>{
304
- var _state_value;
305
- setTempValue((_state_value = state === null || state === void 0 ? void 0 : state.value) !== null && _state_value !== void 0 ? _state_value : '');
288
+ setTempValue(state?.value ?? '');
306
289
  }, [
307
- state === null || state === void 0 ? void 0 : state.value
290
+ state?.value
308
291
  ]);
309
- var _definition_spec_display_name, _definition_spec_constant;
310
292
  return /*#__PURE__*/ _jsx(TextField, {
311
293
  title: tempValue,
312
294
  value: tempValue,
313
- //onChange={(e) => setTempValue(e.target.value)}
314
295
  onChange: (e)=>{
315
296
  setTempValue(e.target.value);
316
297
  setInputWidth(getWidthPx(e.target.value, 'text'));
317
298
  },
318
299
  onBlur: ()=>setVariableValue(name, tempValue, source),
319
300
  placeholder: name,
320
- label: (_definition_spec_display_name = definition === null || definition === void 0 ? void 0 : (_definition_spec_display = definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name,
321
- InputProps: {
322
- readOnly: (_definition_spec_constant = definition === null || definition === void 0 ? void 0 : definition.spec.constant) !== null && _definition_spec_constant !== void 0 ? _definition_spec_constant : false
301
+ label: definition?.spec.display?.name ?? name,
302
+ slotProps: {
303
+ input: {
304
+ readOnly: definition?.spec.constant ?? false
305
+ }
323
306
  },
324
307
  sx: {
325
308
  width: `${inputWidth}px`,
@@ -333,4 +316,4 @@ function TextVariable({ name, source }) {
333
316
  });
334
317
  }
335
318
 
336
- //# sourceMappingURL=TemplateVariable.js.map
319
+ //# sourceMappingURL=Variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Variables/Variable.tsx"],"sourcesContent":["// Copyright 2024 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 { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { LinearProgress, TextField, Autocomplete, Popper, PopperProps } from '@mui/material';\nimport {\n DEFAULT_ALL_VALUE,\n ListVariableDefinition,\n ListVariableSpec,\n TextVariableDefinition,\n VariableName,\n VariableValue,\n} from '@perses-dev/core';\nimport { useListVariablePluginValues, VariableOption, VariableState } from '@perses-dev/plugin-system';\nimport { UseQueryResult } from '@tanstack/react-query';\nimport { useVariableDefinitionAndState, useVariableDefinitionActions } from '../../context';\nimport { MAX_VARIABLE_WIDTH, MIN_VARIABLE_WIDTH } from '../../constants';\n\ntype VariableProps = {\n name: VariableName;\n source?: string;\n};\n\nfunction variableOptionToVariableValue(options: VariableOption | VariableOption[] | null): VariableValue {\n if (options === null) {\n return null;\n }\n if (Array.isArray(options)) {\n return options.map((v) => {\n return v.value;\n });\n }\n return options.value;\n}\n\nexport function Variable({ name, source }: VariableProps): ReactElement {\n const ctx = useVariableDefinitionAndState(name, source);\n const kind = ctx.definition?.kind;\n switch (kind) {\n case 'TextVariable':\n return <TextVariable name={name} source={source} />;\n case 'ListVariable':\n return <ListVariable name={name} source={source} />;\n }\n\n return <div>Unsupported Variable Kind: ${kind}</div>;\n}\n\nexport function useListVariableState(\n spec: ListVariableSpec | undefined,\n state: VariableState | undefined,\n variablesOptionsQuery: Partial<UseQueryResult<VariableOption[]>>\n): {\n // Value, Loading, Options are modified only when we want to save the changes made\n value: VariableValue | undefined;\n loading: boolean;\n options: VariableOption[] | undefined;\n // selectedOptions is/are the option(s) selected in the view\n selectedOptions: VariableOption | VariableOption[];\n // viewOptions are the options used in the view only (= options + All if allowed)\n viewOptions: VariableOption[];\n} {\n const allowMultiple = spec?.allowMultiple === true;\n const allowAllValue = spec?.allowAllValue === true;\n const sort = spec?.sort;\n const loading = useMemo(() => variablesOptionsQuery.isFetching ?? false, [variablesOptionsQuery.isFetching]);\n const options = useMemo(() => variablesOptionsQuery.data ?? [], [variablesOptionsQuery.data]);\n\n let value = state?.value;\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 // Sort the provided list of options according to the method defined\n const sortedOptions = useMemo((): VariableOption[] => {\n const opts = options ? [...options] : [];\n\n if (!sort || sort === 'none') return opts;\n\n switch (sort) {\n case 'alphabetical-asc':\n return opts.sort((a, b) => (a.label > b.label ? 1 : -1));\n case 'alphabetical-desc':\n return opts.sort((a, b) => (a.label > b.label ? -1 : 1));\n case 'numerical-asc':\n return opts.sort((a, b) => (parseInt(a.label) > parseInt(b.label) ? 1 : -1));\n case 'numerical-desc':\n return opts.sort((a, b) => (parseInt(a.label) < parseInt(b.label) ? 1 : -1));\n case 'alphabetical-ci-asc':\n return opts.sort((a, b) => (a.label.toLowerCase() > b.label.toLowerCase() ? 1 : -1));\n case 'alphabetical-ci-desc':\n return opts.sort((a, b) => (a.label.toLowerCase() > b.label.toLowerCase() ? -1 : 1));\n default:\n return opts;\n }\n }, [options, sort]);\n\n const viewOptions = useMemo(() => {\n let computedOptions = sortedOptions;\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 }, [allowAllValue, sortedOptions]);\n\n const valueIsInOptions = useMemo(\n () =>\n Boolean(\n viewOptions.find((v) => {\n if (allowMultiple) {\n return (value as string[]).includes(v.value);\n }\n return value === v.value;\n })\n ),\n [viewOptions, value, allowMultiple]\n );\n\n value = useMemo(() => {\n const firstOptionValue = viewOptions?.[allowAllValue ? 1 : 0]?.value;\n\n // If there is no value but there are options, or the value is not in options, we set the value to the first option.\n if (firstOptionValue) {\n if (!valueIsInOptions || !value || value.length === 0) {\n return allowMultiple ? [firstOptionValue] : firstOptionValue;\n }\n }\n\n return value;\n }, [viewOptions, value, valueIsInOptions, allowMultiple, allowAllValue]);\n\n const selectedOptions = useMemo(() => {\n // In the case Autocomplete.multiple equals false, Autocomplete.value expects a single object, not\n // an array, hence this conditional\n if (Array.isArray(value)) {\n return viewOptions.filter((o) => {\n return value?.includes(o.value);\n });\n } else {\n return (\n viewOptions.find((o) => {\n return value === o.value;\n }) ?? { value: '', label: '' }\n );\n }\n }, [value, viewOptions]);\n\n return { value, loading, options, selectedOptions, viewOptions };\n}\n\nconst StyledPopper = (props: PopperProps): ReactElement => (\n <Popper {...props} sx={{ minWidth: 'fit-content' }} placement=\"bottom-start\" />\n);\n\nconst LETTER_HSIZE = 8; // approximation\nconst ARROW_OFFSET = 40; // right offset for list variables (= take into account the dropdown toggle size)\nconst getWidthPx = (inputValue: string, kind: 'list' | 'text'): number => {\n const width = (inputValue.length + 1) * LETTER_HSIZE + (kind === 'list' ? ARROW_OFFSET : 0);\n if (width < MIN_VARIABLE_WIDTH) {\n return MIN_VARIABLE_WIDTH;\n } else if (width > MAX_VARIABLE_WIDTH) {\n return MAX_VARIABLE_WIDTH;\n } else {\n return width;\n }\n};\n\nfunction ListVariable({ name, source }: VariableProps): ReactElement {\n const ctx = useVariableDefinitionAndState(name, source);\n const definition = ctx.definition as ListVariableDefinition;\n const variablesOptionsQuery = useListVariablePluginValues(definition);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useVariableDefinitionActions();\n const { selectedOptions, value, loading, options, viewOptions } = useListVariableState(\n definition?.spec,\n ctx.state,\n variablesOptionsQuery\n );\n const [inputWidth, setInputWidth] = useState(MIN_VARIABLE_WIDTH);\n\n const title = definition?.spec.display?.name ?? name;\n const allowMultiple = definition?.spec.allowMultiple === true;\n const allowAllValue = definition?.spec.allowAllValue === true;\n\n // Update value when changed\n useEffect(() => {\n if (value) {\n setVariableValue(name, value, source);\n }\n }, [setVariableValue, name, value, source]);\n\n // Update loading when changed\n useEffect(() => {\n setVariableLoading(name, loading, source);\n }, [setVariableLoading, name, loading, source]);\n\n // Update options when changed\n useEffect(() => {\n if (options) {\n setVariableOptions(name, options, source);\n }\n }, [setVariableOptions, name, options, source]);\n\n return (\n <>\n <Autocomplete\n disablePortal\n disableCloseOnSelect={allowMultiple}\n multiple={allowMultiple}\n fullWidth\n limitTags={3}\n size=\"small\"\n disableClearable\n slots={{ popper: StyledPopper }}\n renderInput={(params) => {\n return allowMultiple ? (\n <TextField {...params} label={title} />\n ) : (\n <TextField {...params} label={title} style={{ width: `${inputWidth}px` }} />\n );\n }}\n sx={{\n '& .MuiInputBase-root': {\n minHeight: '38px',\n },\n '& .MuiAutocomplete-tag': {\n margin: '1px 2px', // Default margin of 2px (Y axis) make min height of the autocomplete 40px\n },\n }}\n value={selectedOptions}\n onChange={(_, value) => {\n if ((value === null || (Array.isArray(value) && value.length === 0)) && allowAllValue) {\n setVariableValue(name, DEFAULT_ALL_VALUE, source);\n } else {\n setVariableValue(name, variableOptionToVariableValue(value), source);\n }\n }}\n onInputChange={(_, newInputValue) => {\n if (!allowMultiple) {\n setInputWidth(getWidthPx(newInputValue, 'list'));\n }\n }}\n options={viewOptions}\n />\n {loading && <LinearProgress />}\n </>\n );\n}\n\nfunction TextVariable({ name, source }: VariableProps): ReactElement {\n const ctx = useVariableDefinitionAndState(name, source);\n const state = ctx.state;\n const definition = ctx.definition as TextVariableDefinition;\n const [tempValue, setTempValue] = useState(state?.value ?? '');\n const [inputWidth, setInputWidth] = useState(getWidthPx(tempValue as string, 'text'));\n const { setVariableValue } = useVariableDefinitionActions();\n\n useEffect(() => {\n setTempValue(state?.value ?? '');\n }, [state?.value]);\n\n return (\n <TextField\n title={tempValue as string}\n value={tempValue}\n onChange={(e) => {\n setTempValue(e.target.value);\n setInputWidth(getWidthPx(e.target.value, 'text'));\n }}\n onBlur={() => setVariableValue(name, tempValue, source)}\n placeholder={name}\n label={definition?.spec.display?.name ?? name}\n slotProps={{\n input: {\n readOnly: definition?.spec.constant ?? false,\n },\n }}\n sx={{\n width: `${inputWidth}px`,\n '& .MuiInputBase-root': {\n minHeight: '38px',\n },\n '& .MuiInputBase-input': {\n textOverflow: 'ellipsis',\n },\n }}\n />\n );\n}\n"],"names":["useEffect","useMemo","useState","LinearProgress","TextField","Autocomplete","Popper","DEFAULT_ALL_VALUE","useListVariablePluginValues","useVariableDefinitionAndState","useVariableDefinitionActions","MAX_VARIABLE_WIDTH","MIN_VARIABLE_WIDTH","variableOptionToVariableValue","options","Array","isArray","map","v","value","Variable","name","source","ctx","kind","definition","TextVariable","ListVariable","div","useListVariableState","spec","state","variablesOptionsQuery","allowMultiple","allowAllValue","sort","loading","isFetching","data","sortedOptions","opts","a","b","label","parseInt","toLowerCase","viewOptions","computedOptions","valueIsInOptions","Boolean","find","includes","firstOptionValue","length","selectedOptions","filter","o","StyledPopper","props","sx","minWidth","placement","LETTER_HSIZE","ARROW_OFFSET","getWidthPx","inputValue","width","setVariableValue","setVariableLoading","setVariableOptions","inputWidth","setInputWidth","title","display","disablePortal","disableCloseOnSelect","multiple","fullWidth","limitTags","size","disableClearable","slots","popper","renderInput","params","style","minHeight","margin","onChange","_","onInputChange","newInputValue","tempValue","setTempValue","e","target","onBlur","placeholder","slotProps","input","readOnly","constant","textOverflow"],"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,SAAuBA,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACnE,SAASC,cAAc,EAAEC,SAAS,EAAEC,YAAY,EAAEC,MAAM,QAAqB,gBAAgB;AAC7F,SACEC,iBAAiB,QAMZ,mBAAmB;AAC1B,SAASC,2BAA2B,QAAuC,4BAA4B;AAEvG,SAASC,6BAA6B,EAAEC,4BAA4B,Q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CAAC5E,KAAK;YAC3BoD,cAAcP,WAAW8B,EAAEC,MAAM,CAAC5E,KAAK,EAAE;QAC3C;QACA6E,QAAQ,IAAM7B,iBAAiB9C,MAAMuE,WAAWtE;QAChD2E,aAAa5E;QACbsB,OAAOlB,YAAYK,KAAK2C,SAASpD,QAAQA;QACzC6E,WAAW;YACTC,OAAO;gBACLC,UAAU3E,YAAYK,KAAKuE,YAAY;YACzC;QACF;QACA1C,IAAI;YACFO,OAAO,CAAC,EAAEI,WAAW,EAAE,CAAC;YACxB,wBAAwB;gBACtBgB,WAAW;YACb;YACA,yBAAyB;gBACvBgB,cAAc;YAChB;QACF;;AAGN"}
@@ -1,3 +1,4 @@
1
+ import { ReactElement } from 'react';
1
2
  import { BuiltinVariableDefinition, VariableDefinition } from '@perses-dev/core';
2
3
  import { VariableState } from '@perses-dev/plugin-system';
3
4
  import { ExternalVariableDefinition } from '../../context';
@@ -7,9 +8,9 @@ export declare function VariableEditor(props: {
7
8
  builtinVariableDefinitions: BuiltinVariableDefinition[];
8
9
  onChange: (variableDefinitions: VariableDefinition[]) => void;
9
10
  onCancel: () => void;
10
- }): import("react/jsx-runtime").JSX.Element;
11
+ }): ReactElement;
11
12
  export declare function VariableName(props: {
12
13
  name: string;
13
14
  state: VariableState | undefined;
14
- }): import("react/jsx-runtime").JSX.Element;
15
+ }): ReactElement;
15
16
  //# sourceMappingURL=VariableEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VariableEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/VariableEditor.tsx"],"names":[],"mappings":"AAoCA,OAAO,EAAU,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAUzF,OAAO,EAAsB,aAAa,EAAkB,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,0BAA0B,EAAuC,MAAM,eAAe,CAAC;AAuBhG,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,mBAAmB,EAAE,kBAAkB,EAAE,CA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