@perses-dev/dashboards 0.45.0 → 0.46.0-rc1

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 (85) hide show
  1. package/dist/cjs/components/Dashboard/Dashboard.js +10 -1
  2. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +1 -1
  3. package/dist/cjs/components/GridLayout/GridContainer.js +15 -10
  4. package/dist/cjs/components/GridLayout/GridItemContent.js +18 -3
  5. package/dist/cjs/components/GridLayout/GridLayout.js +59 -9
  6. package/dist/cjs/components/Panel/Panel.js +3 -2
  7. package/dist/cjs/components/Panel/PanelHeader.js +24 -4
  8. package/dist/cjs/components/PanelDrawer/PanelPreview.js +6 -1
  9. package/dist/cjs/components/Variables/TemplateVariable.js +1 -1
  10. package/dist/cjs/components/Variables/VariableList.js +4 -1
  11. package/dist/cjs/constants/user-interface-text.js +2 -0
  12. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -2
  13. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +36 -0
  14. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
  15. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +6 -0
  16. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +80 -0
  17. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +2 -1
  18. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  19. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  20. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  21. package/dist/components/Dashboard/Dashboard.js +10 -1
  22. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  23. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +1 -1
  24. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  25. package/dist/components/GridLayout/GridContainer.d.ts +4 -2
  26. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  27. package/dist/components/GridLayout/GridContainer.js +15 -10
  28. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  29. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  30. package/dist/components/GridLayout/GridItemContent.js +20 -5
  31. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  32. package/dist/components/GridLayout/GridLayout.d.ts +1 -0
  33. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  34. package/dist/components/GridLayout/GridLayout.js +61 -11
  35. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  36. package/dist/components/Panel/Panel.d.ts +10 -4
  37. package/dist/components/Panel/Panel.d.ts.map +1 -1
  38. package/dist/components/Panel/Panel.js +3 -2
  39. package/dist/components/Panel/Panel.js.map +1 -1
  40. package/dist/components/Panel/PanelHeader.d.ts +5 -1
  41. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  42. package/dist/components/Panel/PanelHeader.js +24 -4
  43. package/dist/components/Panel/PanelHeader.js.map +1 -1
  44. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  45. package/dist/components/PanelDrawer/PanelPreview.js +7 -2
  46. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  47. package/dist/components/Variables/TemplateVariable.js +1 -1
  48. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  49. package/dist/components/Variables/VariableList.d.ts +1 -1
  50. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  51. package/dist/components/Variables/VariableList.js +4 -1
  52. package/dist/components/Variables/VariableList.js.map +1 -1
  53. package/dist/constants/user-interface-text.d.ts +2 -0
  54. package/dist/constants/user-interface-text.d.ts.map +1 -1
  55. package/dist/constants/user-interface-text.js +2 -0
  56. package/dist/constants/user-interface-text.js.map +1 -1
  57. package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -1
  58. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  59. package/dist/context/DashboardProvider/DashboardProvider.js +6 -3
  60. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  61. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts +3 -0
  62. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -0
  63. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +28 -0
  64. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -0
  65. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +5 -0
  66. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  67. package/dist/context/DashboardProvider/dashboard-provider-api.js +12 -4
  68. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  69. package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -0
  70. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  71. package/dist/context/DashboardProvider/panel-group-slice.js +5 -0
  72. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  73. package/dist/context/DashboardProvider/view-panel-slice.d.ts +21 -0
  74. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -0
  75. package/dist/context/DashboardProvider/view-panel-slice.js +74 -0
  76. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -0
  77. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  78. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +2 -1
  79. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  80. package/dist/views/ViewDashboard/DashboardApp.js +2 -1
  81. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  82. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  83. package/dist/views/ViewDashboard/ViewDashboard.js +3 -2
  84. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  85. package/package.json +6 -6
@@ -87,7 +87,8 @@ const DashboardApp = (props)=>{
87
87
  }),
88
88
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
89
89
  sx: {
90
- padding: (theme)=>theme.spacing(2),
90
+ paddingTop: 2,
91
+ paddingX: 2,
91
92
  height: '100%'
92
93
  },
93
94
  children: [
@@ -27,6 +27,7 @@ const _components = require("@perses-dev/components");
27
27
  const _pluginsystem = require("@perses-dev/plugin-system");
28
28
  const _react = require("react");
29
29
  const _context = require("../../context");
30
+ const _DashboardProviderWithQueryParams = require("../../context/DashboardProvider/DashboardProviderWithQueryParams");
30
31
  const _DashboardApp = require("./DashboardApp");
31
32
  function ViewDashboard(props) {
32
33
  const { dashboardResource, datasourceApi, externalVariableDefinitions, dashboardTitleComponent, emptyDashboardProps, onSave, onDiscard, initialVariableIsSticky, isReadonly, isEditing, isCreating, sx, ...others } = props;
@@ -79,7 +80,7 @@ function ViewDashboard(props) {
79
80
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.DatasourceStoreProvider, {
80
81
  dashboardResource: dashboardResource,
81
82
  datasourceApi: datasourceApi,
82
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.DashboardProvider, {
83
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardProviderWithQueryParams.DashboardProviderWithQueryParams, {
83
84
  initialState: {
84
85
  dashboardResource,
85
86
  isEditMode: !!isEditing
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,2CAmB3F"}
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAGF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,2CA2B3F"}
@@ -13,19 +13,27 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
16
+ import { useRef } from 'react';
16
17
  import { usePanelGroupIds } from '../../context';
17
18
  import { GridLayout } from '../GridLayout';
18
19
  import { EmptyDashboard } from '../EmptyDashboard';
20
+ const HEADER_HEIGHT = 165; // Approximate height of the header in dashboard view (including the navbar and variables toolbar)
19
21
  /**
20
22
  * Renders a Dashboard for the provided Dashboard spec.
21
23
  */ export function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }) {
24
+ var _boxRef_current;
22
25
  const panelGroupIds = usePanelGroupIds();
26
+ const boxRef = useRef(null);
23
27
  const isEmpty = !panelGroupIds.length;
28
+ var _boxRef_current_getBoundingClientRect_top;
29
+ const dashboardTopPosition = (_boxRef_current_getBoundingClientRect_top = (_boxRef_current = boxRef.current) === null || _boxRef_current === void 0 ? void 0 : _boxRef_current.getBoundingClientRect().top) !== null && _boxRef_current_getBoundingClientRect_top !== void 0 ? _boxRef_current_getBoundingClientRect_top : HEADER_HEIGHT;
30
+ const panelFullHeight = window.innerHeight - dashboardTopPosition - window.scrollY;
24
31
  return /*#__PURE__*/ _jsx(Box, {
25
32
  ...boxProps,
26
33
  sx: {
27
34
  height: '100%'
28
35
  },
36
+ ref: boxRef,
29
37
  children: /*#__PURE__*/ _jsxs(ErrorBoundary, {
30
38
  FallbackComponent: ErrorAlert,
31
39
  children: [
@@ -41,7 +49,8 @@ import { EmptyDashboard } from '../EmptyDashboard';
41
49
  }),
42
50
  !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
43
51
  panelGroupId: panelGroupId,
44
- panelOptions: panelOptions
52
+ panelOptions: panelOptions,
53
+ panelFullHeight: panelFullHeight
45
54
  }, panelGroupId))
46
55
  ]
47
56
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} panelOptions={panelOptions} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"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,GAAG,QAAkB,gBAAgB;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,cAAc,QAA6B,oBAAoB;AAYxE;;CAEC,GACD,OAAO,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,YAAY,EAAE,GAAGC,UAA0B;IAC1F,MAAMC,gBAAgBP;IACtB,MAAMQ,UAAU,CAACD,cAAcE,MAAM;IAErC,qBACE,KAACZ;QAAK,GAAGS,QAAQ;QAAEI,IAAI;YAAEC,QAAQ;QAAO;kBACtC,cAAA,MAACb;YAAcc,mBAAmBb;;gBAC/BS,yBACC,KAACX;oBAAIa,IAAI;wBAAEC,QAAQ;wBAAQE,SAAS;wBAAQC,YAAY;oBAAS;8BAC/D,cAAA,KAACZ;wBAAgB,GAAGE,mBAAmB;;;gBAG1C,CAACI,WACAD,cAAcQ,GAAG,CAAC,CAACC,6BACjB,KAACf;wBAA8Be,cAAcA;wBAAcX,cAAcA;uBAAxDW;;;;AAK7B"}
1
+ {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useRef } from 'react';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\nconst HEADER_HEIGHT = 165; // Approximate height of the header in dashboard view (including the navbar and variables toolbar)\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const boxRef = useRef<HTMLDivElement>(null);\n const isEmpty = !panelGroupIds.length;\n const dashboardTopPosition = boxRef.current?.getBoundingClientRect().top ?? HEADER_HEIGHT;\n const panelFullHeight = window.innerHeight - dashboardTopPosition - window.scrollY;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }} ref={boxRef}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout\n key={panelGroupId}\n panelGroupId={panelGroupId}\n panelOptions={panelOptions}\n panelFullHeight={panelFullHeight}\n />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","useRef","usePanelGroupIds","GridLayout","EmptyDashboard","HEADER_HEIGHT","Dashboard","emptyDashboardProps","panelOptions","boxProps","boxRef","panelGroupIds","isEmpty","length","dashboardTopPosition","current","getBoundingClientRect","top","panelFullHeight","window","innerHeight","scrollY","sx","height","ref","FallbackComponent","display","alignItems","map","panelGroupId"],"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,GAAG,QAAkB,gBAAgB;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAASC,MAAM,QAAQ,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,cAAc,QAA6B,oBAAoB;AAWxE,MAAMC,gBAAgB,KAAK,kGAAkG;AAE7H;;CAEC,GACD,OAAO,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,YAAY,EAAE,GAAGC,UAA0B;QAI7DC;IAH7B,MAAMC,gBAAgBT;IACtB,MAAMQ,SAAST,OAAuB;IACtC,MAAMW,UAAU,CAACD,cAAcE,MAAM;QACRH;IAA7B,MAAMI,uBAAuBJ,CAAAA,6CAAAA,kBAAAA,OAAOK,OAAO,cAAdL,sCAAAA,gBAAgBM,qBAAqB,GAAGC,GAAG,cAA3CP,uDAAAA,4CAA+CL;IAC5E,MAAMa,kBAAkBC,OAAOC,WAAW,GAAGN,uBAAuBK,OAAOE,OAAO;IAElF,qBACE,KAACvB;QAAK,GAAGW,QAAQ;QAAEa,IAAI;YAAEC,QAAQ;QAAO;QAAGC,KAAKd;kBAC9C,cAAA,MAACX;YAAc0B,mBAAmBzB;;gBAC/BY,yBACC,KAACd;oBAAIwB,IAAI;wBAAEC,QAAQ;wBAAQG,SAAS;wBAAQC,YAAY;oBAAS;8BAC/D,cAAA,KAACvB;wBAAgB,GAAGG,mBAAmB;;;gBAG1C,CAACK,WACAD,cAAciB,GAAG,CAAC,CAACC,6BACjB,KAAC1B;wBAEC0B,cAAcA;wBACdrB,cAAcA;wBACdU,iBAAiBA;uBAHZW;;;;AASnB"}
@@ -19,7 +19,7 @@ export const DeletePanelGroupDialog = ()=>{
19
19
  const panelGroupId = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupId;
20
20
  const handleDelete = (e)=>{
21
21
  e.preventDefault();
22
- if (panelGroupId == undefined) {
22
+ if (panelGroupId === undefined) {
23
23
  throw new Error('group index is undefined');
24
24
  }
25
25
  deletePanelGroup(panelGroupId);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelGroupDialog } from '../../context';\n\nexport const DeletePanelGroupDialog = () => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (panelGroupId == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent dividers sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={() => closeDeletePanelGroupDialog()}>\n Cancel\n </Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelGroupDialog","DeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","deletePanelGroup","panelGroupId","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","dividers","width","panelGroupName","variant","type","color"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,yBAAyB,QAAQ,gBAAgB;AAE1D,OAAO,MAAMC,yBAAyB;IACpC,MAAM,EAAEC,sBAAsB,EAAEC,2BAA2B,EAAEC,gBAAgB,EAAE,GAAGJ;IAElF,MAAMK,eAAeH,mCAAAA,6CAAAA,uBAAwBG,YAAY;IAEzD,MAAMC,eAAe,CAACC;QACpBA,EAAEC,cAAc;QAChB,IAAIH,gBAAgBI,WAAW;YAC7B,MAAM,IAAIC,MAAM;QAClB;QACAN,iBAAiBC;QACjBF;IACF;QAkByCD;IAhBzC,qBACE,MAACR;QAAOiB,MAAMT,2BAA2BO;;0BACvC,KAACd;0BAAY;;0BACb,KAACF;gBACCmB,cAAW;gBACXC,SAAS,IAAMV;gBACfW,IAAI,CAACC,QAAW,CAAA;wBACdC,UAAU;wBACVC,KAAKF,MAAMG,OAAO,CAAC;wBACnBC,OAAOJ,MAAMG,OAAO,CAAC;oBACvB,CAAA;0BAEA,cAAA,KAACnB;;0BAEH,MAACqB;gBAAKC,UAAUf;;kCACd,MAACV;wBAAc0B,QAAQ;wBAACR,IAAI;4BAAES,OAAO;wBAAQ;;4BAAG;4BACbrB,CAAAA,yCAAAA,mCAAAA,6CAAAA,uBAAwBsB,cAAc,cAAtCtB,oDAAAA,yCAA0C;4BAAc;;;kCAG3F,MAACL;;0CACC,KAACC;gCAAO2B,SAAQ;gCAAYC,MAAK;0CAAS;;0CAG1C,KAAC5B;gCAAO2B,SAAQ;gCAAWE,OAAM;gCAAYd,SAAS,IAAMV;0CAA+B;;;;;;;;AAOrG,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelGroupDialog } from '../../context';\n\nexport const DeletePanelGroupDialog = () => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (panelGroupId === undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent dividers sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={() => closeDeletePanelGroupDialog()}>\n Cancel\n </Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelGroupDialog","DeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","deletePanelGroup","panelGroupId","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","dividers","width","panelGroupName","variant","type","color"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,yBAAyB,QAAQ,gBAAgB;AAE1D,OAAO,MAAMC,yBAAyB;IACpC,MAAM,EAAEC,sBAAsB,EAAEC,2BAA2B,EAAEC,gBAAgB,EAAE,GAAGJ;IAElF,MAAMK,eAAeH,mCAAAA,6CAAAA,uBAAwBG,YAAY;IAEzD,MAAMC,eAAe,CAACC;QACpBA,EAAEC,cAAc;QAChB,IAAIH,iBAAiBI,WAAW;YAC9B,MAAM,IAAIC,MAAM;QAClB;QACAN,iBAAiBC;QACjBF;IACF;QAkByCD;IAhBzC,qBACE,MAACR;QAAOiB,MAAMT,2BAA2BO;;0BACvC,KAACd;0BAAY;;0BACb,KAACF;gBACCmB,cAAW;gBACXC,SAAS,IAAMV;gBACfW,IAAI,CAACC,QAAW,CAAA;wBACdC,UAAU;wBACVC,KAAKF,MAAMG,OAAO,CAAC;wBACnBC,OAAOJ,MAAMG,OAAO,CAAC;oBACvB,CAAA;0BAEA,cAAA,KAACnB;;0BAEH,MAACqB;gBAAKC,UAAUf;;kCACd,MAACV;wBAAc0B,QAAQ;wBAACR,IAAI;4BAAES,OAAO;wBAAQ;;4BAAG;4BACbrB,CAAAA,yCAAAA,mCAAAA,6CAAAA,uBAAwBsB,cAAc,cAAtCtB,oDAAAA,yCAA0C;4BAAc;;;kCAG3F,MAACL;;0CACC,KAACC;gCAAO2B,SAAQ;gCAAYC,MAAK;0CAAS;;0CAG1C,KAAC5B;gCAAO2B,SAAQ;gCAAWE,OAAM;gCAAYd,SAAS,IAAMV;0CAA+B;;;;;;;;AAOrG,EAAE"}
@@ -1,6 +1,8 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
+ import { SxProps, Theme } from '@mui/material';
2
3
  export interface GridContainerProps {
3
- children: React.ReactNode;
4
+ children: ReactNode;
5
+ sx?: SxProps<Theme>;
4
6
  }
5
7
  export declare function GridContainer(props: GridContainerProps): import("react/jsx-runtime").JSX.Element;
6
8
  //# sourceMappingURL=GridContainer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GridContainer.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridContainer.tsx"],"names":[],"mappings":";AAgBA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAsBtD"}
1
+ {"version":3,"file":"GridContainer.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridContainer.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvD,OAAO,EAAU,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAyBtD"}
@@ -23,17 +23,22 @@ export function GridContainer(props) {
23
23
  isFirstRender
24
24
  ]);
25
25
  return /*#__PURE__*/ _jsx(ReactGridLayoutContainer, {
26
- sx: {
27
- // This adds spcing between grids (rows) in the overall dashboard
28
- '& + &': {
29
- marginTop: (theme)=>theme.spacing(1)
26
+ sx: [
27
+ {
28
+ // This adds spacing between grids (rows) in the overall dashboard
29
+ '& + &': {
30
+ marginTop: 1
31
+ },
32
+ // This disables the animation of grid items when a grid is first rendered
33
+ // (see https://github.com/react-grid-layout/react-grid-layout/issues/103)
34
+ '& .react-grid-item.cssTransforms': {
35
+ transitionProperty: isFirstRender ? 'none' : 'transform'
36
+ }
30
37
  },
31
- // This disables the animation of grid items when a grid is first rendered
32
- // (see https://github.com/react-grid-layout/react-grid-layout/issues/103)
33
- '& .react-grid-item.cssTransforms': {
34
- transitionProperty: isFirstRender ? 'none' : 'transform'
35
- }
36
- },
38
+ ...Array.isArray(props.sx) ? props.sx : [
39
+ props.sx
40
+ ]
41
+ ],
37
42
  "data-testid": "panel-group",
38
43
  children: props.children
39
44
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridContainer.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, useState } from 'react';\nimport { styled } from '@mui/material';\n\nexport interface GridContainerProps {\n children: React.ReactNode;\n}\n\nexport function GridContainer(props: GridContainerProps) {\n const [isFirstRender, setIsFirstRender] = useState(true);\n useEffect(() => {\n if (isFirstRender) {\n setIsFirstRender(false);\n }\n }, [isFirstRender]);\n\n return (\n <ReactGridLayoutContainer\n sx={{\n // This adds spcing between grids (rows) in the overall dashboard\n '& + &': { marginTop: (theme) => theme.spacing(1) },\n // This disables the animation of grid items when a grid is first rendered\n // (see https://github.com/react-grid-layout/react-grid-layout/issues/103)\n '& .react-grid-item.cssTransforms': { transitionProperty: isFirstRender ? 'none' : 'transform' },\n }}\n data-testid=\"panel-group\"\n >\n {props.children}\n </ReactGridLayoutContainer>\n );\n}\n\n/**\n * These are the classes needed by react-grid-layout from their CSS stylesheet.\n */\nconst ReactGridLayoutContainer = styled('section')(({ theme }) => ({\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 ${theme.palette.text.secondary}`,\n borderBottom: `2px solid ${theme.palette.text.secondary}`,\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}));\n"],"names":["useEffect","useState","styled","GridContainer","props","isFirstRender","setIsFirstRender","ReactGridLayoutContainer","sx","marginTop","theme","spacing","transitionProperty","data-testid","children","position","transition","pointerEvents","userSelect","zIndex","willChange","visibility","background","palette","primary","main","opacity","transitionDuration","WebkitUserSelect","MozUserSelect","msUserSelect","OUserSelect","width","height","content","right","bottom","borderRight","text","secondary","borderBottom","display","left","cursor","transform","top","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;;AAEjC,SAASA,SAAS,EAAEC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QACA,+BAA+B;YAC7BD,MAAM;YACNE,WAAW;QACb;QACA,+BAA+B;YAC7BT,OAAO;YACPS,WAAW;QACb;QACA,0DAA0D;YACxDF,MAAM;YACNI,YAAY;YACZH,QAAQ;QACV;QACA,+BAA+B;YAC7BE,KAAK;YACLD,WAAW;QACb;QACA,+BAA+B;YAC7BR,QAAQ;YACRQ,WAAW;QACb;IACF,CAAA"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridContainer.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 { ReactNode, useEffect, useState } from 'react';\nimport { styled, SxProps, Theme } from '@mui/material';\n\nexport interface GridContainerProps {\n children: ReactNode;\n sx?: SxProps<Theme>;\n}\n\nexport function GridContainer(props: GridContainerProps) {\n const [isFirstRender, setIsFirstRender] = useState(true);\n useEffect(() => {\n if (isFirstRender) {\n setIsFirstRender(false);\n }\n }, [isFirstRender]);\n\n return (\n <ReactGridLayoutContainer\n sx={[\n {\n // This adds spacing between grids (rows) in the overall dashboard\n '& + &': { marginTop: 1 },\n // This disables the animation of grid items when a grid is first rendered\n // (see https://github.com/react-grid-layout/react-grid-layout/issues/103)\n '& .react-grid-item.cssTransforms': { transitionProperty: isFirstRender ? 'none' : 'transform' },\n },\n ...(Array.isArray(props.sx) ? props.sx : [props.sx]),\n ]}\n data-testid=\"panel-group\"\n >\n {props.children}\n </ReactGridLayoutContainer>\n );\n}\n\n/**\n * These are the classes needed by react-grid-layout from their CSS stylesheet.\n */\nconst ReactGridLayoutContainer = styled('section')(({ theme }) => ({\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 ${theme.palette.text.secondary}`,\n borderBottom: `2px solid ${theme.palette.text.secondary}`,\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}));\n"],"names":["useEffect","useState","styled","GridContainer","props","isFirstRender","setIsFirstRender","ReactGridLayoutContainer","sx","marginTop","transitionProperty","Array","isArray","data-testid","children","theme","position","transition","pointerEvents","userSelect","zIndex","willChange","visibility","background","palette","primary","main","opacity","transitionDuration","WebkitUserSelect","MozUserSelect","msUserSelect","OUserSelect","width","height","content","right","bottom","borderRight","text","secondary","borderBottom","display","left","cursor","transform","top","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;;AAEjC,SAAoBA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AACvD,SAASC,MAAM,QAAwB,gBAAgB;AAOvD,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,CAACC,eAAeC,iBAAiB,GAAGL,SAAS;IACnDD,UAAU;QACR,IAAIK,eAAe;YACjBC,iBAAiB;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,MAAM;YACNI,YAAY;YACZH,QAAQ;QACV;QACA,+BAA+B;YAC7BE,KAAK;YACLD,WAAW;QACb;QACA,+BAA+B;YAC7BR,QAAQ;YACRQ,WAAW;QACb;IACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAA0C,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAuD1D"}
1
+ {"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAwD,MAAM,eAAe,CAAC;AACvG,OAAO,EAAqB,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CA0E1D"}
@@ -13,9 +13,10 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { useInView } from 'react-intersection-observer';
16
- import { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';
17
- import { useEditMode, usePanel, usePanelActions } from '../../context';
18
- import { Panel } from '../Panel/Panel';
16
+ import { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';
17
+ import { useEditMode, usePanel, usePanelActions, useViewPanel } from '../../context';
18
+ import { Panel } from '../Panel';
19
+ import { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-group-slice';
19
20
  /**
20
21
  * Resolves the reference to panel content in a GridItemDefinition and renders the panel.
21
22
  */ export function GridItemContent(props) {
@@ -23,12 +24,23 @@ import { Panel } from '../Panel/Panel';
23
24
  const panelDefinition = usePanel(panelGroupItemId);
24
25
  const { spec: { queries } } = panelDefinition;
25
26
  const { isEditMode } = useEditMode();
26
- const { openEditPanel, openDeletePanelDialog, duplicatePanel } = usePanelActions(panelGroupItemId);
27
+ const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = usePanelActions(panelGroupItemId);
28
+ const viewPanelGroupItemId = useViewPanel();
27
29
  const { ref, inView } = useInView({
28
30
  threshold: 0.2,
29
31
  initialInView: false,
30
32
  triggerOnce: true
31
33
  });
34
+ const readHandlers = {
35
+ isPanelViewed: isPanelGroupItemIdEqual(viewPanelGroupItemId, panelGroupItemId),
36
+ onViewPanelClick: function() {
37
+ if (viewPanelGroupItemId === undefined) {
38
+ viewPanel(panelGroupItemId);
39
+ } else {
40
+ viewPanel(undefined);
41
+ }
42
+ }
43
+ };
32
44
  // Provide actions to the panel when in edit mode
33
45
  let editHandlers = undefined;
34
46
  if (isEditMode) {
@@ -40,6 +52,7 @@ import { Panel } from '../Panel/Panel';
40
52
  }
41
53
  // map TimeSeriesQueryDefinition to Definition<UnknownSpec>
42
54
  const suggestedStepMs = useSuggestedStepMs(width);
55
+ const { data: plugin } = usePlugin('Panel', panelDefinition.spec.plugin.kind);
43
56
  const queryDefinitions = queries !== null && queries !== void 0 ? queries : [];
44
57
  const definitions = queryDefinitions.map((query)=>{
45
58
  return {
@@ -56,13 +69,15 @@ import { Panel } from '../Panel/Panel';
56
69
  children: /*#__PURE__*/ _jsx(DataQueriesProvider, {
57
70
  definitions: definitions,
58
71
  options: {
59
- suggestedStepMs
72
+ suggestedStepMs,
73
+ ...plugin === null || plugin === void 0 ? void 0 : plugin.queryOptions
60
74
  },
61
75
  queryOptions: {
62
76
  enabled: inView
63
77
  },
64
78
  children: inView && /*#__PURE__*/ _jsx(Panel, {
65
79
  definition: panelDefinition,
80
+ readHandlers: readHandlers,
66
81
  editHandlers: editHandlers,
67
82
  panelOptions: props.panelOptions,
68
83
  panelGroupItemId: panelGroupItemId
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.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 { Box } from '@mui/material';\nimport { useInView } from 'react-intersection-observer';\nimport { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport { PanelGroupItemId, useEditMode, usePanel, usePanelActions } from '../../context';\nimport { Panel, PanelProps } from '../Panel/Panel';\nimport { PanelOptions } from '../Panel';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n panelOptions?: PanelOptions;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n const {\n spec: { queries },\n } = panelDefinition;\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel } = usePanelActions(panelGroupItemId);\n\n const { ref, inView } = useInView({\n threshold: 0.2, // we have the flexibility to adjust this threshold to trigger queries slightly earlier or later based on performance\n initialInView: false,\n triggerOnce: true,\n });\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n return (\n <Box\n ref={ref}\n sx={{\n width: '100%',\n height: '100%',\n }}\n >\n <DataQueriesProvider definitions={definitions} options={{ suggestedStepMs }} queryOptions={{ enabled: inView }}>\n {inView && (\n <Panel\n definition={panelDefinition}\n editHandlers={editHandlers}\n panelOptions={props.panelOptions}\n panelGroupItemId={panelGroupItemId}\n />\n )}\n </DataQueriesProvider>\n </Box>\n );\n}\n"],"names":["Box","useInView","DataQueriesProvider","useSuggestedStepMs","useEditMode","usePanel","usePanelActions","Panel","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","ref","inView","threshold","initialInView","triggerOnce","editHandlers","undefined","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","queryDefinitions","definitions","map","query","kind","plugin","sx","height","options","queryOptions","enabled","definition","panelOptions"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,SAAS,QAAQ,8BAA8B;AACxD,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ,4BAA4B;AACpF,SAA2BC,WAAW,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,gBAAgB;AACzF,SAASC,KAAK,QAAoB,iBAAiB;AASnD;;CAEC,GACD,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGF;IACpC,MAAMG,kBAAkBP,SAASK;IACjC,MAAM,EACJG,MAAM,EAAEC,OAAO,EAAE,EAClB,GAAGF;IACJ,MAAM,EAAEG,UAAU,EAAE,GAAGX;IACvB,MAAM,EAAEY,aAAa,EAAEC,qBAAqB,EAAEC,cAAc,EAAE,GAAGZ,gBAAgBI;IAEjF,MAAM,EAAES,GAAG,EAAEC,MAAM,EAAE,GAAGnB,UAAU;QAChCoB,WAAW;QACXC,eAAe;QACfC,aAAa;IACf;IAEA,iDAAiD;IACjD,IAAIC,eAA2CC;IAC/C,IAAIV,YAAY;QACdS,eAAe;YACbE,kBAAkBV;YAClBW,uBAAuBT;YACvBU,oBAAoBX;QACtB;IACF;IAEA,2DAA2D;IAC3D,MAAMY,kBAAkB1B,mBAAmBQ;IAC3C,MAAMmB,mBAAmBhB,oBAAAA,qBAAAA,UAAW,EAAE;IACtC,MAAMiB,cAAcD,iBAAiBE,GAAG,CAAC,CAACC;QACxC,OAAO;YACLC,MAAMD,MAAMpB,IAAI,CAACsB,MAAM,CAACD,IAAI;YAC5BrB,MAAMoB,MAAMpB,IAAI,CAACsB,MAAM,CAACtB,IAAI;QAC9B;IACF;IAEA,qBACE,KAACb;QACCmB,KAAKA;QACLiB,IAAI;YACFzB,OAAO;YACP0B,QAAQ;QACV;kBAEA,cAAA,KAACnC;YAAoB6B,aAAaA;YAAaO,SAAS;gBAAET;YAAgB;YAAGU,cAAc;gBAAEC,SAASpB;YAAO;sBAC1GA,wBACC,KAACb;gBACCkC,YAAY7B;gBACZY,cAAcA;gBACdkB,cAAcjC,MAAMiC,YAAY;gBAChChC,kBAAkBA;;;;AAM9B"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.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 { Box } from '@mui/material';\nimport { useInView } from 'react-intersection-observer';\nimport { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport { PanelGroupItemId, useEditMode, usePanel, usePanelActions, useViewPanel } from '../../context';\nimport { Panel, PanelProps, PanelOptions } from '../Panel';\nimport { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-group-slice';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n panelOptions?: PanelOptions;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n const {\n spec: { queries },\n } = panelDefinition;\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = usePanelActions(panelGroupItemId);\n const viewPanelGroupItemId = useViewPanel();\n const { ref, inView } = useInView({\n threshold: 0.2, // we have the flexibility to adjust this threshold to trigger queries slightly earlier or later based on performance\n initialInView: false,\n triggerOnce: true,\n });\n\n const readHandlers = {\n isPanelViewed: isPanelGroupItemIdEqual(viewPanelGroupItemId, panelGroupItemId),\n onViewPanelClick: function () {\n if (viewPanelGroupItemId === undefined) {\n viewPanel(panelGroupItemId);\n } else {\n viewPanel(undefined);\n }\n },\n };\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n\n const { data: plugin } = usePlugin('Panel', panelDefinition.spec.plugin.kind);\n\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n return (\n <Box\n ref={ref}\n sx={{\n width: '100%',\n height: '100%',\n }}\n >\n <DataQueriesProvider\n definitions={definitions}\n options={{ suggestedStepMs, ...plugin?.queryOptions }}\n queryOptions={{ enabled: inView }}\n >\n {inView && (\n <Panel\n definition={panelDefinition}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n panelOptions={props.panelOptions}\n panelGroupItemId={panelGroupItemId}\n />\n )}\n </DataQueriesProvider>\n </Box>\n );\n}\n"],"names":["Box","useInView","DataQueriesProvider","usePlugin","useSuggestedStepMs","useEditMode","usePanel","usePanelActions","useViewPanel","Panel","isPanelGroupItemIdEqual","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","viewPanel","viewPanelGroupItemId","ref","inView","threshold","initialInView","triggerOnce","readHandlers","isPanelViewed","onViewPanelClick","undefined","editHandlers","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","data","plugin","kind","queryDefinitions","definitions","map","query","sx","height","options","queryOptions","enabled","definition","panelOptions"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,SAAS,QAAQ,8BAA8B;AACxD,SAASC,mBAAmB,EAAEC,SAAS,EAAEC,kBAAkB,QAAQ,4BAA4B;AAC/F,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B,MAAM,CAACvB,IAAI;QAC9B;IACF;IAEA,qBACE,KAAChB;QACCwB,KAAKA;QACLqB,IAAI;YACF/B,OAAO;YACPgC,QAAQ;QACV;kBAEA,cAAA,KAAC5C;YACCwC,aAAaA;YACbK,SAAS;gBAAEV;mBAAoBE,mBAAAA,6BAAAA,OAAQS,YAAY,AAAvB;YAAwB;YACpDA,cAAc;gBAAEC,SAASxB;YAAO;sBAE/BA,wBACC,KAAChB;gBACCyC,YAAYnC;gBACZc,cAAcA;gBACdI,cAAcA;gBACdkB,cAAcvC,MAAMuC,YAAY;gBAChCtC,kBAAkBA;;;;AAM9B"}
@@ -3,6 +3,7 @@ import { PanelOptions } from '../Panel';
3
3
  export interface GridLayoutProps {
4
4
  panelGroupId: PanelGroupId;
5
5
  panelOptions?: PanelOptions;
6
+ panelFullHeight?: number;
6
7
  }
7
8
  /**
8
9
  * Layout component that arranges children in a Grid based on the definition.
@@ -1 +1 @@
1
- {"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAoD,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAOxC,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAmFhD"}
1
+ {"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAIL,YAAY,EAIb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAOxC,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAqIhD"}
@@ -11,21 +11,21 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useState } from 'react';
14
+ import { useMemo, useState } from 'react';
15
15
  import { Responsive, WidthProvider } from 'react-grid-layout';
16
16
  import { Collapse, useTheme } from '@mui/material';
17
17
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
18
- import { useEditMode, usePanelGroup, usePanelGroupActions } from '../../context';
18
+ import { useEditMode, usePanelGroup, usePanelGroupActions, useViewPanel } from '../../context';
19
19
  import { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';
20
20
  import { GridTitle } from './GridTitle';
21
21
  import { GridItemContent } from './GridItemContent';
22
22
  import { GridContainer } from './GridContainer';
23
23
  const DEFAULT_MARGIN = 10;
24
- const ResponsiveGridLayout = WidthProvider(Responsive);
24
+ const ROW_HEIGHT = 30;
25
25
  /**
26
26
  * Layout component that arranges children in a Grid based on the definition.
27
27
  */ export function GridLayout(props) {
28
- const { panelGroupId/*...others */ } = props;
28
+ const { panelGroupId, panelOptions, panelFullHeight } = props;
29
29
  const theme = useTheme();
30
30
  const groupDefinition = usePanelGroup(panelGroupId);
31
31
  const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);
@@ -33,13 +33,52 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
33
33
  const [isOpen, setIsOpen] = useState((_ref = !groupDefinition.isCollapsed) !== null && _ref !== void 0 ? _ref : true);
34
34
  const { isEditMode } = useEditMode();
35
35
  const [gridColWidth, setGridColWidth] = useState(0);
36
+ const viewPanelItemId = useViewPanel();
37
+ const hasViewPanel = (viewPanelItemId === null || viewPanelItemId === void 0 ? void 0 : viewPanelItemId.panelGroupId) === panelGroupId; // current panelGroup contains the panel extended?
38
+ const itemLayoutViewed = viewPanelItemId === null || viewPanelItemId === void 0 ? void 0 : viewPanelItemId.panelGroupItemLayoutId;
39
+ // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.
40
+ const isGridDisplayed = useMemo(()=>{
41
+ if (viewPanelItemId === undefined) {
42
+ return true;
43
+ }
44
+ if (hasViewPanel) {
45
+ setIsOpen(true);
46
+ }
47
+ return hasViewPanel;
48
+ }, [
49
+ hasViewPanel,
50
+ viewPanelItemId
51
+ ]);
52
+ // Item layout is override if there is a panel in view mode
53
+ const itemLayouts = useMemo(()=>{
54
+ if (itemLayoutViewed) {
55
+ return groupDefinition.itemLayouts.map((itemLayout)=>{
56
+ if (itemLayout.i === itemLayoutViewed) {
57
+ const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height
58
+ return {
59
+ h: Math.round(((panelFullHeight !== null && panelFullHeight !== void 0 ? panelFullHeight : window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)),
60
+ i: itemLayoutViewed,
61
+ w: 48,
62
+ x: 0,
63
+ y: 0
64
+ };
65
+ }
66
+ return itemLayout;
67
+ });
68
+ }
69
+ return groupDefinition.itemLayouts;
70
+ }, [
71
+ groupDefinition.itemLayouts,
72
+ itemLayoutViewed,
73
+ panelFullHeight
74
+ ]);
36
75
  const handleLayoutChange = (currentLayout, allLayouts)=>{
37
76
  // Using the value from `allLayouts` instead of `currentLayout` because of
38
77
  // a bug in react-layout-grid where `currentLayout` does not adjust properly
39
78
  // when going to a smaller breakpoint and then back to a larger breakpoint.
40
79
  // https://github.com/react-grid-layout/react-grid-layout/issues/1663
41
80
  const smallLayout = allLayouts[GRID_LAYOUT_SMALL_BREAKPOINT];
42
- if (smallLayout) {
81
+ if (smallLayout && !hasViewPanel) {
43
82
  updatePanelGroupLayouts(smallLayout);
44
83
  }
45
84
  };
@@ -53,7 +92,14 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
53
92
  // exclude margin and padding from total width
54
93
  setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);
55
94
  };
95
+ // https://github.com/react-grid-layout/react-grid-layout?tab=readme-ov-file#react-hooks-performance
96
+ const ResponsiveGridLayout = useMemo(()=>WidthProvider(Responsive), []);
56
97
  return /*#__PURE__*/ _jsxs(GridContainer, {
98
+ sx: {
99
+ display: isGridDisplayed ? 'block' : 'none',
100
+ height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',
101
+ overflow: itemLayoutViewed ? 'hidden' : 'unset'
102
+ },
57
103
  children: [
58
104
  groupDefinition.title !== undefined && /*#__PURE__*/ _jsx(GridTitle, {
59
105
  panelGroupId: panelGroupId,
@@ -75,13 +121,13 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
75
121
  xxs: 0
76
122
  },
77
123
  cols: GRID_LAYOUT_COLS,
78
- rowHeight: 30,
124
+ rowHeight: ROW_HEIGHT,
79
125
  draggableHandle: ".drag-handle",
80
126
  resizeHandles: [
81
127
  'se'
82
128
  ],
83
- isDraggable: isEditMode,
84
- isResizable: isEditMode,
129
+ isDraggable: isEditMode && !hasViewPanel,
130
+ isResizable: isEditMode && !hasViewPanel,
85
131
  margin: [
86
132
  DEFAULT_MARGIN,
87
133
  DEFAULT_MARGIN
@@ -91,15 +137,19 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
91
137
  10
92
138
  ],
93
139
  layouts: {
94
- [GRID_LAYOUT_SMALL_BREAKPOINT]: groupDefinition.itemLayouts
140
+ [GRID_LAYOUT_SMALL_BREAKPOINT]: itemLayouts
95
141
  },
96
142
  onLayoutChange: handleLayoutChange,
97
143
  onWidthChange: handleWidthChange,
98
- children: groupDefinition.itemLayouts.map(({ i, w })=>/*#__PURE__*/ _jsx("div", {
144
+ allowOverlap: hasViewPanel,
145
+ children: itemLayouts.map(({ i, w })=>/*#__PURE__*/ _jsx("div", {
146
+ style: {
147
+ display: itemLayoutViewed !== undefined ? itemLayoutViewed === i ? 'unset' : 'none' : 'unset'
148
+ },
99
149
  children: /*#__PURE__*/ _jsx(ErrorBoundary, {
100
150
  FallbackComponent: ErrorAlert,
101
151
  children: /*#__PURE__*/ _jsx(GridItemContent, {
102
- panelOptions: props.panelOptions,
152
+ panelOptions: panelOptions,
103
153
  panelGroupItemId: {
104
154
  panelGroupId,
105
155
  panelGroupItemLayoutId: i
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.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.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider, Layouts, Layout } from 'react-grid-layout';\nimport { Collapse, useTheme } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, PanelGroupId } from '../../context';\nimport { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { PanelOptions } from '../Panel';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\nimport { GridContainer } from './GridContainer';\nconst DEFAULT_MARGIN = 10;\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n panelOptions?: PanelOptions;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId /*...others */ } = props;\n const theme = useTheme();\n const groupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n const [gridColWidth, setGridColWidth] = useState(0);\n\n const handleLayoutChange = (currentLayout: Layout[], allLayouts: Layouts) => {\n // Using the value from `allLayouts` instead of `currentLayout` because of\n // a bug in react-layout-grid where `currentLayout` does not adjust properly\n // when going to a smaller breakpoint and then back to a larger breakpoint.\n // https://github.com/react-grid-layout/react-grid-layout/issues/1663\n const smallLayout = allLayouts[GRID_LAYOUT_SMALL_BREAKPOINT];\n if (smallLayout) {\n updatePanelGroupLayouts(smallLayout);\n }\n };\n\n /**\n * Calculate the column width so we can determine the width of each panel for suggested step ms\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\n const handleWidthChange = (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ) => {\n const marginX = margin[0];\n const marginWidth = marginX * (cols - 1);\n const containerPaddingWidth = containerPadding[0] * 2;\n // exclude margin and padding from total width\n setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);\n };\n\n return (\n <GridContainer>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false} data-testid=\"panel-group-content\">\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ sm: theme.breakpoints.values.sm, xxs: 0 }}\n cols={GRID_LAYOUT_COLS}\n rowHeight={30}\n draggableHandle=\".drag-handle\"\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n margin={[DEFAULT_MARGIN, DEFAULT_MARGIN]}\n containerPadding={[0, 10]}\n layouts={{ [GRID_LAYOUT_SMALL_BREAKPOINT]: groupDefinition.itemLayouts }}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n >\n {groupDefinition.itemLayouts.map(({ i, w }) => (\n <div key={i}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent\n panelOptions={props.panelOptions}\n panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i }}\n width={calculateGridItemWidth(w, gridColWidth)}\n />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n\n/**\n * Calculates grid item width\n * @param w number of columns the grid item spans\n * @param colWidth the width of each column in px\n * @returns grid item's width in px\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\nconst calculateGridItemWidth = (w: number, colWidth: number) => {\n // 0 * Infinity === NaN, which causes problems with resize contraints\n if (!Number.isFinite(w)) return w;\n return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);\n};\n"],"names":["useState","Responsive","WidthProvider","Collapse","useTheme","ErrorAlert","ErrorBoundary","useEditMode","usePanelGroup","usePanelGroupActions","GRID_LAYOUT_COLS","GRID_LAYOUT_SMALL_BREAKPOINT","GridTitle","GridItemContent","GridContainer","DEFAULT_MARGIN","ResponsiveGridLayout","GridLayout","props","panelGroupId","theme","groupDefinition","updatePanelGroupLayouts","isOpen","setIsOpen","isCollapsed","isEditMode","gridColWidth","setGridColWidth","handleLayoutChange","currentLayout","allLayouts","smallLayout","handleWidthChange","containerWidth","margin","cols","containerPadding","marginX","marginWidth","containerPaddingWidth","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","appear","data-testid","className","breakpoints","sm","values","xxs","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","layouts","itemLayouts","onLayoutChange","onWidthChange","map","i","w","div","FallbackComponent","panelOptions","panelGroupItemId","panelGroupItemLayoutId","width","calculateGridItemWidth","colWidth","Number","isFinite","Math","round","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,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zC,qEAAqE;IACrE,IAAI,CAACC,OAAOC,QAAQ,CAACV,IAAI,OAAOA;IAChC,OAAOW,KAAKC,KAAK,CAACJ,WAAWR,IAAIW,KAAKE,GAAG,CAAC,GAAGb,IAAI,KAAKnD;AACxD"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.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.\nimport { useMemo, useState } from 'react';\nimport { Responsive, WidthProvider, Layouts, Layout } from 'react-grid-layout';\nimport { Collapse, useTheme } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n useEditMode,\n usePanelGroup,\n usePanelGroupActions,\n PanelGroupId,\n PanelGroupItemLayout,\n useViewPanel,\n PanelGroupDefinition,\n} from '../../context';\nimport { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { PanelOptions } from '../Panel';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\nimport { GridContainer } from './GridContainer';\nconst DEFAULT_MARGIN = 10;\nconst ROW_HEIGHT = 30;\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n panelOptions?: PanelOptions;\n panelFullHeight?: number;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId, panelOptions, panelFullHeight } = props;\n const theme = useTheme();\n const groupDefinition: PanelGroupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n const [gridColWidth, setGridColWidth] = useState(0);\n\n const viewPanelItemId = useViewPanel();\n const hasViewPanel = viewPanelItemId?.panelGroupId === panelGroupId; // current panelGroup contains the panel extended?\n const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;\n\n // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.\n const isGridDisplayed = useMemo(() => {\n if (viewPanelItemId === undefined) {\n return true;\n }\n if (hasViewPanel) {\n setIsOpen(true);\n }\n return hasViewPanel;\n }, [hasViewPanel, viewPanelItemId]);\n\n // Item layout is override if there is a panel in view mode\n const itemLayouts: PanelGroupItemLayout[] = useMemo(() => {\n if (itemLayoutViewed) {\n return groupDefinition.itemLayouts.map((itemLayout) => {\n if (itemLayout.i === itemLayoutViewed) {\n const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height\n return {\n h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)), // Viewed panel should take the full height remaining\n i: itemLayoutViewed,\n w: 48,\n x: 0,\n y: 0,\n } as PanelGroupItemLayout;\n }\n return itemLayout;\n });\n }\n return groupDefinition.itemLayouts;\n }, [groupDefinition.itemLayouts, itemLayoutViewed, panelFullHeight]);\n\n const handleLayoutChange = (currentLayout: Layout[], allLayouts: Layouts) => {\n // Using the value from `allLayouts` instead of `currentLayout` because of\n // a bug in react-layout-grid where `currentLayout` does not adjust properly\n // when going to a smaller breakpoint and then back to a larger breakpoint.\n // https://github.com/react-grid-layout/react-grid-layout/issues/1663\n const smallLayout = allLayouts[GRID_LAYOUT_SMALL_BREAKPOINT];\n if (smallLayout && !hasViewPanel) {\n updatePanelGroupLayouts(smallLayout);\n }\n };\n\n /**\n * Calculate the column width so we can determine the width of each panel for suggested step ms\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\n const handleWidthChange = (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ) => {\n const marginX = margin[0];\n const marginWidth = marginX * (cols - 1);\n const containerPaddingWidth = containerPadding[0] * 2;\n // exclude margin and padding from total width\n setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);\n };\n\n // https://github.com/react-grid-layout/react-grid-layout?tab=readme-ov-file#react-hooks-performance\n const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);\n\n return (\n <GridContainer\n sx={{\n display: isGridDisplayed ? 'block' : 'none',\n height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',\n overflow: itemLayoutViewed ? 'hidden' : 'unset',\n }}\n >\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false} data-testid=\"panel-group-content\">\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ sm: theme.breakpoints.values.sm, xxs: 0 }}\n cols={GRID_LAYOUT_COLS}\n rowHeight={ROW_HEIGHT}\n draggableHandle=\".drag-handle\"\n resizeHandles={['se']}\n isDraggable={isEditMode && !hasViewPanel}\n isResizable={isEditMode && !hasViewPanel}\n margin={[DEFAULT_MARGIN, DEFAULT_MARGIN]}\n containerPadding={[0, 10]}\n layouts={{ [GRID_LAYOUT_SMALL_BREAKPOINT]: itemLayouts }}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n allowOverlap={hasViewPanel} // Enabling overlap when viewing a specific panel because panel in front of the viewed panel will add empty spaces (empty row height)\n >\n {itemLayouts.map(({ i, w }) => (\n <div\n key={i}\n style={{\n display: itemLayoutViewed !== undefined ? (itemLayoutViewed === i ? 'unset' : 'none') : 'unset',\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent\n panelOptions={panelOptions}\n panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i }}\n width={calculateGridItemWidth(w, gridColWidth)}\n />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n\n/**\n * Calculates grid item width\n * @param w number of columns the grid item spans\n * @param colWidth the width of each column in px\n * @returns grid item's width in px\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\nconst calculateGridItemWidth = (w: number, colWidth: number) => {\n // 0 * Infinity === NaN, which causes problems with resize contraints\n if (!Number.isFinite(w)) return w;\n return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);\n};\n"],"names":["useMemo","useState","Responsive","WidthProvider","Collapse","useTheme","ErrorAlert","ErrorBoundary","useEditMode","usePanelGroup","usePanelGroupActions","useViewPanel","GRID_LAYOUT_COLS","GRID_LAYOUT_SMALL_BREAKPOINT","GridTitle","GridItemContent","GridContainer","DEFAULT_MARGIN","ROW_HEIGHT","GridLayout","props","panelGroupId","panelOptions","panelFullHeight","theme","groupDefinition","updatePanelGroupLayouts","isOpen","setIsOpen","isCollapsed","isEditMode","gridColWidth","setGridColWidth","viewPanelItemId","hasViewPanel","itemLayoutViewed","panelGroupItemLayoutId","isGridDisplayed","undefined","itemLayouts","map","itemLayout","i","rowTitleHeight","h","Math","round","window","innerHeight","w","x","y","handleLayoutChange","currentLayout","allLayouts","smallLayout","handleWidthChange","containerWidth","margin","cols","containerPadding","marginX","marginWidth","containerPaddingWidth","ResponsiveGridLayout","sx","display","height","overflow","title","collapse","onToggleOpen","current","in","unmountOnExit","appear","data-testid","className","breakpoints","sm","values","xxs","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","layouts","onLayoutChange","onWidthChange","allowOverlap","div","style","FallbackComponent","panelGroupItemId","width","calculateGridItemWidth","colWidth","Number","isFinite","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AA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CW;;;;;AAkBnB;AAEA;;;;;;CAMC,GACD,MAAMsD,yBAAyB,CAAC/C,GAAWgD;IACzC,qEAAqE;IACrE,IAAI,CAACC,OAAOC,QAAQ,CAAClD,IAAI,OAAOA;IAChC,OAAOJ,KAAKC,KAAK,CAACmD,WAAWhD,IAAIJ,KAAKuD,GAAG,CAAC,GAAGnD,IAAI,KAAKhC;AACxD"}
@@ -1,20 +1,26 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { PanelDefinition } from '@perses-dev/core';
3
3
  import { CardProps } from '@mui/material';
4
4
  import { PanelGroupItemId } from '../../context';
5
5
  import { PanelHeaderProps } from './PanelHeader';
6
6
  export interface PanelProps extends CardProps<'section'> {
7
7
  definition: PanelDefinition;
8
+ readHandlers?: PanelHeaderProps['readHandlers'];
8
9
  editHandlers?: PanelHeaderProps['editHandlers'];
9
10
  panelOptions?: PanelOptions;
10
11
  panelGroupItemId?: PanelGroupItemId;
11
12
  }
12
13
  export type PanelOptions = {
13
14
  /**
14
- * Content to render in the top-right corner of the panel. It will only be
15
- * rendered when the panel is in edit mode.
15
+ * Allow you to hide the panel header if desired.
16
+ * This can be useful in embedded mode for example.
16
17
  */
17
- extra?: (props: PanelExtraProps) => React.ReactNode;
18
+ hideHeader?: boolean;
19
+ /**
20
+ * Content to render in right of the panel header. (top right of the panel)
21
+ * It will only be rendered when the panel is in edit mode.
22
+ */
23
+ extra?: (props: PanelExtraProps) => ReactNode;
18
24
  };
19
25
  export type PanelExtraProps = {
20
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAQ,SAAS,EAAe,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAe,gBAAgB,EAAE,MA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