@perses-dev/dashboards 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-histogram-types-78c5104

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 (366) 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 +4 -4
  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/DeletePanelDialog/DeletePanelDialog.js +2 -0
  7. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -4
  8. package/dist/cjs/components/DownloadButton/DownloadButton.js +135 -29
  9. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +10 -13
  10. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +2 -2
  11. package/dist/cjs/components/GridLayout/GridContainer.js +15 -10
  12. package/dist/cjs/components/GridLayout/GridItemContent.js +20 -4
  13. package/dist/cjs/components/GridLayout/GridLayout.js +57 -12
  14. package/dist/cjs/components/GridLayout/GridTitle.js +3 -3
  15. package/dist/cjs/{validation/panel.js → components/Panel/HeaderIconButton.js} +8 -10
  16. package/dist/cjs/components/Panel/Panel.js +19 -11
  17. package/dist/cjs/components/Panel/PanelActions.js +365 -0
  18. package/dist/cjs/components/Panel/PanelContent.js +59 -13
  19. package/dist/cjs/components/Panel/PanelHeader.js +14 -117
  20. package/dist/cjs/components/Panel/PanelLinks.js +136 -0
  21. package/dist/cjs/components/Panel/PanelPluginLoader.js +56 -0
  22. package/dist/cjs/components/Panel/index.js +1 -0
  23. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +9 -6
  24. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +81 -67
  25. package/dist/cjs/components/PanelDrawer/PanelPreview.js +7 -3
  26. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +9 -6
  27. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  28. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  29. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -6
  30. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +2 -2
  31. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +7 -14
  32. package/dist/cjs/components/Variables/EditVariablesButton.js +4 -4
  33. package/dist/cjs/components/Variables/{TemplateVariable.js → Variable.js} +52 -60
  34. package/dist/cjs/components/Variables/VariableEditor.js +34 -40
  35. package/dist/cjs/components/Variables/VariableList.js +23 -22
  36. package/dist/cjs/components/Variables/index.js +2 -2
  37. package/dist/cjs/constants/styles.js +19 -7
  38. package/dist/cjs/constants/user-interface-text.js +3 -1
  39. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +10 -8
  40. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +36 -0
  41. package/dist/cjs/context/DashboardProvider/common.js +2 -2
  42. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +25 -6
  43. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -2
  44. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +7 -10
  45. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  46. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +8 -3
  47. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +79 -0
  48. package/dist/cjs/context/DatasourceStoreProvider.js +18 -23
  49. package/dist/cjs/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +76 -87
  50. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +11 -14
  51. package/dist/cjs/{validation → context/VariableProvider}/index.js +2 -2
  52. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  53. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  54. package/dist/cjs/context/index.js +2 -2
  55. package/dist/cjs/context/useDashboard.js +4 -4
  56. package/dist/cjs/test/datasource-provider.js +1 -1
  57. package/dist/cjs/test/plugin-registry.js +8 -3
  58. package/dist/cjs/test/render.js +13 -11
  59. package/dist/cjs/views/ViewDashboard/DashboardApp.js +6 -4
  60. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +10 -9
  61. package/dist/components/AddGroupButton/AddGroupButton.d.ts +2 -1
  62. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  63. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  64. package/dist/components/AddPanelButton/AddPanelButton.d.ts +2 -1
  65. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  66. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  67. package/dist/components/Dashboard/Dashboard.d.ts +2 -1
  68. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  69. package/dist/components/Dashboard/Dashboard.js +8 -1
  70. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  71. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +2 -1
  72. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  73. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +3 -3
  74. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  75. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +4 -2
  76. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  77. package/dist/components/DashboardToolbar/DashboardToolbar.js +4 -4
  78. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  79. package/dist/components/Datasources/DatasourceEditor.d.ts +2 -1
  80. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  81. package/dist/components/Datasources/DatasourceEditor.js +19 -19
  82. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  83. package/dist/components/Datasources/EditDatasourcesButton.d.ts +2 -1
  84. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  85. package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
  86. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  87. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +2 -1
  88. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  89. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +3 -1
  90. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  91. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +2 -1
  92. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  93. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +6 -5
  94. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  95. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +2 -1
  96. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  97. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  98. package/dist/components/DownloadButton/DownloadButton.d.ts +2 -5
  99. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  100. package/dist/components/DownloadButton/DownloadButton.js +94 -29
  101. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  102. package/dist/components/EditButton/EditButton.d.ts +2 -1
  103. package/dist/components/EditButton/EditButton.d.ts.map +1 -1
  104. package/dist/components/EditButton/EditButton.js.map +1 -1
  105. package/dist/components/EditJsonButton/EditJsonButton.d.ts +2 -1
  106. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  107. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  108. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +2 -1
  109. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  110. package/dist/components/EditJsonDialog/EditJsonDialog.js +7 -10
  111. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  112. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +3 -3
  113. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
  114. package/dist/components/EmptyDashboard/EmptyDashboard.js +2 -2
  115. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  116. package/dist/components/GridLayout/GridContainer.d.ts +5 -3
  117. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  118. package/dist/components/GridLayout/GridContainer.js +15 -10
  119. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  120. package/dist/components/GridLayout/GridItemContent.d.ts +2 -1
  121. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  122. package/dist/components/GridLayout/GridItemContent.js +22 -6
  123. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  124. package/dist/components/GridLayout/GridLayout.d.ts +4 -2
  125. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  126. package/dist/components/GridLayout/GridLayout.js +59 -14
  127. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  128. package/dist/components/GridLayout/GridTitle.d.ts +3 -2
  129. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  130. package/dist/components/GridLayout/GridTitle.js +3 -3
  131. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  132. package/dist/components/Panel/HeaderIconButton.d.ts +5 -0
  133. package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -0
  134. package/dist/{stories/decorators/index.js → components/Panel/HeaderIconButton.js} +7 -6
  135. package/dist/components/Panel/HeaderIconButton.js.map +1 -0
  136. package/dist/components/Panel/Panel.d.ts +16 -5
  137. package/dist/components/Panel/Panel.d.ts.map +1 -1
  138. package/dist/components/Panel/Panel.js +25 -12
  139. package/dist/components/Panel/Panel.js.map +1 -1
  140. package/dist/components/Panel/PanelActions.d.ts +22 -0
  141. package/dist/components/Panel/PanelActions.d.ts.map +1 -0
  142. package/dist/components/Panel/PanelActions.js +352 -0
  143. package/dist/components/Panel/PanelActions.js.map +1 -0
  144. package/dist/components/Panel/PanelContent.d.ts +7 -5
  145. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  146. package/dist/components/Panel/PanelContent.js +61 -15
  147. package/dist/components/Panel/PanelContent.js.map +1 -1
  148. package/dist/components/Panel/PanelHeader.d.ts +10 -8
  149. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  150. package/dist/components/Panel/PanelHeader.js +18 -116
  151. package/dist/components/Panel/PanelHeader.js.map +1 -1
  152. package/dist/components/Panel/PanelLinks.d.ts +6 -0
  153. package/dist/components/Panel/PanelLinks.d.ts.map +1 -0
  154. package/dist/components/Panel/PanelLinks.js +123 -0
  155. package/dist/components/Panel/PanelLinks.js.map +1 -0
  156. package/dist/components/Panel/PanelPluginLoader.d.ts +13 -0
  157. package/dist/components/Panel/PanelPluginLoader.d.ts.map +1 -0
  158. package/dist/components/Panel/PanelPluginLoader.js +51 -0
  159. package/dist/components/Panel/PanelPluginLoader.js.map +1 -0
  160. package/dist/components/Panel/index.d.ts +1 -0
  161. package/dist/components/Panel/index.d.ts.map +1 -1
  162. package/dist/components/Panel/index.js +1 -0
  163. package/dist/components/Panel/index.js.map +1 -1
  164. package/dist/components/PanelDrawer/PanelDrawer.d.ts +2 -1
  165. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  166. package/dist/components/PanelDrawer/PanelDrawer.js +10 -7
  167. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  168. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  169. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  170. package/dist/components/PanelDrawer/PanelEditorForm.js +84 -70
  171. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  172. package/dist/components/PanelDrawer/PanelPreview.d.ts +3 -2
  173. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  174. package/dist/components/PanelDrawer/PanelPreview.js +8 -4
  175. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  176. package/dist/components/PanelDrawer/usePanelEditor.d.ts +12 -10
  177. package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -1
  178. package/dist/components/PanelDrawer/usePanelEditor.js +9 -6
  179. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  180. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +2 -1
  181. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  182. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  183. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  184. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +2 -1
  185. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  186. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  187. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +2 -1
  188. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
  189. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  190. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  191. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +2 -1
  192. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  193. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +5 -7
  194. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  195. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +2 -1
  196. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  197. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -3
  198. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  199. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +2 -1
  200. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -1
  201. package/dist/components/Variables/BuiltinVariableAccordions.js +7 -14
  202. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  203. package/dist/components/Variables/EditVariablesButton.d.ts +2 -1
  204. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  205. package/dist/components/Variables/EditVariablesButton.js +5 -5
  206. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  207. package/dist/components/Variables/{TemplateVariable.d.ts → Variable.d.ts} +6 -5
  208. package/dist/components/Variables/Variable.d.ts.map +1 -0
  209. package/dist/components/Variables/{TemplateVariable.js → Variable.js} +53 -61
  210. package/dist/components/Variables/Variable.js.map +1 -0
  211. package/dist/components/Variables/VariableEditor.d.ts +3 -2
  212. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  213. package/dist/components/Variables/VariableEditor.js +35 -41
  214. package/dist/components/Variables/VariableEditor.js.map +1 -1
  215. package/dist/components/Variables/VariableList.d.ts +4 -3
  216. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  217. package/dist/components/Variables/VariableList.js +21 -20
  218. package/dist/components/Variables/VariableList.js.map +1 -1
  219. package/dist/components/Variables/index.d.ts +1 -1
  220. package/dist/components/Variables/index.d.ts.map +1 -1
  221. package/dist/components/Variables/index.js +2 -2
  222. package/dist/components/Variables/index.js.map +1 -1
  223. package/dist/constants/styles.d.ts +5 -2
  224. package/dist/constants/styles.d.ts.map +1 -1
  225. package/dist/constants/styles.js +6 -3
  226. package/dist/constants/styles.js.map +1 -1
  227. package/dist/constants/user-interface-text.d.ts +3 -1
  228. package/dist/constants/user-interface-text.d.ts.map +1 -1
  229. package/dist/constants/user-interface-text.js +3 -1
  230. package/dist/constants/user-interface-text.js.map +1 -1
  231. package/dist/context/DashboardProvider/DashboardProvider.d.ts +6 -3
  232. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  233. package/dist/context/DashboardProvider/DashboardProvider.js +11 -9
  234. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  235. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts +4 -0
  236. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -0
  237. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +28 -0
  238. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -0
  239. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  240. package/dist/context/DashboardProvider/common.js +2 -2
  241. package/dist/context/DashboardProvider/common.js.map +1 -1
  242. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +45 -23
  243. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  244. package/dist/context/DashboardProvider/dashboard-provider-api.js +23 -6
  245. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  246. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +2 -1
  247. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -1
  248. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  249. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -2
  250. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  251. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  252. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  253. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  254. package/dist/context/DashboardProvider/index.d.ts +1 -2
  255. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  256. package/dist/context/DashboardProvider/index.js.map +1 -1
  257. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -9
  258. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  259. package/dist/context/DashboardProvider/panel-editor-slice.js +4 -7
  260. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  261. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +2 -1
  262. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  263. package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  264. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  265. package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -3
  266. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  267. package/dist/context/DashboardProvider/panel-group-slice.js +7 -3
  268. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  269. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  270. package/dist/context/DashboardProvider/view-panel-slice.d.ts +21 -0
  271. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -0
  272. package/dist/context/DashboardProvider/view-panel-slice.js +73 -0
  273. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -0
  274. package/dist/context/DatasourceStoreProvider.d.ts +7 -7
  275. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  276. package/dist/context/DatasourceStoreProvider.js +18 -23
  277. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  278. package/dist/context/VariableProvider/VariableProvider.d.ts +119 -0
  279. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -0
  280. package/dist/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +62 -64
  281. package/dist/context/VariableProvider/VariableProvider.js.map +1 -0
  282. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.d.ts +1 -1
  283. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -0
  284. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +9 -12
  285. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -0
  286. package/dist/context/VariableProvider/index.d.ts +2 -0
  287. package/dist/context/VariableProvider/index.d.ts.map +1 -0
  288. package/dist/{validation → context/VariableProvider}/index.js +2 -2
  289. package/dist/context/VariableProvider/index.js.map +1 -0
  290. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.d.ts +2 -6
  291. package/dist/context/VariableProvider/query-params.d.ts.map +1 -0
  292. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  293. package/dist/context/VariableProvider/query-params.js.map +1 -0
  294. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.d.ts +1 -1
  295. package/dist/context/VariableProvider/utils.d.ts.map +1 -0
  296. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  297. package/dist/context/VariableProvider/utils.js.map +1 -0
  298. package/dist/context/index.d.ts +1 -1
  299. package/dist/context/index.d.ts.map +1 -1
  300. package/dist/context/index.js +2 -2
  301. package/dist/context/index.js.map +1 -1
  302. package/dist/context/useDashboard.d.ts.map +1 -1
  303. package/dist/context/useDashboard.js +4 -4
  304. package/dist/context/useDashboard.js.map +1 -1
  305. package/dist/test/dashboard-provider.d.ts +1 -1
  306. package/dist/test/dashboard-provider.d.ts.map +1 -1
  307. package/dist/test/dashboard-provider.js.map +1 -1
  308. package/dist/test/datasource-provider.d.ts +3 -3
  309. package/dist/test/datasource-provider.d.ts.map +1 -1
  310. package/dist/test/datasource-provider.js +1 -1
  311. package/dist/test/datasource-provider.js.map +1 -1
  312. package/dist/test/plugin-registry.d.ts.map +1 -1
  313. package/dist/test/plugin-registry.js +8 -3
  314. package/dist/test/plugin-registry.js.map +1 -1
  315. package/dist/test/render.d.ts +2 -2
  316. package/dist/test/render.d.ts.map +1 -1
  317. package/dist/test/render.js +9 -7
  318. package/dist/test/render.js.map +1 -1
  319. package/dist/utils/panelUtils.d.ts.map +1 -1
  320. package/dist/utils/panelUtils.js.map +1 -1
  321. package/dist/views/ViewDashboard/DashboardApp.d.ts +4 -2
  322. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  323. package/dist/views/ViewDashboard/DashboardApp.js +6 -4
  324. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  325. package/dist/views/ViewDashboard/ViewDashboard.d.ts +4 -3
  326. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  327. package/dist/views/ViewDashboard/ViewDashboard.js +11 -10
  328. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  329. package/package.json +12 -12
  330. package/dist/cjs/context/TemplateVariableProvider/index.js +0 -30
  331. package/dist/cjs/stories/decorators/WithDashboard.js +0 -41
  332. package/dist/cjs/stories/decorators/WithDatasourceStore.js +0 -39
  333. package/dist/cjs/stories/decorators/WithTemplateVariables.js +0 -37
  334. package/dist/cjs/stories/decorators/constants.js +0 -39
  335. package/dist/cjs/stories/decorators/index.js +0 -33
  336. package/dist/components/Variables/TemplateVariable.d.ts.map +0 -1
  337. package/dist/components/Variables/TemplateVariable.js.map +0 -1
  338. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +0 -77
  339. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +0 -1
  340. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +0 -1
  341. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +0 -1
  342. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +0 -1
  343. package/dist/context/TemplateVariableProvider/index.d.ts +0 -2
  344. package/dist/context/TemplateVariableProvider/index.d.ts.map +0 -1
  345. package/dist/context/TemplateVariableProvider/index.js +0 -15
  346. package/dist/context/TemplateVariableProvider/index.js.map +0 -1
  347. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +0 -1
  348. package/dist/context/TemplateVariableProvider/query-params.js.map +0 -1
  349. package/dist/context/TemplateVariableProvider/utils.d.ts.map +0 -1
  350. package/dist/context/TemplateVariableProvider/utils.js.map +0 -1
  351. package/dist/stories/decorators/WithDashboard.js +0 -33
  352. package/dist/stories/decorators/WithDashboard.js.map +0 -1
  353. package/dist/stories/decorators/WithDatasourceStore.js +0 -31
  354. package/dist/stories/decorators/WithDatasourceStore.js.map +0 -1
  355. package/dist/stories/decorators/WithTemplateVariables.js +0 -29
  356. package/dist/stories/decorators/WithTemplateVariables.js.map +0 -1
  357. package/dist/stories/decorators/constants.js +0 -31
  358. package/dist/stories/decorators/constants.js.map +0 -1
  359. package/dist/stories/decorators/index.js.map +0 -1
  360. package/dist/validation/index.d.ts +0 -2
  361. package/dist/validation/index.d.ts.map +0 -1
  362. package/dist/validation/index.js.map +0 -1
  363. package/dist/validation/panel.d.ts +0 -19
  364. package/dist/validation/panel.d.ts.map +0 -1
  365. package/dist/validation/panel.js +0 -21
  366. package/dist/validation/panel.js.map +0 -1
@@ -1,39 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "EMPTY_DASHBOARD_RESOURCE", {
18
- enumerable: true,
19
- get: function() {
20
- return EMPTY_DASHBOARD_RESOURCE;
21
- }
22
- });
23
- const EMPTY_DASHBOARD_RESOURCE = {
24
- kind: 'Dashboard',
25
- metadata: {
26
- name: 'My Dashboard',
27
- project: 'Storybook',
28
- createdAt: '2021-11-09T00:00:00Z',
29
- updatedAt: '2021-11-09T00:00:00Z',
30
- version: 0
31
- },
32
- spec: {
33
- duration: '1h',
34
- refreshInterval: '0s',
35
- variables: [],
36
- layouts: [],
37
- panels: {}
38
- }
39
- };
@@ -1,33 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _export_star(require("./constants"), exports);
18
- _export_star(require("./WithDashboard"), exports);
19
- _export_star(require("./WithDatasourceStore"), exports);
20
- _export_star(require("./WithTemplateVariables"), exports);
21
- function _export_star(from, to) {
22
- Object.keys(from).forEach(function(k) {
23
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
24
- Object.defineProperty(to, k, {
25
- enumerable: true,
26
- get: function() {
27
- return from[k];
28
- }
29
- });
30
- }
31
- });
32
- return from;
33
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateVariable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/TemplateVariable.tsx"],"names":[],"mappings":"AAeA,OAAO,EAGL,gBAAgB,EAEhB,WAAW,EACX,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,qBAAqB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAcF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,qBAAqB,2CAWvE;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,EAC/C,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 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/Variables/TemplateVariable.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 { 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 UnknownSpec,\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 { useTemplateVariable, useTemplateVariableActions } from '../../context';\nimport { MAX_TEMPLATE_VARIABLE_WIDTH, MIN_TEMPLATE_VARIABLE_WIDTH } from '../../constants';\n\ntype TemplateVariableProps = {\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 TemplateVariable({ name, source }: TemplateVariableProps) {\n const ctx = useTemplateVariable(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<UnknownSpec> | 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) => (\n <Popper placeholder={undefined} {...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_TEMPLATE_VARIABLE_WIDTH) {\n return MIN_TEMPLATE_VARIABLE_WIDTH;\n } else if (width > MAX_TEMPLATE_VARIABLE_WIDTH) {\n return MAX_TEMPLATE_VARIABLE_WIDTH;\n } else {\n return width;\n }\n};\n\nfunction ListVariable({ name, source }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name, source);\n const definition = ctx.definition as ListVariableDefinition;\n const variablesOptionsQuery = useListVariablePluginValues(definition);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();\n const { selectedOptions, value, loading, options, viewOptions } = useListVariableState(\n definition?.spec,\n ctx.state,\n variablesOptionsQuery\n );\n const [inputValue, setInputValue] = useState<string>('');\n const [inputWidth, setInputWidth] = useState(MIN_TEMPLATE_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 PopperComponent={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 '& .MuiInputBase-root.MuiOutlinedInput-root.MuiInputBase-sizeSmall': {\n paddingY: '5px',\n paddingLeft: '5px',\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 inputValue={inputValue}\n onInputChange={(_, newInputValue) => {\n setInputValue(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 }: TemplateVariableProps) {\n const ctx = useTemplateVariable(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 } = useTemplateVariableActions();\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) => setTempValue(e.target.value)}\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 InputProps={{\n readOnly: definition?.spec.constant ?? false,\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","useTemplateVariable","useTemplateVariableActions","MAX_TEMPLATE_VARIABLE_WIDTH","MIN_TEMPLATE_VARIABLE_WIDTH","variableOptionToVariableValue","options","Array","isArray","map","v","value","TemplateVariable","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","placeholder","undefined","sx","minWidth","placement","LETTER_HSIZE","ARROW_OFFSET","getWidthPx","inputValue","width","setVariableValue","setVariableLoading","setVariableOptions","setInputValue","inputWidth","setInputWidth","title","display","disablePortal","disableCloseOnSelect","multiple","fullWidth","limitTags","size","disableClearable","PopperComponent","renderInput","params","style","minHeight","paddingY","paddingLeft","onChange","_","onInputChange","newInputValue","tempValue","setTempValue","e","target","onBlur","InputProps","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,SAASA,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACrD,SAASC,cAAc,EAAEC,SAAS,EAAEC,YAAY,EAAEC,MAAM,QAAqB,gBAAgB;AAC7F,SACEC,iBAAiB,QAOZ,mBAAmB;AAC1B,SAASC,2BAA2B,QAAuC,4BAA4B;AAEvG,SAASC,mBAAmB,EAAEC,0BAA0B,QAAQ,gBAAgB;AAChF,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,kBAAkB;AAO3F,SAASC,8BAA8BC,OAAiD;IACtF,IAAIA,YAAY,MAAM;QACpB,OAAO;IACT;IACA,IAAIC,MAAMC,OAAO,CAACF,UAAU;QAC1B,OAAOA,QAAQG,GAAG,CAAC,CAACC;YAClB,OAAOA,EAAEC,KAAK;QAChB;IACF;IACA,OAAOL,QAAQK,KAAK;AACtB;AAEA,OAAO,SAASC,iBAAiB,EAAEC,IAAI,EAAEC,MAAM,EAAyB;QAEzDC;IADb,MAAMA,MAAMd,oBAAoBY,MAAMC;IACtC,MAAME,QAAOD,kBAAAA,IAAIE,UAAU,cAAdF,sCAAAA,gBAAgBC,IAAI;IACjC,OAAQA;QACN,KAAK;YACH,qBAAO,KAACE;gBAAaL,MAAMA;gBAAMC,QAAQA;;QAC3C,KAAK;YACH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;IAE7BV,UAAU;YACK+B;QAAbiE,aAAajE,CAAAA,eAAAA,kBAAAA,4BAAAA,MAAOZ,KAAK,cAAZY,0BAAAA,eAAgB;IAC/B,GAAG;QAACA,kBAAAA,4BAAAA,MAAOZ,KAAK;KAAC;QAaNM,+BAEKA;IAbhB,qBACE,KAACrB;QACCuE,OAAOoB;QACP5E,OAAO4E;QACP,gDAAgD;QAChDJ,UAAU,CAACM;YACTD,aAAaC,EAAEC,MAAM,CAAC/E,KAAK;YAC3BuD,cAAcR,WAAW+B,EAAEC,MAAM,CAAC/E,KAAK,EAAE;QAC3C;QACAgF,QAAQ,IAAM9B,iBAAiBhD,MAAM0E,WAAWzE;QAChDqC,aAAatC;QACbsB,OAAOlB,CAAAA,gCAAAA,uBAAAA,kCAAAA,2BAAAA,WAAYK,IAAI,CAAC8C,OAAO,cAAxBnD,+CAAAA,yBAA0BJ,IAAI,cAA9BI,2CAAAA,gCAAkCJ;QACzC+E,YAAY;YACVC,UAAU5E,CAAAA,4BAAAA,uBAAAA,iCAAAA,WAAYK,IAAI,CAACwE,QAAQ,cAAzB7E,uCAAAA,4BAA6B;QACzC;QACAoC,IAAI;YACFO,OAAO,CAAC,EAAEK,WAAW,EAAE,CAAC;YACxB,wBAAwB;gBACtBe,WAAW;YACb;YACA,yBAAyB;gBACvBe,cAAc;YAChB;QACF;;AAGN"}
@@ -1,77 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { VariableStateMap, VariableState, VariableStoreStateMap, VariableOption } from '@perses-dev/plugin-system';
3
- import { VariableName, VariableValue, VariableDefinition, BuiltinVariableDefinition } from '@perses-dev/core';
4
- type TemplateVariableStore = {
5
- variableDefinitions: VariableDefinition[];
6
- externalVariableDefinitions: ExternalVariableDefinition[];
7
- variableState: VariableStoreStateMap;
8
- setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;
9
- setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;
10
- setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;
11
- setVariableDefinitions: (definitions: VariableDefinition[]) => void;
12
- setVariableDefaultValues: () => VariableDefinition[];
13
- getSavedVariablesStatus: () => {
14
- isSavedVariableModified: boolean;
15
- modifiedVariableNames: string[];
16
- };
17
- };
18
- export declare function useTemplateVariableStoreCtx(): Omit<Omit<import("zustand").StoreApi<TemplateVariableStore>, "setState"> & {
19
- setState<A extends string | {
20
- type: string;
21
- }>(partial: TemplateVariableStore | Partial<TemplateVariableStore> | ((state: TemplateVariableStore) => TemplateVariableStore | Partial<TemplateVariableStore>), replace?: boolean | undefined, action?: A | undefined): void;
22
- }, "setState"> & {
23
- setState(nextStateOrUpdater: TemplateVariableStore | Partial<TemplateVariableStore> | ((state: import("immer/dist/internal").WritableDraft<TemplateVariableStore>) => void), shouldReplace?: boolean | undefined, action?: string | {
24
- type: string;
25
- } | undefined): void;
26
- };
27
- export declare function useTemplateVariableValues(variableNames?: string[]): VariableStateMap;
28
- /**
29
- * Get the state and definition of a variable from the Template variables context.
30
- * @param name name of the variable
31
- * @param source if given, it searches in the external variables
32
- */
33
- export declare function useTemplateVariable(name: string, source?: string): {
34
- state: VariableState | undefined;
35
- definition: VariableDefinition | undefined;
36
- };
37
- export declare function useTemplateVariableActions(): {
38
- setVariableValue: (variableName: string, value: VariableValue, source?: string | undefined) => void;
39
- setVariableLoading: (name: string, loading: boolean, source?: string | undefined) => void;
40
- setVariableOptions: (name: string, options: VariableOption[], source?: string | undefined) => void;
41
- setVariableDefinitions: (definitions: VariableDefinition[]) => void;
42
- setVariableDefaultValues: () => VariableDefinition[];
43
- getSavedVariablesStatus: () => {
44
- isSavedVariableModified: boolean;
45
- modifiedVariableNames: string[];
46
- };
47
- };
48
- export declare function useTemplateVariableDefinitions(): VariableDefinition[];
49
- export declare function useTemplateExternalVariableDefinitions(): ExternalVariableDefinition[];
50
- export declare function useTemplateVariableStore(): TemplateVariableStore;
51
- export type ExternalVariableDefinition = {
52
- source: string;
53
- tooltip?: {
54
- title?: string;
55
- description?: string;
56
- };
57
- editLink?: string;
58
- definitions: VariableDefinition[];
59
- };
60
- export interface TemplateVariableProviderProps {
61
- children: ReactNode;
62
- initialVariableDefinitions?: VariableDefinition[];
63
- /**
64
- * The external variables allow you to give to the provider some additional variables, not defined in the dashboard and static.
65
- * It means that you won´t be able to update them from the dashboard itself, but you will see them appear and will be able
66
- * to modify their runtime value as any other variable.
67
- * If one of the external variable has the same name as a local one, it will be marked as overridden.
68
- * You can define one list of variable definition by source and as many source as you want.
69
- * The order of the sources is important as first one will take precedence on the following ones, in case they have same names.
70
- */
71
- externalVariableDefinitions?: ExternalVariableDefinition[];
72
- builtinVariables?: BuiltinVariableDefinition[];
73
- }
74
- export declare function TemplateVariableProvider({ children, initialVariableDefinitions, externalVariableDefinitions, builtinVariables, }: TemplateVariableProviderProps): import("react/jsx-runtime").JSX.Element;
75
- export declare function TemplateVariableProviderWithQueryParams({ children, initialVariableDefinitions, externalVariableDefinitions, builtinVariables, }: TemplateVariableProviderProps): import("react/jsx-runtime").JSX.Element;
76
- export {};
77
- //# sourceMappingURL=TemplateVariableProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateVariableProvider.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/TemplateVariableProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAiB,SAAS,EAAiC,MAAM,OAAO,CAAC;AAKhF,OAAO,EAEL,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,cAAc,EAGf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAGlB,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAK1B,KAAK,qBAAqB,GAAG;IAC3B,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,2BAA2B,EAAE,0BAA0B,EAAE,CAAC;IAC1D,aAAa,EAAE,qBAAqB,CAAC;IACrC,gBAAgB,EAAE,CAAC,YAAY,EAAE,YAAY,EA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kB,EAAE,CAAC;IAClD;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC3D,gBAAgB,CAAC,EAAE,yBAAyB,EAAE,CAAC;CAChD;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,0BAA+B,EAC/B,2BAAgC,EAChC,gBAAqB,GACtB,EAAE,6BAA6B,2CAQ/B;AAED,wBAAgB,uCAAuC,CAAC,EACtD,QAAQ,EACR,0BAA+B,EAC/B,2BAAgC,EAChC,gBAAqB,GACtB,EAAE,6BAA6B,2CAY/B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/TemplateVariableProvider.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 { createContext, ReactNode, useContext, useMemo, useState } from 'react';\nimport { createStore, useStore } from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport { devtools } from 'zustand/middleware';\nimport produce from 'immer';\nimport {\n TemplateVariableContext,\n VariableStateMap,\n VariableState,\n VariableStoreStateMap,\n VariableOption,\n BuiltinVariableContext,\n useTimeRange,\n} from '@perses-dev/plugin-system';\nimport {\n DEFAULT_ALL_VALUE as ALL_VALUE,\n VariableName,\n VariableValue,\n VariableDefinition,\n formatDuration,\n intervalToPrometheusDuration,\n BuiltinVariableDefinition,\n} from '@perses-dev/core';\nimport { checkSavedDefaultVariableStatus, findVariableDefinitionByName, mergeVariableDefinitions } from './utils';\nimport { hydrateTemplateVariableStates } from './hydrationUtils';\nimport { getInitalValuesFromQueryParameters, getURLQueryParamName, useVariableQueryParams } from './query-params';\n\ntype TemplateVariableStore = {\n variableDefinitions: VariableDefinition[];\n externalVariableDefinitions: ExternalVariableDefinition[];\n variableState: VariableStoreStateMap;\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n setVariableDefaultValues: () => VariableDefinition[];\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n};\n\nconst TemplateVariableStoreContext = createContext<ReturnType<typeof createTemplateVariableSrvStore> | undefined>(\n undefined\n);\nexport function useTemplateVariableStoreCtx() {\n const context = useContext(TemplateVariableStoreContext);\n if (!context) {\n throw new Error('TemplateVariableStoreContext not initialized');\n }\n return context;\n}\n\nexport function useTemplateVariableValues(variableNames?: string[]) {\n const store = useTemplateVariableStoreCtx();\n return useStore(\n store,\n (s) => {\n const vars: VariableStateMap = {};\n\n // Collect values of local variables, from the variable state\n const names = variableNames ?? s.variableDefinitions.map((value) => value.spec.name);\n names.forEach((name) => {\n const varState = s.variableState.get({ name });\n if (!varState || varState.overridden) {\n return;\n }\n vars[name] = varState;\n });\n\n // Collect values of external variables, from the variable state\n s.externalVariableDefinitions.forEach((d) => {\n const source = d.source;\n d.definitions.forEach((value) => {\n const name = value.spec.name;\n const varState = s.variableState.get({ name, source });\n if (!varState || varState.overridden) {\n return;\n }\n vars[name] = varState;\n });\n });\n\n return vars;\n },\n (left, right) => {\n return JSON.stringify(left) === JSON.stringify(right);\n }\n );\n}\n\n/**\n * Get the state and definition of a variable from the Template variables context.\n * @param name name of the variable\n * @param source if given, it searches in the external variables\n */\nexport function useTemplateVariable(name: string, source?: string) {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => {\n const state = s.variableState.get({ name, source });\n const definitions = source\n ? s.externalVariableDefinitions.find((v) => v.source === source)?.definitions\n : s.variableDefinitions;\n const definition = (definitions || []).find((v) => v.spec.name === name);\n\n return { state, definition };\n });\n}\n\nexport function useTemplateVariableActions() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => {\n return {\n setVariableValue: s.setVariableValue,\n setVariableLoading: s.setVariableLoading,\n setVariableOptions: s.setVariableOptions,\n setVariableDefinitions: s.setVariableDefinitions,\n setVariableDefaultValues: s.setVariableDefaultValues,\n getSavedVariablesStatus: s.getSavedVariablesStatus,\n };\n });\n}\n\nexport function useTemplateVariableDefinitions() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => s.variableDefinitions);\n}\n\nexport function useTemplateExternalVariableDefinitions() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store, (s) => s.externalVariableDefinitions);\n}\n\nexport function useTemplateVariableStore() {\n const store = useTemplateVariableStoreCtx();\n return useStore(store);\n}\n\ninterface PluginProviderProps {\n children: ReactNode;\n builtinVariables?: BuiltinVariableDefinition[];\n}\n\nfunction PluginProvider({ children, builtinVariables }: PluginProviderProps) {\n const originalValues = useTemplateVariableValues();\n const definitions = useTemplateVariableDefinitions();\n const externalDefinitions = useTemplateExternalVariableDefinitions();\n const { absoluteTimeRange } = useTimeRange();\n\n const values = useMemo(() => {\n const contextValues: VariableStateMap = {};\n\n // This will loop through all the current variables values\n // and update any variables that have ALL_VALUE as their current value\n // to include all options.\n Object.keys(originalValues).forEach((name) => {\n const v = { ...originalValues[name] } as VariableState;\n\n if (v.value === ALL_VALUE) {\n const definition = findVariableDefinitionByName(name, definitions, externalDefinitions);\n // If the variable is a list variable and has a custom all value, then use that value instead\n if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {\n v.value = definition.spec.customAllValue;\n } else {\n v.value = v.options?.map((o: { value: string }) => o.value) ?? null;\n }\n }\n contextValues[name] = v;\n });\n return contextValues;\n }, [originalValues, definitions, externalDefinitions]);\n\n const allBuiltinVariables: BuiltinVariableDefinition[] = useMemo(() => {\n const result: BuiltinVariableDefinition[] = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__from',\n value: () => absoluteTimeRange.start.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__from',\n description: 'Start time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__to',\n value: () => absoluteTimeRange.end.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__to',\n description: 'End time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range',\n value: () => formatDuration(intervalToPrometheusDuration(absoluteTimeRange)),\n source: 'Dashboard',\n display: {\n name: '__range',\n description: 'The range for the current dashboard in human readable format',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_s',\n value: () => ((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_s',\n description: 'The range for the current dashboard in second',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_ms',\n value: () => (absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_ms',\n description: 'The range for the current dashboard in millisecond',\n hidden: true,\n },\n },\n },\n ];\n builtinVariables?.forEach((def) => result.push(def));\n return result;\n }, [absoluteTimeRange, builtinVariables]);\n\n return (\n <BuiltinVariableContext.Provider value={{ variables: allBuiltinVariables }}>\n <TemplateVariableContext.Provider value={{ state: values }}>{children}</TemplateVariableContext.Provider>\n </BuiltinVariableContext.Provider>\n );\n}\n\ninterface TemplateVariableSrvArgs {\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n queryParams?: ReturnType<typeof useVariableQueryParams>;\n}\n\nfunction createTemplateVariableSrvStore({\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n queryParams,\n}: TemplateVariableSrvArgs) {\n const initialParams = getInitalValuesFromQueryParameters(queryParams ? queryParams[0] : {});\n const store = createStore<TemplateVariableStore>()(\n devtools(\n immer((set, get) => ({\n variableState: hydrateTemplateVariableStates(\n initialVariableDefinitions,\n initialParams,\n externalVariableDefinitions\n ),\n variableDefinitions: initialVariableDefinitions,\n externalVariableDefinitions: externalVariableDefinitions,\n setVariableDefinitions(definitions: VariableDefinition[]) {\n set(\n (state) => {\n state.variableDefinitions = definitions;\n state.variableState = hydrateTemplateVariableStates(\n definitions,\n initialParams,\n externalVariableDefinitions\n );\n },\n false,\n '[Variables] setVariableDefinitions' // Used for action name in Redux devtools\n );\n },\n setVariableOptions(name, options, source?: string) {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.options = options;\n },\n false,\n '[Variables] setVariableOptions'\n );\n },\n setVariableLoading(name, loading, source?: string) {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.loading = loading;\n },\n false,\n '[Variables] setVariableLoading'\n );\n },\n setVariableValue: (name, value, source?: string) =>\n set(\n (state) => {\n let val = value;\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n\n // Make sure there is only one all value\n if (Array.isArray(val) && val.includes(ALL_VALUE)) {\n if (val.at(-1) === ALL_VALUE) {\n val = ALL_VALUE;\n } else {\n val = val.filter((v) => v !== ALL_VALUE);\n }\n }\n if (queryParams) {\n const setQueryParams = queryParams[1];\n setQueryParams({ [getURLQueryParamName(name)]: val });\n }\n varState.value = val;\n },\n false,\n '[Variables] setVariableValue'\n ),\n setVariableDefaultValues: () => {\n const variableDefinitions = get().variableDefinitions;\n const variableState = get().variableState;\n const updatedVariables = produce(variableDefinitions, (draft) => {\n draft.forEach((variable, index) => {\n const name = variable.spec.name;\n if (variable.kind === 'ListVariable') {\n const currentVariable = variableState.get({ name });\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'ListVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.defaultValue = currentVariable.value;\n }),\n };\n }\n } else if (variable.kind === 'TextVariable') {\n const currentVariable = variableState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'TextVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.value = currentVariableValue;\n }),\n };\n }\n }\n });\n });\n set(\n (state) => {\n state.variableDefinitions = updatedVariables;\n },\n false,\n '[Variables] setVariableDefaultValues'\n );\n return updatedVariables;\n },\n getSavedVariablesStatus: () => {\n return checkSavedDefaultVariableStatus(get().variableDefinitions, get().variableState);\n },\n }))\n )\n );\n\n return store;\n}\n\nexport type ExternalVariableDefinition = {\n source: string;\n tooltip?: {\n title?: string;\n description?: string;\n };\n editLink?: string;\n definitions: VariableDefinition[];\n};\n\nexport interface TemplateVariableProviderProps {\n children: ReactNode;\n initialVariableDefinitions?: VariableDefinition[];\n /**\n * The external variables allow you to give to the provider some additional variables, not defined in the dashboard and static.\n * It means that you won´t be able to update them from the dashboard itself, but you will see them appear and will be able\n * to modify their runtime value as any other variable.\n * If one of the external variable has the same name as a local one, it will be marked as overridden.\n * You can define one list of variable definition by source and as many source as you want.\n * The order of the sources is important as first one will take precedence on the following ones, in case they have same names.\n */\n externalVariableDefinitions?: ExternalVariableDefinition[];\n builtinVariables?: BuiltinVariableDefinition[];\n}\n\nexport function TemplateVariableProvider({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariables = [],\n}: TemplateVariableProviderProps) {\n const [store] = useState(createTemplateVariableSrvStore({ initialVariableDefinitions, externalVariableDefinitions }));\n\n return (\n <TemplateVariableStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariables}>{children}</PluginProvider>\n </TemplateVariableStoreContext.Provider>\n );\n}\n\nexport function TemplateVariableProviderWithQueryParams({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariables = [],\n}: TemplateVariableProviderProps) {\n const allVariableDefs = mergeVariableDefinitions(initialVariableDefinitions, externalVariableDefinitions);\n const queryParams = useVariableQueryParams(allVariableDefs);\n const [store] = useState(\n createTemplateVariableSrvStore({ initialVariableDefinitions, externalVariableDefinitions, queryParams })\n );\n\n return (\n <TemplateVariableStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariables}>{children}</PluginProvider>\n </TemplateVariableStoreContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useMemo","useState","createStore","useStore","immer","devtools","produce","TemplateVariableContext","BuiltinVariableContext","useTimeRange","DEFAULT_ALL_VALUE","ALL_VALUE","formatDuration","intervalToPrometheusDuration","checkSavedDefaultVariableStatus","findVariableDefinitionByName","mergeVariableDefinitions","hydrateTemplateVariableStates","getInitalValuesFromQueryParameters","getURLQueryParamName","useVariableQueryParams","TemplateVariableStoreContext","undefined","useTemplateVariableStoreCtx","context","Error","useTemplateVariableValues","variableNames","store","s","vars","names","variableDefinitions","map","value","spec","name","forEach","varState","variableState","get","overridden","externalVariableDefinitions","d","source","definitions","left","right","JSON","stringify","useTemplateVariable","state","find","v","definition","useTemplateVariableActions","setVariableValue","setVariableLoading","setVariableOptions","setVariableDefinitions","setVariableDefaultValues","getSavedVariablesStatus","useTemplateVariableDefinitions","useTemplateExternalVariableDefinitions","useTemplateVariableStore","PluginProvider","children","builtinVariables","originalValues","externalDefinitions","absoluteTimeRange","values","contextValues","Object","keys","kind","customAllValue","options","o","allBuiltinVariables","result","start","valueOf","toString","display","description","hidden","end","def","push","Provider","variables","createTemplateVariableSrvStore","initialVariableDefinitions","queryParams","initialParams","set","loading","val","Array","isArray","includes","at","filter","setQueryParams","updatedVariables","draft","variable","index","currentVariable","specDraft","defaultValue","currentVariableValue","TemplateVariableProvider","TemplateVariableProviderWithQueryParams","allVariableDefs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAA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xG,qBACE,KAACzE,6BAA6BqE,QAAQ;QAACxD,OAAON;kBAC5C,cAAA,KAACqC;YAAeE,kBAAkBA;sBAAmBD;;;AAG3D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydrationUtils.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/hydrationUtils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAiB,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAyCpE;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC5C,mBAAmB,GAAE,0BAA0B,EAAO,GACrD,qBAAqB,CAoEvB"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/hydrationUtils.ts"],"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 { DEFAULT_ALL_VALUE, VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { VariableStoreStateMap, VariableState } from '@perses-dev/plugin-system';\nimport { ExternalVariableDefinition } from '@perses-dev/dashboards';\n\n// TODO: move to TemplateVariableProvider/utils.ts\nfunction hydrateTemplateVariableState(variable: VariableDefinition, initialValue?: VariableValue): VariableState {\n const varState: VariableState = {\n value: null,\n loading: false,\n overriding: false,\n overridden: false,\n };\n switch (variable.kind) {\n case 'TextVariable':\n varState.value = initialValue ?? variable.spec.value;\n break;\n case 'ListVariable':\n varState.options = [];\n varState.value = initialValue ?? variable.spec.defaultValue ?? null;\n // TODO: smarter fallbacks for defaultValue when allowAllValue is true\n if (varState.options.length > 0 && !varState.value) {\n const firstOptionValue = varState.options[0]?.value ?? null;\n if (firstOptionValue !== null) {\n varState.value = variable.spec.allowMultiple ? [firstOptionValue] : firstOptionValue;\n }\n }\n\n // \"all\" variable handling assumes the value is not in an array. This is\n // handled properly during internal variable interactions, but it is possible\n // to end up in a buggy state if the variables are initialized with an \"all\"\n // value inside an array. When hydrating variables, normalize this to minimize\n // bugs.\n if (Array.isArray(varState.value) && varState.value.length === 1 && varState.value[0] === DEFAULT_ALL_VALUE) {\n varState.value = DEFAULT_ALL_VALUE;\n }\n\n break;\n default:\n break;\n }\n return varState;\n}\n\n/**\n * Build the local variable states according to the given definitions\n * @param localDefinitions local variable definitions. Dynamic part.\n * @param externalDefinitions external variables definitions. Static part.\n * @param initialValues values coming from query parameters\n */\nexport function hydrateTemplateVariableStates(\n localDefinitions: VariableDefinition[],\n initialValues: Record<string, VariableValue>,\n externalDefinitions: ExternalVariableDefinition[] = []\n): VariableStoreStateMap {\n const state: VariableStoreStateMap = new VariableStoreStateMap();\n\n // Collect the names used by local definitions\n let overridingNames: Record<string, boolean> = {};\n localDefinitions.forEach(\n (v) => {\n overridingNames[v.spec.name] = true;\n },\n {} as Record<string, boolean>\n );\n\n // Then populate the external variables state,\n // taking care of well flagging each name as used, so the overridden state can be filled accordingly.\n const overriddenNames: Record<string, boolean> = {};\n externalDefinitions.forEach(\n (externalDef) => {\n const source = externalDef.source;\n externalDef.definitions.forEach((v) => {\n const name = v.spec.name;\n const param = initialValues[name];\n const initialValue = param ? param : null;\n state.set(\n { source, name },\n {\n ...hydrateTemplateVariableState(v, initialValue),\n overridden: !!overridingNames[name],\n }\n );\n\n overridingNames[name] = true;\n overriddenNames[v.spec.name] = true;\n });\n },\n {} as Record<string, boolean>\n );\n\n // Then populate the local variables state,\n // taking care the overriding state is filled according to the names used in external variables.\n localDefinitions.forEach((v) => {\n const name = v.spec.name;\n const param = initialValues[name];\n const initialValue = param ? param : null;\n state.set(\n { name },\n {\n ...hydrateTemplateVariableState(v, initialValue),\n overriding: !!overriddenNames[name],\n }\n );\n });\n\n overridingNames = {};\n externalDefinitions\n .slice()\n .reverse()\n .forEach((externalDef) => {\n const source = externalDef.source;\n externalDef.definitions.forEach((v) => {\n const name = v.spec.name;\n const value = state.get({ source, name });\n if (value) {\n value.overriding = !!overridingNames[name];\n }\n overridingNames[name] = true;\n });\n });\n return state;\n}\n"],"names":["DEFAULT_ALL_VALUE","VariableStoreStateMap","hydrateTemplateVariableState","variable","initialValue","varState","value","loading","overriding","overridden","kind","spec","options","defaultValue","length","firstOptionValue","allowMultiple","Array","isArray","hydrateTemplateVariableStates","localDefinitions","initialValues","externalDefinitions","state","overridingNames","forEach","v","name","overriddenNames","externalDef","source","definitions","param","set","slice","reverse","get"],"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,iBAAiB,QAA2C,mBAAmB;AACxF,SAASC,qBAAqB,QAAuB,4BAA4B;AAGjF,kDAAkD;AAClD,SAASC,6BAA6BC,QAA4B,EAAEC,YAA4B;IAC9F,MAAMC,WAA0B;QAC9BC,OAAO;QACPC,SAAS;QACTC,YAAY;QACZC,YAAY;IACd;IACA,OAAQN,SAASO,IAAI;QACnB,KAAK;YACHL,SAASC,KAAK,GAAGF,yBAAAA,0BAAAA,eAAgBD,SAASQ,IAAI,CAACL,KAAK;YACpD;QACF,KAAK;YACHD,SAASO,OAAO,GAAG,EAAE;gBACJR;YAAjBC,SAASC,KAAK,GAAGF,CAAAA,OAAAA,yBAAAA,0BAAAA,e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B,eAAe4B,QAAQA,QAAQ;YACrCT,MAAMU,GAAG,CACP;gBAAEH;gBAAQH;YAAK,GACf;gBACE,GAAGzB,6BAA6BwB,GAAGtB,aAAa;gBAChDK,YAAY,CAAC,CAACe,eAAe,CAACG,KAAK;YACrC;YAGFH,eAAe,CAACG,KAAK,GAAG;YACxBC,eAAe,CAACF,EAAEf,IAAI,CAACgB,IAAI,CAAC,GAAG;QACjC;IACF,GACA,CAAC;IAGH,2CAA2C;IAC3C,gGAAgG;IAChGP,iBAAiBK,OAAO,CAAC,CAACC;QACxB,MAAMC,OAAOD,EAAEf,IAAI,CAACgB,IAAI;QACxB,MAAMK,QAAQX,aAAa,CAACM,KAAK;QACjC,MAAMvB,eAAe4B,QAAQA,QAAQ;QACrCT,MAAMU,GAAG,CACP;YAAEN;QAAK,GACP;YACE,GAAGzB,6BAA6BwB,GAAGtB,aAAa;YAChDI,YAAY,CAAC,CAACoB,eAAe,CAACD,KAAK;QACrC;IAEJ;IAEAH,kBAAkB,CAAC;IACnBF,oBACGY,KAAK,GACLC,OAAO,GACPV,OAAO,CAAC,CAACI;QACR,MAAMC,SAASD,YAAYC,MAAM;QACjCD,YAAYE,WAAW,CAACN,OAAO,CAAC,CAACC;YAC/B,MAAMC,OAAOD,EAAEf,IAAI,CAACgB,IAAI;YACxB,MAAMrB,QAAQiB,MAAMa,GAAG,CAAC;gBAAEN;gBAAQH;YAAK;YACvC,IAAIrB,OAAO;gBACTA,MAAME,UAAU,GAAG,CAAC,CAACgB,eAAe,CAACG,KAAK;YAC5C;YACAH,eAAe,CAACG,KAAK,GAAG;QAC1B;IACF;IACF,OAAOJ;AACT"}
@@ -1,2 +0,0 @@
1
- export * from './TemplateVariableProvider';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,4BAA4B,CAAC"}
@@ -1,15 +0,0 @@
1
- // Copyright 2023 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 './TemplateVariableProvider';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/index.ts"],"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\nexport * from './TemplateVariableProvider';\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,6BAA6B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/query-params.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,kBAAkB,CAAC;AAIpE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAEhD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,iBAKvD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAShE;AAYD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE;;;;IAOhE;AAED,wBAAgB,kCAAkC,CAChD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAC9C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAW/B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.ts"],"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 { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config, { updateType: 'replaceIn' });\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","updateType","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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,SAA2BA,cAAc,QAAQ,mBAAmB;AAEpE,MAAMC,+BAA+B;AAErC,OAAO,SAASC,qBAAqBC,IAAY;IAC/C,OAAO,CAAC,EAAEF,6BAA6B,EAAEE,KAAK,CAAC;AACjD;AAEA,OAAO,SAASC,oBAAoBC,KAAoB;IACtD,IAAIC,MAAMC,OAAO,CAACF,QAAQ;QACxB,OAAOA,MAAMG,IAAI,CAAC;IACpB;IACA,OAAOH;AACT;AAEA,OAAO,SAASI,oBAAoBJ,KAAa;IAC/C,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IACA,MAAMK,SAASL,MAAMM,KAAK,CAAC;IAC3B,IAAID,OAAOE,MAAM,KAAK,GAAG;QACvB,OAAOF,MAAM,CAAC,EAAE;IAClB;IACA,OAAOA;AACT;AAEA,MAAMG,qBAAsD;IAC1DC,QAAQV;IACRW,QAAQ,CAACC;QACP,IAAI,OAAOA,MAAM,UAAU;YACzB,OAAOP,oBAAoBO;QAC7B;QACA,OAAO;IACT;AACF;AAEA,OAAO,SAASC,uBAAuBC,IAA0B;IAC/D,MAAMC,SAAoD,CAAC;IAC3DD,KAAKE,OAAO,CAAC,CAACC;QACZ,MAAMlB,OAAOD,qBAAqBmB,IAAIC,IAAI,CAACnB,IAAI;QAC/CgB,MAAM,CAAChB,KAAK,GAAGU;IACjB;IACA,OAAOb,eAAemB,QAAQ;QAAEI,YAAY;IAAY;AAC1D;AAEA,OAAO,SAASC,mCACdC,gBAA+C;IAE/C,MAAMf,SAAwC,CAAC;IAC/CgB,OAAOC,IAAI,CAACF,kBAAkBL,OAAO,CAAC,CAACQ;QACrC,MAAMvB,QAAQoB,gBAAgB,CAACG,IAAI;QACnC,IAAI,CAACvB,OAAO;YACV;QACF;QACA,MAAMF,OAAOyB,IAAIC,OAAO,CAAC5B,8BAA8B;QACvDS,MAAM,CAACP,KAAK,GAAGE;IACjB;IACA,OAAOK;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAKpE,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,qBAAqB;;;EAqBjH;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,SAAS,EAAE,0BAA0B,EAAE,GACtC,kBAAkB,EAAE,CAYtB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,mBAAmB,EAAE,0BAA0B,EAAE,GAChD,kBAAkB,GAAG,SAAS,CAEhC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,SAAS,EAAE,0BAA0B,EAAE,EACvC,UAAU,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,QAIhF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/utils.ts"],"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 { VariableDefinition } from '@perses-dev/core';\nimport { VariableStoreStateMap } from '@perses-dev/plugin-system';\nimport { ExternalVariableDefinition } from '@perses-dev/dashboards';\n\n/*\n * Check whether saved variable definitions are out of date with current default list values in Zustand store\n */\nexport function checkSavedDefaultVariableStatus(definitions: VariableDefinition[], varState: VariableStoreStateMap) {\n let isSavedVariableModified = false;\n const modifiedVariableNames: string[] = [];\n for (const savedVariable of definitions) {\n const name = savedVariable.spec.name;\n if (savedVariable.kind === 'ListVariable') {\n const currentVariable = varState.get({ name });\n if (currentVariable?.value !== null && currentVariable?.value !== savedVariable.spec.defaultValue) {\n modifiedVariableNames.push(name);\n isSavedVariableModified = true;\n }\n } else if (savedVariable.kind === 'TextVariable') {\n const currentVariable = varState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (savedVariable.spec.value !== currentVariableValue) {\n modifiedVariableNames.push(name);\n isSavedVariableModified = true;\n }\n }\n }\n return { isSavedVariableModified, modifiedVariableNames };\n}\n\n/**\n * Merge the different kind of variable definition into a list without any duplicates (same name).\n * Respects the order of priority explained in {@link forEachVariableDefinition}\n * @param locals\n * @param externals\n */\nexport function mergeVariableDefinitions(\n locals: VariableDefinition[],\n externals: ExternalVariableDefinition[]\n): VariableDefinition[] {\n const pushed: Record<string, boolean> = {};\n const result: VariableDefinition[] = [];\n\n // Append the value only if it's not already appended\n forEachVariableDefinition(locals, externals, (value: VariableDefinition, name: string) => {\n if (!pushed[name]) {\n result.push(value);\n pushed[name] = true;\n }\n });\n return result;\n}\n\n/**\n * Find a definition by its name.\n * Respects the order of priority explained in {@link forEachVariableDefinition}\n * @param name\n * @param localDefinitions\n * @param externalDefinitions\n */\nexport function findVariableDefinitionByName(\n name: string,\n localDefinitions: VariableDefinition[],\n externalDefinitions: ExternalVariableDefinition[]\n): VariableDefinition | undefined {\n return mergeVariableDefinitions(localDefinitions, externalDefinitions).find((d) => d.spec.name === name);\n}\n\n/**\n * Loop on local and external variable definitions, respecting the order of priority:\n * - local var defs override external var defs of same name\n * - each external var defs override the external var defs coming after.\n * @param locals\n * @param externals\n * @param callbackFn\n */\nexport function forEachVariableDefinition(\n locals: VariableDefinition[],\n externals: ExternalVariableDefinition[],\n callbackFn: (varDef: VariableDefinition, name: string, source?: string) => void\n) {\n locals.forEach((v) => callbackFn(v, v.spec.name));\n externals.forEach((ext) => ext.definitions.forEach((v) => callbackFn(v, v.spec.name, ext.source)));\n}\n"],"names":["checkSavedDefaultVariableStatus","definitions","varState","isSavedVariableModified","modifiedVariableNames","savedVariable","name","spec","kind","currentVariable","get","value","defaultValue","push","currentVariableValue","mergeVariableDefinitions","locals","externals","pushed","result","forEachVariableDefinition","findVariableDefinitionByName","localDefinitions","externalDefinitions","find","d","callbackFn","forEach","v","ext","source"],"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;AAMjC;;CAEC,GAC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,OAAOR,yBAAyBO,kBAAkBC,qBAAqBC,IAAI,CAAC,CAACC,IAAMA,EAAElB,IAAI,CAACD,IAAI,KAAKA;AACrG;AAEA;;;;;;;CAOC,GACD,OAAO,SAASc,0BACdJ,MAA4B,EAC5BC,SAAuC,EACvCS,UAA+E;IAE/EV,OAAOW,OAAO,CAAC,CAACC,IAAMF,WAAWE,GAAGA,EAAErB,IAAI,CAACD,IAAI;IAC/CW,UAAUU,OAAO,CAAC,CAACE,MAAQA,IAAI5B,WAAW,CAAC0B,OAAO,CAAC,CAACC,IAAMF,WAAWE,GAAGA,EAAErB,IAAI,CAACD,IAAI,EAAEuB,IAAIC,MAAM;AACjG"}
@@ -1,33 +0,0 @@
1
- // Copyright 2023 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 { DashboardProvider } from '@perses-dev/dashboards';
15
- import { EMPTY_DASHBOARD_RESOURCE } from './constants';
16
- // Type guard because storybook types parameters as `any`
17
- function isWithDashboardParameter(parameter) {
18
- return !!parameter && typeof parameter === 'object' && 'props' in parameter;
19
- }
20
- export const WithDashboard = (Story, context)=>{
21
- const initParameter = context.parameters.withDashboard;
22
- const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;
23
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
24
- return /*#__PURE__*/ _jsx(DashboardProvider, {
25
- initialState: {
26
- dashboardResource: EMPTY_DASHBOARD_RESOURCE
27
- },
28
- ...props,
29
- children: /*#__PURE__*/ _jsx(Story, {})
30
- });
31
- };
32
-
33
- //# sourceMappingURL=WithDashboard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithDashboard.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DashboardProvider, DashboardProviderProps } from '@perses-dev/dashboards';\nimport { EMPTY_DASHBOARD_RESOURCE } from './constants';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDashboard?: WithDashboardParameter;\n }\n}\n\nexport type WithDashboardParameter = {\n props: Partial<DashboardProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDashboardParameter(parameter: unknown | WithDashboardParameter): parameter is WithDashboardParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDashboard = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDashboard;\n const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DashboardProvider initialState={{ dashboardResource: EMPTY_DASHBOARD_RESOURCE }} {...props}>\n <Story />\n </DashboardProvider>\n );\n};\n"],"names":["DashboardProvider","EMPTY_DASHBOARD_RESOURCE","isWithDashboardParameter","parameter","WithDashboard","Story","context","initParameter","parameters","withDashboard","undefined","props","initialState","dashboardResource"],"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,SAASA,iBAAiB,QAAgC,yBAAyB;AACnF,SAASC,wBAAwB,QAAQ,cAAc;AAYvD,yDAAyD;AACzD,SAASC,yBAAyBC,SAA2C;IAC3E,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,gBAAgB,CAACC,OAAgBC;IAC5C,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,aAAa;IACtD,MAAMN,YAAYD,yBAAyBK,iBAAiBA,gBAAgBG;IAC5E,MAAMC,QAAQR,sBAAAA,gCAAAA,UAAWQ,KAAK;IAE9B,qBACE,KAACX;QAAkBY,cAAc;YAAEC,mBAAmBZ;QAAyB;QAAI,GAAGU,KAAK;kBACzF,cAAA,KAACN;;AAGP,EAAE"}
@@ -1,31 +0,0 @@
1
- // Copyright 2023 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 { DatasourceStoreProvider } from '@perses-dev/dashboards';
15
- import { defaultDatasourceProps } from '../../test';
16
- // Type guard because storybook types parameters as `any`
17
- function isWithDatasourceStoreParameter(parameter) {
18
- return !!parameter && typeof parameter === 'object' && 'props' in parameter;
19
- }
20
- export const WithDatasourceStore = (Story, context)=>{
21
- const initParameter = context.parameters.withDatasourceStore;
22
- const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;
23
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
24
- return /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
25
- ...defaultDatasourceProps,
26
- ...props,
27
- children: /*#__PURE__*/ _jsx(Story, {})
28
- });
29
- };
30
-
31
- //# sourceMappingURL=WithDatasourceStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithDatasourceStore.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DatasourceStoreProvider, DatasourceStoreProviderProps } from '@perses-dev/dashboards';\nimport { defaultDatasourceProps } from '../../test';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDatasourceStore?: WithDatasourceStoreParameter;\n }\n}\n\nexport type WithDatasourceStoreParameter = {\n props: Partial<DatasourceStoreProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatasourceStoreParameter(\n parameter: unknown | WithDatasourceStoreParameter\n): parameter is WithDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDatasourceStore;\n const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DatasourceStoreProvider {...defaultDatasourceProps} {...props}>\n <Story />\n </DatasourceStoreProvider>\n );\n};\n"],"names":["DatasourceStoreProvider","defaultDatasourceProps","isWithDatasourceStoreParameter","parameter","WithDatasourceStore","Story","context","initParameter","parameters","withDatasourceStore","undefined","props"],"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,SAASA,uBAAuB,QAAsC,yBAAyB;AAC/F,SAASC,sBAAsB,QAAQ,aAAa;AAYpD,yDAAyD;AACzD,SAASC,+BACPC,SAAiD;IAEjD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,sBAAsB,CAACC,OAAgBC;IAClD,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,mBAAmB;IAC5D,MAAMN,YAAYD,+BAA+BK,iBAAiBA,gBAAgBG;IAClF,MAAMC,QAAQR,sBAAAA,gCAAAA,UAAWQ,KAAK;IAE9B,qBACE,KAACX;QAAyB,GAAGC,sBAAsB;QAAG,GAAGU,KAAK;kBAC5D,cAAA,KAACN;;AAGP,EAAE"}
@@ -1,29 +0,0 @@
1
- // Copyright 2023 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 { TemplateVariableProvider } from '@perses-dev/dashboards';
15
- // Type guard because storybook types parameters as `any`
16
- function isWithTemplateVariableParameter(parameter) {
17
- return !!parameter && typeof parameter === 'object' && 'props' in parameter;
18
- }
19
- export const WithTemplateVariables = (Story, context)=>{
20
- const initParameter = context.parameters.withTemplateVariables;
21
- const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;
22
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
23
- return /*#__PURE__*/ _jsx(TemplateVariableProvider, {
24
- ...props,
25
- children: /*#__PURE__*/ _jsx(Story, {})
26
- });
27
- };
28
-
29
- //# sourceMappingURL=WithTemplateVariables.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithTemplateVariables.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableProvider, TemplateVariableProviderProps } from '@perses-dev/dashboards';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTemplateVariables?: WithTemplateVariableParameter;\n }\n}\n\nexport type WithTemplateVariableParameter = {\n props: Partial<TemplateVariableProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithTemplateVariableParameter\n): parameter is WithTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTemplateVariables;\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TemplateVariableProvider {...props}>\n <Story />\n </TemplateVariableProvider>\n );\n};\n"],"names":["TemplateVariableProvider","isWithTemplateVariableParameter","parameter","WithTemplateVariables","Story","context","initParameter","parameters","withTemplateVariables","undefined","props"],"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,SAASA,wBAAwB,QAAuC,yBAAyB;AAYjG,yDAAyD;AACzD,SAASC,gCACPC,SAAkD;IAElD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,wBAAwB,CAACC,OAAgBC;IACpD,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,qBAAqB;IAC9D,MAAMN,YAAYD,gCAAgCK,iBAAiBA,gBAAgBG;IACnF,MAAMC,QAAQR,sBAAAA,gCAAAA,UAAWQ,KAAK;IAE9B,qBACE,KAACV;QAA0B,GAAGU,KAAK;kBACjC,cAAA,KAACN;;AAGP,EAAE"}
@@ -1,31 +0,0 @@
1
- // Copyright 2023 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 const EMPTY_DASHBOARD_RESOURCE = {
14
- kind: 'Dashboard',
15
- metadata: {
16
- name: 'My Dashboard',
17
- project: 'Storybook',
18
- createdAt: '2021-11-09T00:00:00Z',
19
- updatedAt: '2021-11-09T00:00:00Z',
20
- version: 0
21
- },
22
- spec: {
23
- duration: '1h',
24
- refreshInterval: '0s',
25
- variables: [],
26
- layouts: [],
27
- panels: {}
28
- }
29
- };
30
-
31
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/constants.ts"],"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 { DashboardResource } from '@perses-dev/core';\n\nexport const EMPTY_DASHBOARD_RESOURCE: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'My Dashboard',\n project: 'Storybook',\n createdAt: '2021-11-09T00:00:00Z',\n updatedAt: '2021-11-09T00:00:00Z',\n version: 0,\n },\n spec: {\n duration: '1h',\n refreshInterval: '0s',\n variables: [],\n layouts: [],\n panels: {},\n },\n};\n"],"names":["EMPTY_DASHBOARD_RESOURCE","kind","metadata","name","project","createdAt","updatedAt","version","spec","duration","refreshInterval","variables","layouts","panels"],"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;AAIjC,OAAO,MAAMA,2BAA8C;IACzDC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,SAAS;QACTC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,UAAU;QACVC,iBAAiB;QACjBC,WAAW,EAAE;QACbC,SAAS,EAAE;QACXC,QAAQ,CAAC;IACX;AACF,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/index.ts"],"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\nexport * from './constants';\nexport * from './WithDashboard';\nexport * from './WithDatasourceStore';\nexport * from './WithTemplateVariables';\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,cAAc;AAC5B,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,0BAA0B"}
@@ -1,2 +0,0 @@
1
- export * from './panel';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/validation/index.ts"],"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\nexport * from './panel';\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,UAAU"}
@@ -1,19 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const panelEditorValidationSchema: z.ZodObject<{
3
- name: z.ZodString;
4
- groupId: z.ZodNumber;
5
- description: z.ZodOptional<z.ZodString>;
6
- type: z.ZodString;
7
- }, "strip", z.ZodTypeAny, {
8
- name: string;
9
- groupId: number;
10
- type: string;
11
- description?: string | undefined;
12
- }, {
13
- name: string;
14
- groupId: number;
15
- type: string;
16
- description?: string | undefined;
17
- }>;
18
- export type PanelEditorValidationType = z.infer<typeof panelEditorValidationSchema>;
19
- //# sourceMappingURL=panel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/validation/panel.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;EAKtC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -1,21 +0,0 @@
1
- // Copyright 2023 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 { z } from 'zod';
14
- export const panelEditorValidationSchema = z.object({
15
- name: z.string().nonempty('Required'),
16
- groupId: z.number(),
17
- description: z.string().optional(),
18
- type: z.string().nonempty('Required')
19
- });
20
-
21
- //# sourceMappingURL=panel.js.map