@perses-dev/dashboards 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +9 -3
  2. package/dist/cjs/components/DownloadButton/DownloadButton.js +109 -0
  3. package/dist/cjs/{utils → components/DownloadButton}/index.js +1 -1
  4. package/dist/cjs/{css/styles.js → components/GridLayout/GridContainer.js} +66 -39
  5. package/dist/cjs/components/GridLayout/GridLayout.js +51 -64
  6. package/dist/cjs/components/GridLayout/GridTitle.js +11 -14
  7. package/dist/cjs/components/Panel/Panel.js +4 -2
  8. package/dist/cjs/components/Panel/PanelHeader.js +52 -48
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +23 -0
  10. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +15 -54
  11. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +27 -11
  12. package/dist/cjs/components/Variables/Variable.js +16 -4
  13. package/dist/cjs/components/Variables/VariableEditor.js +21 -1
  14. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +63 -7
  15. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
  16. package/dist/cjs/components/Variables/VariableList.js +81 -17
  17. package/dist/cjs/components/index.js +1 -0
  18. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -1
  19. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +68 -39
  20. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +40 -15
  21. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +5 -9
  22. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +16 -1
  23. package/dist/cjs/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
  24. package/dist/cjs/{utils/component-ids.js → context/TimeRangeProvider/index.js} +12 -14
  25. package/dist/cjs/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +11 -5
  26. package/dist/cjs/index.js +0 -1
  27. package/dist/cjs/test/testDashboard.js +1 -1
  28. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  29. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -7
  30. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +16 -22
  31. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
  32. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  33. package/dist/components/DashboardToolbar/DashboardToolbar.js +9 -3
  34. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  35. package/dist/components/DownloadButton/DownloadButton.d.ts +3 -0
  36. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -0
  37. package/dist/components/DownloadButton/DownloadButton.js +60 -0
  38. package/dist/components/DownloadButton/DownloadButton.js.map +1 -0
  39. package/dist/components/DownloadButton/index.d.ts +2 -0
  40. package/dist/components/DownloadButton/index.d.ts.map +1 -0
  41. package/dist/{utils → components/DownloadButton}/index.js +1 -1
  42. package/dist/components/DownloadButton/index.js.map +1 -0
  43. package/dist/components/GridLayout/GridContainer.d.ts +6 -0
  44. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
  45. package/dist/{css/styles.js → components/GridLayout/GridContainer.js} +65 -38
  46. package/dist/components/GridLayout/GridContainer.js.map +1 -0
  47. package/dist/components/GridLayout/GridLayout.d.ts +1 -2
  48. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  49. package/dist/components/GridLayout/GridLayout.js +53 -66
  50. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  51. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  52. package/dist/components/GridLayout/GridTitle.js +12 -15
  53. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  54. package/dist/components/Panel/Panel.d.ts.map +1 -1
  55. package/dist/components/Panel/Panel.js +4 -2
  56. package/dist/components/Panel/Panel.js.map +1 -1
  57. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  58. package/dist/components/Panel/PanelHeader.js +52 -48
  59. package/dist/components/Panel/PanelHeader.js.map +1 -1
  60. package/dist/components/PanelDrawer/PanelDrawer.test.js +23 -0
  61. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  62. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  63. package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -58
  64. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  65. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +28 -12
  66. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  67. package/dist/components/Variables/Variable.js +16 -4
  68. package/dist/components/Variables/Variable.js.map +1 -1
  69. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  70. package/dist/components/Variables/VariableEditor.js +23 -3
  71. package/dist/components/Variables/VariableEditor.js.map +1 -1
  72. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  73. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +25 -3
  74. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  75. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
  76. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  77. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
  78. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  79. package/dist/components/Variables/VariableList.d.ts +5 -1
  80. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  81. package/dist/components/Variables/VariableList.js +43 -18
  82. package/dist/components/Variables/VariableList.js.map +1 -1
  83. package/dist/components/index.d.ts +1 -0
  84. package/dist/components/index.d.ts.map +1 -1
  85. package/dist/components/index.js +1 -0
  86. package/dist/components/index.js.map +1 -1
  87. package/dist/context/DashboardProvider/DashboardProvider.js +2 -1
  88. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  89. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -1
  90. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  91. package/dist/context/DashboardProvider/dashboard-provider-api.js +70 -41
  92. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  93. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  94. package/dist/context/DashboardProvider/panel-editor-slice.js +40 -15
  95. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  96. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  97. package/dist/context/DashboardProvider/panel-group-editor-slice.js +5 -9
  98. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  99. package/dist/context/DashboardProvider/panel-group-slice.d.ts +9 -0
  100. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  101. package/dist/context/DashboardProvider/panel-group-slice.js +17 -0
  102. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  103. package/dist/context/{TimeRangeProvider.d.ts → TimeRangeProvider/TimeRangeProvider.d.ts} +2 -2
  104. package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
  105. package/dist/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
  106. package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
  107. package/dist/context/TimeRangeProvider/index.d.ts +3 -0
  108. package/dist/context/TimeRangeProvider/index.d.ts.map +1 -0
  109. package/dist/{utils/component-ids.js → context/TimeRangeProvider/index.js} +3 -14
  110. package/dist/context/TimeRangeProvider/index.js.map +1 -0
  111. package/dist/{utils/time-range-params.d.ts → context/TimeRangeProvider/query-params.d.ts} +3 -3
  112. package/dist/context/TimeRangeProvider/query-params.d.ts.map +1 -0
  113. package/dist/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +13 -7
  114. package/dist/context/TimeRangeProvider/query-params.js.map +1 -0
  115. package/dist/index.d.ts +0 -1
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +0 -1
  118. package/dist/index.js.map +1 -1
  119. package/dist/test/testDashboard.js +1 -1
  120. package/dist/test/testDashboard.js.map +1 -1
  121. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  122. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  123. package/dist/views/ViewDashboard/DashboardApp.js +2 -1
  124. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  125. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  126. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  127. package/dist/views/ViewDashboard/ViewDashboard.js +6 -7
  128. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  129. package/dist/views/ViewDashboard/tests/panelGroups.test.js +16 -22
  130. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  131. package/package.json +4 -4
  132. package/dist/context/TimeRangeProvider.d.ts.map +0 -1
  133. package/dist/context/TimeRangeProvider.js.map +0 -1
  134. package/dist/css/styles.d.ts +0 -172
  135. package/dist/css/styles.d.ts.map +0 -1
  136. package/dist/css/styles.js.map +0 -1
  137. package/dist/utils/component-ids.d.ts +0 -8
  138. package/dist/utils/component-ids.d.ts.map +0 -1
  139. package/dist/utils/component-ids.js.map +0 -1
  140. package/dist/utils/index.d.ts +0 -2
  141. package/dist/utils/index.d.ts.map +0 -1
  142. package/dist/utils/index.js.map +0 -1
  143. package/dist/utils/time-range-params.d.ts.map +0 -1
  144. package/dist/utils/time-range-params.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider timeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panel = screen.getByText('CPU');\n userEvent.hover(panel);\n const deletePanelButton = screen.getByLabelText('delete panel');\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText('CPU');\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panels = screen.getAllByText('Disk I/O Utilization');\n expect(panels).toHaveLength(2);\n\n const panel = panels[0];\n if (panel === undefined) throw new Error('Missing panel');\n\n userEvent.hover(panel);\n const deletePanelButton = screen.getByLabelText('delete panel');\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText('Disk I/O Utilization');\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const group1 = screen.getByText('CPU Stats');\n userEvent.hover(group1);\n const moveGroupDownBtn = screen.getByLabelText('move group down');\n userEvent.click(moveGroupDownBtn);\n userEvent.unhover(moveGroupDownBtn);\n\n // should move panel up\n const group2 = screen.getByText('Disk Stats');\n userEvent.hover(group2);\n const moveGroupUpBtn = screen.getByLabelText('move group up');\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const group = screen.getByText('CPU Stats');\n userEvent.hover(group);\n const deleteGroupIcon = screen.getByLabelText('delete group');\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText('CPU Stats');\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","DashboardProvider","TemplateVariableProvider","TimeRangeProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","timeRange","pastDuration","initialState","dashboardResource","isEditMode","it","panel","getByText","hover","deletePanelButton","getByLabelText","click","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","undefined","Error","group1","moveGroupDownBtn","unhover","group2","moveGroupUpBtn","group","deleteGroupIcon","deletedGroup"],"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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AC,CAACU,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFX,KAAK,GAAGhB,MAAM,CAACwB,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACT,KAAK,CAAC,CAACW,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider initialTimeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panelTitle = 'CPU';\n const deletePanelButton = screen.getByLabelText(`delete panel ${panelTitle}`);\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panelTitle = 'Disk I/O Utilization';\n const panels = screen.getAllByText(panelTitle);\n expect(panels).toHaveLength(2);\n\n const deletePanelButton = screen.getAllByLabelText(`delete panel ${panelTitle}`)[0];\n if (deletePanelButton === undefined) throw new Error('Missing delete button');\n\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const groupTitle1 = 'CPU Stats';\n const moveGroupDownBtn = screen.getByLabelText(`move group ${groupTitle1} down`);\n userEvent.click(moveGroupDownBtn);\n\n // should move panel up\n const groupTitle2 = 'Disk Stats';\n const moveGroupUpBtn = screen.getByLabelText(`move group ${groupTitle2} up`);\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const groupTitle = 'CPU Stats';\n const deleteGroupIcon = screen.getByLabelText(`delete group ${groupTitle}`);\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText(groupTitle);\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","DashboardProvider","TemplateVariableProvider","TimeRangeProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","initialTimeRange","pastDuration","initialState","dashboardResource","isEditMode","it","panelTitle","deletePanelButton","getByLabelText","click","getByText","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","getAllByLabelText","undefined","Error","groupTitle1","moveGroupDownBtn","groupTitle2","moveGroupUpBtn","groupTitle","deleteGroupIcon","deletedGroup","panel"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,iBAAiB,EAAEC,wBAAwB,EAAEC,iBAAiB,QAAQ,kBAAkB,CAAC;AAClG,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,eAAe,CAAC;AACpE,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAE/CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,eAAe,GAAG,IAAM;QAC5BH,iBAAiB,eACf,KAACF,iBAAiB;YAACM,gBAAgB,EAAE;gBAAEC,YAAY,EAAE,KAAK;aAAE;sBAC1D,cAAA,KAACR,wBAAwB;0BACvB,cAAA,KAACD,iBAAiB;oBAACU,YAAY,EAAE;wBAAEC,iBAAiB,EAAER,gBAAgB,EAAE;wBAAES,UAAU,EAAE,IAAI;qBAAE;8BAC1F,cAAA,KAACP,YAAY;wBAACM,iBAAiB,EAAER,gBAAgB,EAAE;sBAAI;kBACrC;cACK;UACT,CACrB,CAAC;IACJ,CAAC,AAAC;IACFU,EAAE,CAAC,qBAAqB,EAAE,IAAM;QAC9BN,eAAe,EAAE,CAAC;QAClB,MAAMO,UAAU,GAAG,KAAK,AAAC;QACzB,MA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ACe,YAAY,CAAC,CAACd,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAE7C,yEAAyE;QACzE,IAAIc,KAAK,GAAGxC,MAAM,CAACuB,WAAW,CAAC,KAAK,CAAC,AAAC;QACtCC,MAAM,CAACgB,KAAK,CAAC,CAACf,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFc,KAAK,GAAGxC,MAAM,CAACuB,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACgB,KAAK,CAAC,CAACd,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -28,9 +28,9 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "^0.14.0",
32
- "@perses-dev/core": "^0.14.0",
33
- "@perses-dev/plugin-system": "^0.14.0",
31
+ "@perses-dev/components": "^0.16.0",
32
+ "@perses-dev/core": "^0.16.0",
33
+ "@perses-dev/plugin-system": "^0.16.0",
34
34
  "@types/react-grid-layout": "^1.3.2",
35
35
  "date-fns": "^2.28.0",
36
36
  "immer": "^9.0.15",
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../src/context/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,cAAc,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAiB9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB;;;EAGpC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/context/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useMemo } from 'react';\nimport { TimeRangeValue } from '@perses-dev/core';\nimport { TimeRangeContext, useTimeRangeContext } from '@perses-dev/plugin-system';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n setTimeRange?: (value: TimeRangeValue) => void;\n children?: React.ReactNode;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { timeRange, children, setTimeRange } = props;\n\n // TODO: fix no-op, pass paramsEnabled as false in useSetTimeRangeParams as workaround\n const ctx = useMemo(\n () => ({\n timeRange,\n setTimeRange:\n setTimeRange ??\n (() => {\n /* no-op */\n }),\n }),\n [timeRange, setTimeRange]\n );\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n\n/**\n * Internal version of time range hook to get all supported values\n */\nexport function useDashboardTimeRange() {\n const { timeRange, setTimeRange } = useTimeRangeContext();\n return { timeRange, setTimeRange };\n}\n"],"names":["React","useMemo","TimeRangeContext","useTimeRangeContext","TimeRangeProvider","props","timeRange","children","setTimeRange","ctx","Provider","value","useDashboardTimeRange"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO,CAAC;AAEvC,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,2BAA2B,CAAC;AAQlF;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,SAAS,CAAA,EAAEC,QAAQ,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEpD,sFAAsF;IACtF,MAAMI,GAAG,GAAGR,OAAO,CACjB,IAAO,CAAA;YACLK,SAAS;YACTE,YAAY,EACVA,YAAY,aAAZA,YAAY,cAAZA,YAAY,GACX,IAAM;YACL,SAAS,GACX,CAAC,AAAC;SACL,CAAA,AAAC,EACF;QAACF,SAAS;QAAEE,YAAY;KAAC,CAC1B,AAAC;IAEF,qBAAO,KAACN,gBAAgB,CAACQ,QAAQ;QAACC,KAAK,EAAEF,GAAG;kBAAGF,QAAQ;MAA6B,CAAC;AACvF,CAAC;AAED;;CAEC,GACD,OAAO,SAASK,qBAAqB,GAAG;IACtC,MAAM,EAAEN,SAAS,CAAA,EAAEE,YAAY,CAAA,EAAE,GAAGL,mBAAmB,EAAE,AAAC;IAC1D,OAAO;QAAEG,SAAS;QAAEE,YAAY;KAAE,CAAC;AACrC,CAAC"}
@@ -1,172 +0,0 @@
1
- import { Theme } from '@mui/material';
2
- export declare const styles: (theme: Theme) => {
3
- readonly '&.react-grid-layout': {
4
- readonly position: "relative";
5
- readonly transition: "height 200ms ease";
6
- };
7
- readonly '&.react-grid-item': {
8
- readonly transition: "all 200ms ease";
9
- readonly transitionProperty: "left, top";
10
- };
11
- readonly '&.react-grid-item img': {
12
- readonly pointerEvents: "none";
13
- readonly userSelect: "none";
14
- };
15
- readonly '&.react-grid-item.cssTransforms': {
16
- readonly transitionProperty: "transform";
17
- };
18
- readonly '&.react-grid-item.resizing': {
19
- readonly zIndex: 1;
20
- readonly willChange: "width, height";
21
- };
22
- readonly '&.react-grid-item.react-draggable-dragging': {
23
- readonly transition: "none";
24
- readonly zIndex: 3;
25
- readonly willChange: "transform";
26
- };
27
- readonly '&.react-grid-item.dropping': {
28
- readonly visibility: "hidden";
29
- };
30
- readonly '&.react-grid-item.react-grid-placeholder': {
31
- readonly background: string;
32
- readonly opacity: 0.2;
33
- readonly transitionDuration: "100ms";
34
- readonly zIndex: 2;
35
- readonly userSelect: "none";
36
- readonly WebkitUserSelect: "none";
37
- readonly MozUserSelect: "none";
38
- readonly msUserSelect: "none";
39
- readonly OUserSelect: "none";
40
- };
41
- readonly '&.react-grid-item > .react-resizable-handle': {
42
- readonly position: "absolute";
43
- readonly width: "20px";
44
- readonly height: "20px";
45
- };
46
- readonly '&.react-grid-item > .react-resizable-handle::after': {
47
- readonly content: "\"\"";
48
- readonly position: "absolute";
49
- readonly right: "3px";
50
- readonly bottom: "3px";
51
- readonly width: "5px";
52
- readonly height: "5px";
53
- readonly borderRight: "2px solid rgba(0, 0, 0, 0.4)";
54
- readonly borderBottom: "2px solid rgba(0, 0, 0, 0.4)";
55
- };
56
- readonly '&.react-resizable-hide > .react-resizable-handle': {
57
- readonly display: "none";
58
- };
59
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {
60
- readonly bottom: "0";
61
- readonly left: "0";
62
- readonly cursor: "sw-resize";
63
- readonly transform: "rotate(90deg)";
64
- };
65
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-se': {
66
- readonly bottom: "0";
67
- readonly right: "0";
68
- readonly cursor: "se-resize";
69
- };
70
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {
71
- readonly top: "0";
72
- readonly left: "0";
73
- readonly cursor: "nw-resize";
74
- readonly transform: "rotate(180deg)";
75
- };
76
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {
77
- readonly top: "0";
78
- readonly right: "0";
79
- readonly cursor: "ne-resize";
80
- readonly transform: "rotate(270deg)";
81
- };
82
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
83
- readonly top: "50%";
84
- readonly marginTop: "-10px";
85
- readonly cursor: "ew-resize";
86
- };
87
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
88
- readonly left: "0";
89
- readonly transform: "rotate(135deg)";
90
- };
91
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
92
- readonly right: "0";
93
- readonly transform: "rotate(315deg)";
94
- };
95
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
96
- readonly left: "50%";
97
- readonly marginLeft: "-10px";
98
- readonly cursor: "ns-resize";
99
- };
100
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
101
- readonly top: "0";
102
- readonly transform: "rotate(225deg)";
103
- };
104
- readonly '&.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
105
- readonly bottom: "0";
106
- readonly transform: "rotate(45deg)";
107
- };
108
- readonly '&.react-resizable': {
109
- readonly position: "relative";
110
- };
111
- readonly '&.react-resizable-handle': {
112
- readonly position: "absolute";
113
- readonly width: "20px";
114
- readonly height: "20px";
115
- readonly backgroundRepeat: "no-repeat";
116
- readonly backgroundOrigin: "content-box";
117
- readonly boxSizing: "border-box";
118
- readonly backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+')";
119
- readonly backgroundPosition: "bottom right";
120
- readonly padding: "0 3px 3px 0";
121
- };
122
- readonly '&.react-resizable-handle-sw': {
123
- readonly bottom: "0";
124
- readonly left: "0";
125
- readonly cursor: "sw-resize";
126
- readonly transform: "rotate(90deg)";
127
- };
128
- readonly '&.react-resizable-handle-se': {
129
- readonly bottom: "0";
130
- readonly right: "0";
131
- readonly cursor: "se-resize";
132
- };
133
- readonly '&.react-resizable-handle-nw': {
134
- readonly top: "0";
135
- readonly left: "0";
136
- readonly cursor: "nw-resize";
137
- readonly transform: "rotate(180deg)";
138
- };
139
- readonly '&.react-resizable-handle-ne': {
140
- readonly top: "0";
141
- readonly right: "0";
142
- readonly cursor: "ne-resize";
143
- readonly transform: "rotate(270deg)";
144
- };
145
- readonly '&.react-resizable-handle-w, .react-resizable-handle-e': {
146
- readonly top: "50%";
147
- readonly marginTop: "-10px";
148
- readonly cursor: "ew-resize";
149
- };
150
- readonly '&.react-resizable-handle-w': {
151
- readonly left: "0";
152
- readonly transform: "rotate(135deg)";
153
- };
154
- readonly '&.react-resizable-handle-e': {
155
- readonly right: "0";
156
- readonly transform: "rotate(315deg)";
157
- };
158
- readonly '&.react-resizable-handle-n, .react-resizable-handle-s': {
159
- readonly left: "50%";
160
- readonly marginLeft: "-10px";
161
- readonly cursor: "ns-resize";
162
- };
163
- readonly '&.react-resizable-handle-n': {
164
- readonly top: "0";
165
- readonly transform: "rotate(225deg)";
166
- };
167
- readonly '&.react-resizable-handle-s': {
168
- readonly bottom: "0";
169
- readonly transform: "rotate(45deg)";
170
- };
171
- };
172
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/css/styles.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,eAAO,MAAM,MAAM,UAAW,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgLlC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/css/styles.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\n\nexport const styles = (theme: Theme) => {\n return {\n '&.react-grid-layout': {\n position: 'relative',\n transition: 'height 200ms ease',\n },\n '&.react-grid-item': {\n transition: 'all 200ms ease',\n transitionProperty: 'left, top',\n },\n '&.react-grid-item img': {\n pointerEvents: 'none',\n userSelect: 'none',\n },\n '&.react-grid-item.cssTransforms': {\n transitionProperty: 'transform',\n },\n '&.react-grid-item.resizing': {\n zIndex: 1,\n willChange: 'width, height',\n },\n '&.react-grid-item.react-draggable-dragging': {\n transition: 'none',\n zIndex: 3,\n willChange: 'transform',\n },\n '&.react-grid-item.dropping': {\n visibility: 'hidden',\n },\n '&.react-grid-item.react-grid-placeholder': {\n background: theme.palette.primary.main,\n opacity: 0.2,\n transitionDuration: '100ms',\n zIndex: 2,\n userSelect: 'none',\n WebkitUserSelect: 'none',\n MozUserSelect: 'none',\n msUserSelect: 'none',\n OUserSelect: 'none',\n },\n\n '&.react-grid-item > .react-resizable-handle': {\n position: 'absolute',\n width: '20px',\n height: '20px',\n },\n '&.react-grid-item > .react-resizable-handle::after': {\n content: '\"\"',\n position: 'absolute',\n right: '3px',\n bottom: '3px',\n width: '5px',\n height: '5px',\n borderRight: '2px solid rgba(0, 0, 0, 0.4)',\n borderBottom: '2px solid rgba(0, 0, 0, 0.4)',\n },\n\n '&.react-resizable-hide > .react-resizable-handle': {\n display: 'none',\n },\n\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {\n bottom: '0',\n left: '0',\n cursor: 'sw-resize',\n transform: 'rotate(90deg)',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-se': {\n bottom: '0',\n right: '0',\n cursor: 'se-resize',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {\n top: '0',\n left: '0',\n cursor: 'nw-resize',\n transform: 'rotate(180deg)',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {\n top: '0',\n right: '0',\n cursor: 'ne-resize',\n transform: 'rotate(270deg)',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e':\n {\n top: '50%',\n marginTop: '-10px',\n cursor: 'ew-resize',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w': {\n left: '0',\n transform: 'rotate(135deg)',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {\n right: '0',\n transform: 'rotate(315deg)',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s':\n {\n left: '50%',\n marginLeft: '-10px',\n cursor: 'ns-resize',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n': {\n top: '0',\n transform: 'rotate(225deg)',\n },\n '&.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {\n bottom: '0',\n transform: 'rotate(45deg)',\n },\n '&.react-resizable': {\n position: 'relative',\n },\n '&.react-resizable-handle': {\n position: 'absolute',\n width: '20px',\n height: '20px',\n backgroundRepeat: 'no-repeat',\n backgroundOrigin: 'content-box',\n boxSizing: 'border-box',\n backgroundImage: `url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+')`,\n backgroundPosition: 'bottom right',\n padding: '0 3px 3px 0',\n },\n '&.react-resizable-handle-sw': {\n bottom: '0',\n left: '0',\n cursor: 'sw-resize',\n transform: 'rotate(90deg)',\n },\n '&.react-resizable-handle-se': {\n bottom: '0',\n right: '0',\n cursor: 'se-resize',\n },\n '&.react-resizable-handle-nw': {\n top: '0',\n left: '0',\n cursor: 'nw-resize',\n transform: 'rotate(180deg)',\n },\n '&.react-resizable-handle-ne': {\n top: '0',\n right: '0',\n cursor: 'ne-resize',\n transform: 'rotate(270deg)',\n },\n '&.react-resizable-handle-w, .react-resizable-handle-e': {\n top: '50%',\n marginTop: '-10px',\n cursor: 'ew-resize',\n },\n '&.react-resizable-handle-w': {\n left: '0',\n transform: 'rotate(135deg)',\n },\n '&.react-resizable-handle-e': {\n right: '0',\n transform: 'rotate(315deg)',\n },\n '&.react-resizable-handle-n, .react-resizable-handle-s': {\n left: '50%',\n marginLeft: '-10px',\n cursor: 'ns-resize',\n },\n '&.react-resizable-handle-n': {\n top: '0',\n transform: 'rotate(225deg)',\n },\n '&.react-resizable-handle-s': {\n bottom: '0',\n transform: 'rotate(45deg)',\n },\n } as const;\n};\n"],"names":["styles","theme","position","transition","transitionProperty","pointerEvents","userSelect","zIndex","willChange","visibility","background","palette","primary","main","opacity","transitionDuration","WebkitUserSelect","MozUserSelect","msUserSelect","OUserSelect","width","height","content","right","bottom","borderRight","borderBottom","display","left","cursor","transform","top","marginTop","marginLeft","backgroundRepeat","backgroundOrigin","boxSizing","backgroundImage","backgroundPosition","padding"],"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,MAAM,GAAG,CAACC,KAAY,GAAK;IACtC,OAAO;QACL,qBAAqB,EAAE;YACrBC,QAAQ,EAAE,UAAU;YACpBC,UAAU,EAAE,mBAAmB;SAChC;QACD,mBAAmB,EAAE;YACnBA,UAAU,EAAE,gBAAgB;YAC5BC,kBAAkB,EAAE,WAAW;SAChC;QACD,uBAAuB,EAAE;YACvBC,aAAa,EAAE,MAAM;YACrBC,UAAU,EAAE,MAAM;SACnB;QACD,iCAAiC,EAAE;YACjCF,kBAAkB,EAAE,WAAW;SAChC;QACD,4BAA4B,EAAE;YAC5BG,MAAM,EAAE,CAAC;YACTC,UAAU,EAAE,eAAe;SAC5B;QACD,4CAA4C,EAAE;YAC5CL,UAAU,EAAE,MAAM;YAClBI,MAAM,EAAE,CAAC;YACTC,UAAU,EAAE,WAAW;SACxB;QACD,4BAA4B,EAAE;YAC5BC,UAAU,EAAE,QAAQ;SACrB;QACD,0CAA0C,EAAE;YAC1CC,UAAU,EAAET,KAAK,CAACU,OAAO,CAACC,OAAO,CAACC,IAAI;YACtCC,OAAO,EAAE,GAAG;YACZC,kBAAkB,EAAE,OAAO;YAC3BR,MAAM,EAAE,CAA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E,GAAG;YACTE,SAAS,EAAE,gBAAgB;SAC5B;QACD,4BAA4B,EAAE;YAC5BP,KAAK,EAAE,GAAG;YACVO,SAAS,EAAE,gBAAgB;SAC5B;QACD,uDAAuD,EAAE;YACvDF,IAAI,EAAE,KAAK;YACXK,UAAU,EAAE,OAAO;YACnBJ,MAAM,EAAE,WAAW;SACpB;QACD,4BAA4B,EAAE;YAC5BE,GAAG,EAAE,GAAG;YACRD,SAAS,EAAE,gBAAgB;SAC5B;QACD,4BAA4B,EAAE;YAC5BN,MAAM,EAAE,GAAG;YACXM,SAAS,EAAE,eAAe;SAC3B;KACF,CAAU;AACb,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- declare global {
2
- var useIdValue: number;
3
- }
4
- /**
5
- * Generates a unique (stable) ID for a component. Should be replaced with React.useId once we support only React 18.
6
- */
7
- export declare function useId(prefix: string): string;
8
- //# sourceMappingURL=component-ids.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component-ids.d.ts","sourceRoot":"","sources":["../../src/utils/component-ids.ts"],"names":[],"mappings":"AAeA,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,UAAU,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,UAUnC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/component-ids.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useRef } from 'react';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var useIdValue: number;\n}\n\n/**\n * Generates a unique (stable) ID for a component. Should be replaced with React.useId once we support only React 18.\n */\nexport function useId(prefix: string) {\n if (globalThis.useIdValue === undefined) {\n globalThis.useIdValue = 0;\n }\n\n const id = useRef<string | undefined>(undefined);\n if (id.current === undefined) {\n id.current = `${prefix}-${globalThis.useIdValue++}`;\n }\n return id.current;\n}\n"],"names":["useRef","useId","prefix","globalThis","useIdValue","undefined","id","current"],"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,MAAM,QAAQ,OAAO,CAAC;AAO/B;;CAEC,GACD,OAAO,SAASC,KAAK,CAACC,MAAc,EAAE;IACpC,IAAIC,UAAU,CAACC,UAAU,KAAKC,SAAS,EAAE;QACvCF,UAAU,CAACC,UAAU,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,MAAME,EAAE,GAAGN,MAAM,CAAqBK,SAAS,CAAC,AAAC;IACjD,IAAIC,EAAE,CAACC,OAAO,KAAKF,SAAS,EAAE;QAC5BC,EAAE,CAACC,OAAO,GAAG,CAAC,EAAEL,MAAM,CAAC,CAAC,EAAEC,UAAU,CAACC,UAAU,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,OAAOE,EAAE,CAACC,OAAO,CAAC;AACpB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './time-range-params';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './time-range-params';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"time-range-params.d.ts","sourceRoot":"","sources":["../../src/utils/time-range-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,cAAc,EAAE,aAAa,UAAO,GAAG,SAAS,CA+BvG"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/time-range-params.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo, useCallback, useEffect, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from '@perses-dev/plugin-system';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n if (input == null) {\n return input;\n }\n // '' or []\n if (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== ''))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str == null) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (paramString == null) return paramString;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (valueA == null || valueB == null) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig);\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, set paramsEnabled to false to disable query string serialization\n */\nexport function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, paramsEnabled = true): TimeRange {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig);\n\n // fallback when app does not want query string as source of truth\n const [timeRangeState, setTimeRangeState] = useState<TimeRangeValue>(initialTimeRange);\n\n const { start } = query;\n\n useEffect(() => {\n if (paramsEnabled && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n }\n }\n }, [initialTimeRange, paramsEnabled, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n if (!paramsEnabled) {\n return { timeRange: timeRangeState, setTimeRange: setTimeRangeState };\n }\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","useInitialTimeRange","dashboardDuration","query","initialTimeRange","pastDuration","startStr","useSetTimeRangeParams","paramsEnabled","setQuery","timeRangeState","setTimeRangeState","undefined","setTimeRange","value","timeRange"],"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,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAClE,SAASC,cAAc,QAA0B,kBAAkB,CAAC;AACpE,SAASC,WAAW,EAAEC,MAAM,QAAQ,UAAU,CAAC;AAC/C,SAEEC,mBAAmB,EACnBC,gBAAgB,QAGX,kBAAkB,CAAC;AAK1B,iGAAiG,GACjG,SAASC,eAAe,CACtBC,KAAuD,EACvDC,gBAA0B,EACC;IAC3B,IAAID,KAAK,IAAI,IAAI,EAAE;QACjB,OAAOA,KAAK,CAAC;IACf,CAAC;IACD,WAAW;IACX,IAAIA,KAAK,CAACE,MAAM,KAAK,CAAC,IAAK,CAA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