@perses-dev/dashboards 0.8.1 → 0.10.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.
- package/dist/cjs/components/Dashboard.js +25 -14
- package/dist/cjs/components/DashboardToolbar.js +148 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +25 -19
- package/dist/cjs/components/GridLayout/GridLayout.js +92 -27
- package/dist/cjs/components/GridLayout/GridTitle.js +91 -31
- package/dist/cjs/components/GridLayout/index.js +18 -19
- package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
- package/dist/cjs/components/Panel/Panel.js +156 -55
- package/dist/cjs/components/Panel/Panel.test.js +58 -41
- package/dist/cjs/components/Panel/PanelContent.js +41 -12
- package/dist/cjs/components/Panel/index.js +16 -17
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +84 -108
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +87 -92
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +194 -0
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +121 -39
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -88
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
- package/dist/cjs/components/TimeRangeControls/index.js +16 -17
- package/dist/cjs/components/Variables/Variable.js +195 -36
- package/dist/cjs/components/Variables/VariableEditor.js +207 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
- package/dist/cjs/components/Variables/VariableList.js +81 -13
- package/dist/cjs/components/Variables/index.js +18 -18
- package/dist/cjs/components/index.js +21 -21
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +38 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
- package/dist/cjs/context/QueryStringProvider.js +69 -15
- package/dist/cjs/context/TemplateVariableProvider.js +135 -136
- package/dist/cjs/context/TimeRangeProvider.js +79 -30
- package/dist/cjs/context/index.js +20 -22
- package/dist/cjs/css/styles.js +43 -39
- package/dist/cjs/index.js +19 -20
- package/dist/cjs/test/dashboard-provider.js +51 -0
- package/dist/cjs/test/index.js +18 -18
- package/dist/cjs/test/plugin-registry.js +52 -25
- package/dist/cjs/test/render.js +25 -22
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/test/testDashboard.js +203 -107
- package/dist/cjs/utils/functions.js +9 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +49 -23
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +62 -31
- package/dist/cjs/views/ViewDashboard/index.js +16 -17
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
- package/dist/cjs/views/index.js +16 -17
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +34 -1
- package/dist/components/Dashboard.js.map +1 -0
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +154 -1
- package/dist/components/DashboardToolbar.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +35 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.d.ts +2 -3
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +102 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +99 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -0
- package/dist/components/GridLayout/index.js +16 -1
- package/dist/components/GridLayout/index.js.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.js +80 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +181 -1
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.js +74 -1
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +5 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +41 -1
- package/dist/components/Panel/PanelContent.js.map +1 -0
- package/dist/components/Panel/index.js +15 -1
- package/dist/components/Panel/index.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +96 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +99 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js +184 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.js +42 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelDrawer/index.d.ts +2 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -0
- package/dist/components/PanelDrawer/index.js +15 -0
- package/dist/components/PanelDrawer/index.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +131 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +210 -1
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableEditor.d.ts +8 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditor.js +196 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +15 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +84 -1
- package/dist/components/Variables/VariableList.js.map +1 -0
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +17 -1
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -1
- package/dist/components/index.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
- package/dist/context/DashboardProvider/common.d.ts +5 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -0
- package/dist/context/DashboardProvider/common.js +17 -0
- package/dist/context/DashboardProvider/common.js.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -0
- package/dist/context/DashboardProvider/index.js +16 -0
- package/dist/context/DashboardProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.js +196 -0
- package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +24 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +166 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/QueryStringProvider.js +40 -1
- package/dist/context/QueryStringProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider.d.ts +8 -3
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +199 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider.js +72 -1
- package/dist/context/TimeRangeProvider.js.map +1 -0
- package/dist/context/index.d.ts +3 -4
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +19 -1
- package/dist/context/index.js.map +1 -0
- package/dist/css/styles.js +186 -1
- package/dist/css/styles.js.map +1 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -0
- package/dist/test/dashboard-provider.d.ts +19 -0
- package/dist/test/dashboard-provider.d.ts.map +1 -0
- package/dist/test/dashboard-provider.js +40 -0
- package/dist/test/dashboard-provider.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +17 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +3 -4
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +74 -1
- package/dist/test/plugin-registry.js.map +1 -0
- package/dist/test/render.d.ts +1 -2
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +34 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +286 -1
- package/dist/test/testDashboard.js.map +1 -0
- package/dist/utils/functions.js +17 -1
- package/dist/utils/functions.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +55 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +79 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -1
- package/dist/views/ViewDashboard/index.js.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/dist/views/index.js +15 -1
- package/dist/views/index.js.map +1 -0
- package/package.json +13 -7
- package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
- package/dist/cjs/context/DashboardAppSlice.js +0 -45
- package/dist/cjs/context/DashboardProvider.js +0 -98
- package/dist/cjs/context/LayoutsSlice.js +0 -42
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
- package/dist/context/DashboardAppSlice.d.ts +0 -26
- package/dist/context/DashboardAppSlice.d.ts.map +0 -1
- package/dist/context/DashboardAppSlice.js +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -34
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -1
- package/dist/context/LayoutsSlice.d.ts +0 -12
- package/dist/context/LayoutsSlice.d.ts.map +0 -1
- package/dist/context/LayoutsSlice.js +0 -1
|
@@ -1 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Responsive, WidthProvider } from 'react-grid-layout';
|
|
16
|
+
import { Box, Collapse, GlobalStyles } from '@mui/material';
|
|
17
|
+
import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
18
|
+
import { styles } from '../../css/styles';
|
|
19
|
+
import { useEditMode } from '../../context';
|
|
20
|
+
import { GridTitle } from './GridTitle';
|
|
21
|
+
import { GridItemContent } from './GridItemContent';
|
|
22
|
+
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
23
|
+
/**
|
|
24
|
+
* Layout component that arranges children in a Grid based on the definition.
|
|
25
|
+
*/ export function GridLayout(props) {
|
|
26
|
+
const { groupIndex , groupDefinition , ...others } = props;
|
|
27
|
+
var ref;
|
|
28
|
+
const [isOpen, setIsOpen] = useState((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
29
|
+
const { isEditMode } = useEditMode();
|
|
30
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ _jsx(GlobalStyles, {
|
|
33
|
+
styles: styles
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
36
|
+
...others,
|
|
37
|
+
component: "section",
|
|
38
|
+
sx: {
|
|
39
|
+
'& + &': {
|
|
40
|
+
marginTop: (theme)=>theme.spacing(1)
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
children: [
|
|
44
|
+
groupDefinition.title !== undefined && /*#__PURE__*/ _jsx(GridTitle, {
|
|
45
|
+
groupIndex: groupIndex,
|
|
46
|
+
title: groupDefinition.title,
|
|
47
|
+
collapse: groupDefinition.isCollapsed === undefined ? undefined : {
|
|
48
|
+
isOpen,
|
|
49
|
+
onToggleOpen: ()=>setIsOpen((current)=>!current)
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ _jsx(Collapse, {
|
|
53
|
+
in: isOpen,
|
|
54
|
+
unmountOnExit: true,
|
|
55
|
+
children: /*#__PURE__*/ _jsx(ResponsiveGridLayout, {
|
|
56
|
+
className: "layout",
|
|
57
|
+
breakpoints: {
|
|
58
|
+
lg: 1200,
|
|
59
|
+
md: 996,
|
|
60
|
+
sm: 768,
|
|
61
|
+
xs: 480,
|
|
62
|
+
xxs: 0
|
|
63
|
+
},
|
|
64
|
+
cols: {
|
|
65
|
+
lg: 24,
|
|
66
|
+
md: 24,
|
|
67
|
+
sm: 24,
|
|
68
|
+
xs: 24,
|
|
69
|
+
xxs: 2
|
|
70
|
+
},
|
|
71
|
+
rowHeight: 30,
|
|
72
|
+
draggableHandle: '.drag-handle',
|
|
73
|
+
resizeHandles: [
|
|
74
|
+
'se'
|
|
75
|
+
],
|
|
76
|
+
isDraggable: isEditMode,
|
|
77
|
+
isResizable: isEditMode,
|
|
78
|
+
children: groupDefinition.items.map(({ x , y , width , height , content }, itemIndex)=>/*#__PURE__*/ _jsx("div", {
|
|
79
|
+
"data-grid": {
|
|
80
|
+
x,
|
|
81
|
+
y,
|
|
82
|
+
w: width,
|
|
83
|
+
h: height
|
|
84
|
+
},
|
|
85
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
86
|
+
FallbackComponent: ErrorAlert,
|
|
87
|
+
children: /*#__PURE__*/ _jsx(GridItemContent, {
|
|
88
|
+
groupIndex: groupIndex,
|
|
89
|
+
itemIndex: itemIndex,
|
|
90
|
+
content: content
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}, itemIndex))
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=GridLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridLayout.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.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider } from 'react-grid-layout';\nimport { Box, BoxProps, Collapse, GlobalStyles } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { styles } from '../../css/styles';\nimport { useEditMode } from '../../context';\nimport { PanelGroupDefinition } from '../../context/DashboardProvider/layout-slice';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps extends BoxProps {\n groupIndex: number;\n groupDefinition: PanelGroupDefinition;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { groupIndex, groupDefinition, ...others } = props;\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n return (\n <>\n <GlobalStyles styles={styles} />\n <Box {...others} component=\"section\" sx={{ '& + &': { marginTop: (theme) => theme.spacing(1) } }}>\n {groupDefinition.title !== undefined && (\n <GridTitle\n groupIndex={groupIndex}\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>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}\n cols={{ lg: 24, md: 24, sm: 24, xs: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n >\n {groupDefinition.items.map(({ x, y, width, height, content }, itemIndex) => (\n <div key={itemIndex} data-grid={{ x, y, w: width, h: height }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent groupIndex={groupIndex} itemIndex={itemIndex} content={content} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </Box>\n </>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Box","Collapse","GlobalStyles","ErrorAlert","ErrorBoundary","styles","useEditMode","GridTitle","GridItemContent","ResponsiveGridLayout","GridLayout","props","groupIndex","groupDefinition","others","isOpen","setIsOpen","isCollapsed","isEditMode","component","sx","marginTop","theme","spacing","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","className","breakpoints","lg","md","sm","xs","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","items","map","x","y","width","height","content","itemIndex","div","data-grid","w","h","FallbackComponent"],"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;AACjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,UAAU,EAAEC,aAAa,QAAQ,mBAAmB,CAAC;AAC9D,SAASC,GAAG,EAAYC,QAAQ,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACtE,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,MAAM,QAAQ,kBAAkB,CAAC;AAC1C,SAASC,WAAW,QAAQ,eAAe,CAAC;AAE5C,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AAEpD,MAAMC,oBAAoB,GAAGV,aAAa,CAACD,UAAU,CAAC,AAAC;AAOvD;;CAEC,GACD,OAAO,SAASY,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGH,KAAK,AAAC;QAEpB,GAA4B;IAAjE,MAAM,CAACI,MAAM,EAAEC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AE,EAAE;4BACbC,eAAe,EAAE,cAAc;4BAC/BC,aAAa,EAAE;gCAAC,IAAI;6BAAC;4BACrBC,WAAW,EAAExB,UAAU;4BACvByB,WAAW,EAAEzB,UAAU;sCAEtBL,eAAe,CAAC+B,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAEC,CAAC,CAAA,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAE,EAAEC,SAAS,iBACrE,KAACC,KAAG;oCAAiBC,WAAS,EAAE;wCAAEP,CAAC;wCAAEC,CAAC;wCAAEO,CAAC,EAAEN,KAAK;wCAAEO,CAAC,EAAEN,MAAM;qCAAE;8CAC3D,cAAA,KAAC7C,aAAa;wCAACoD,iBAAiB,EAAErD,UAAU;kDAC1C,cAAA,KAACK,eAAe;4CAACI,UAAU,EAAEA,UAAU;4CAAEuC,SAAS,EAAEA,SAAS;4CAAED,OAAO,EAAEA,OAAO;0CAAI;sCACrE;mCAHRC,SAAS,CAIb,AACP,CAAC;0BACmB;sBACd;;cACP;;MACL,CACH;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";AAyBA,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,MAAM,IAAI,CAAC;KAC1B,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAmE9C"}
|
|
@@ -1 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Box, IconButton, Stack, Typography } from '@mui/material';
|
|
16
|
+
import ExpandedIcon from 'mdi-material-ui/ChevronUp';
|
|
17
|
+
import CollapsedIcon from 'mdi-material-ui/ChevronDown';
|
|
18
|
+
import AddIcon from 'mdi-material-ui/Plus';
|
|
19
|
+
import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
20
|
+
import ArrowUpIcon from 'mdi-material-ui/ArrowUp';
|
|
21
|
+
import ArrowDownIcon from 'mdi-material-ui/ArrowDown';
|
|
22
|
+
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
23
|
+
import { usePanelGroupDialog, useEditMode, useLayouts, usePanels } from '../../context';
|
|
24
|
+
/**
|
|
25
|
+
* Renders the title for a Grid section, optionally also supporting expanding
|
|
26
|
+
* and collapsing
|
|
27
|
+
*/ export function GridTitle(props) {
|
|
28
|
+
const { groupIndex , title , collapse } = props;
|
|
29
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
30
|
+
const { openPanelGroupDialog , openDeletePanelGroupDialog } = usePanelGroupDialog();
|
|
31
|
+
const { addPanel } = usePanels();
|
|
32
|
+
const { isEditMode } = useEditMode();
|
|
33
|
+
const { layouts , swapPanelGroups } = useLayouts();
|
|
34
|
+
const text = /*#__PURE__*/ _jsx(Typography, {
|
|
35
|
+
variant: "h2",
|
|
36
|
+
sx: {
|
|
37
|
+
marginLeft: collapse !== undefined ? 1 : undefined
|
|
38
|
+
},
|
|
39
|
+
children: title
|
|
40
|
+
});
|
|
41
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
42
|
+
sx: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
justifyContent: 'start',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
padding: (theme)=>theme.spacing(1),
|
|
47
|
+
backgroundColor: (theme)=>theme.palette.background.default
|
|
48
|
+
},
|
|
49
|
+
onMouseEnter: ()=>setIsHovered(true),
|
|
50
|
+
onMouseLeave: ()=>setIsHovered(false),
|
|
51
|
+
children: collapse ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
54
|
+
onClick: collapse.onToggleOpen,
|
|
55
|
+
children: collapse.isOpen ? /*#__PURE__*/ _jsx(ExpandedIcon, {}) : /*#__PURE__*/ _jsx(CollapsedIcon, {})
|
|
56
|
+
}),
|
|
57
|
+
text,
|
|
58
|
+
isEditMode && isHovered && /*#__PURE__*/ _jsxs(Stack, {
|
|
59
|
+
direction: "row",
|
|
60
|
+
sx: {
|
|
61
|
+
marginLeft: 'auto'
|
|
62
|
+
},
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
65
|
+
"aria-label": "add panel to group",
|
|
66
|
+
onClick: ()=>addPanel(groupIndex),
|
|
67
|
+
children: /*#__PURE__*/ _jsx(AddIcon, {})
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
70
|
+
"aria-label": "edit group",
|
|
71
|
+
onClick: ()=>openPanelGroupDialog(groupIndex),
|
|
72
|
+
children: /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
75
|
+
"aria-label": "delete group",
|
|
76
|
+
onClick: ()=>openDeletePanelGroupDialog(groupIndex),
|
|
77
|
+
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
80
|
+
"aria-label": "move group down",
|
|
81
|
+
disabled: groupIndex === layouts.length - 1,
|
|
82
|
+
onClick: ()=>swapPanelGroups(groupIndex, groupIndex + 1),
|
|
83
|
+
children: /*#__PURE__*/ _jsx(ArrowDownIcon, {})
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
86
|
+
"aria-label": "move group up",
|
|
87
|
+
disabled: groupIndex === 0,
|
|
88
|
+
onClick: ()=>swapPanelGroups(groupIndex, groupIndex - 1),
|
|
89
|
+
children: /*#__PURE__*/ _jsx(ArrowUpIcon, {})
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
}) : // If we don't need expand/collapse, just render the title text
|
|
95
|
+
text
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=GridTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridTitle.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 { useState } from 'react';\nimport { Box, IconButton, Stack, Typography } from '@mui/material';\nimport ExpandedIcon from 'mdi-material-ui/ChevronUp';\nimport CollapsedIcon from 'mdi-material-ui/ChevronDown';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport ArrowUpIcon from 'mdi-material-ui/ArrowUp';\nimport ArrowDownIcon from 'mdi-material-ui/ArrowDown';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\n\nimport { usePanelGroupDialog, useEditMode, useLayouts, usePanels } from '../../context';\n\nexport interface GridTitleProps {\n groupIndex: number;\n title: string;\n collapse?: {\n isOpen: boolean;\n onToggleOpen: () => void;\n };\n}\n\n/**\n * Renders the title for a Grid section, optionally also supporting expanding\n * and collapsing\n */\nexport function GridTitle(props: GridTitleProps) {\n const { groupIndex, title, collapse } = props;\n\n const [isHovered, setIsHovered] = useState(false);\n const { openPanelGroupDialog, openDeletePanelGroupDialog } = usePanelGroupDialog();\n const { addPanel } = usePanels();\n const { isEditMode } = useEditMode();\n const { layouts, swapPanelGroups } = useLayouts();\n\n const text = (\n <Typography variant=\"h2\" sx={{ marginLeft: collapse !== undefined ? 1 : undefined }}>\n {title}\n </Typography>\n );\n\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1),\n backgroundColor: (theme) => theme.palette.background.default,\n }}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {collapse ? (\n <>\n <IconButton onClick={collapse.onToggleOpen}>\n {collapse.isOpen ? <ExpandedIcon /> : <CollapsedIcon />}\n </IconButton>\n {text}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" sx={{ marginLeft: 'auto' }}>\n <IconButton aria-label=\"add panel to group\" onClick={() => addPanel(groupIndex)}>\n <AddIcon />\n </IconButton>\n <IconButton aria-label=\"edit group\" onClick={() => openPanelGroupDialog(groupIndex)}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete group\" onClick={() => openDeletePanelGroupDialog(groupIndex)}>\n <DeleteIcon />\n </IconButton>\n <IconButton\n aria-label=\"move group down\"\n disabled={groupIndex === layouts.length - 1}\n onClick={() => swapPanelGroups(groupIndex, groupIndex + 1)}\n >\n <ArrowDownIcon />\n </IconButton>\n <IconButton\n aria-label=\"move group up\"\n disabled={groupIndex === 0}\n onClick={() => swapPanelGroups(groupIndex, groupIndex - 1)}\n >\n <ArrowUpIcon />\n </IconButton>\n </Stack>\n )}\n </>\n ) : (\n // If we don't need expand/collapse, just render the title text\n text\n )}\n </Box>\n );\n}\n"],"names":["useState","Box","IconButton","Stack","Typography","ExpandedIcon","CollapsedIcon","AddIcon","PencilIcon","ArrowUpIcon","ArrowDownIcon","DeleteIcon","usePanelGroupDialog","useEditMode","useLayouts","usePanels","GridTitle","props","groupIndex","title","collapse","isHovered","setIsHovered","openPanelGroupDialog","openDeletePanelGroupDialog","addPanel","isEditMode","layouts","swapPanelGroups","text","variant","sx","marginLeft","undefined","display","justifyContent","alignItems","padding","theme","spacing","backgroundColor","palette","background","default","onMouseEnter","onMouseLeave","onClick","onToggleOpen","isOpen","direction","aria-label","disabled","length"],"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,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACnE,OAAOC,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAOC,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAOC,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAOC,aAAa,MAAM,2BAA2B,CAAC;AACtD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AAEvD,SAASC,mBAAm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
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './GridLayout';
|
|
14
|
+
export * from './GridItemContent';
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/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 './GridLayout';\nexport * from './GridItemContent';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeletePanelDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/DeletePanelDialog.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,QAAA,MAAM,iBAAiB,mBAoBtB,CAAC;AA+BF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
|
|
15
|
+
import CloseIcon from 'mdi-material-ui/Close';
|
|
16
|
+
import { usePanels, useLayouts } from '../../context';
|
|
17
|
+
const DeletePanelDialog = ()=>{
|
|
18
|
+
const { deletePanelDialog , closeDeletePanelDialog } = usePanels();
|
|
19
|
+
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
20
|
+
open: deletePanelDialog !== undefined,
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
23
|
+
children: "Delete Panel"
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
26
|
+
"aria-label": "Close",
|
|
27
|
+
onClick: ()=>closeDeletePanelDialog(),
|
|
28
|
+
sx: (theme)=>({
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: theme.spacing(0.5),
|
|
31
|
+
right: theme.spacing(0.5)
|
|
32
|
+
}),
|
|
33
|
+
children: /*#__PURE__*/ _jsx(CloseIcon, {})
|
|
34
|
+
}),
|
|
35
|
+
deletePanelDialog && /*#__PURE__*/ _jsx(DeletePanelForm, {
|
|
36
|
+
deletePanelDialog: deletePanelDialog
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const DeletePanelForm = ({ deletePanelDialog })=>{
|
|
42
|
+
var ref;
|
|
43
|
+
const { layouts } = useLayouts();
|
|
44
|
+
const { deletePanels , closeDeletePanelDialog } = usePanels();
|
|
45
|
+
const handleDelete = (e)=>{
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
const { layoutItem } = deletePanelDialog;
|
|
48
|
+
deletePanels([
|
|
49
|
+
layoutItem
|
|
50
|
+
]);
|
|
51
|
+
closeDeletePanelDialog();
|
|
52
|
+
};
|
|
53
|
+
return /*#__PURE__*/ _jsxs("form", {
|
|
54
|
+
onSubmit: handleDelete,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
57
|
+
sx: {
|
|
58
|
+
width: '500px'
|
|
59
|
+
},
|
|
60
|
+
children: `Are you sure you want to delete ${deletePanelDialog.panelName} from ${(ref = layouts[deletePanelDialog.layoutItem.groupIndex]) === null || ref === void 0 ? void 0 : ref.title}? This action cannot be undone.`
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
65
|
+
variant: "contained",
|
|
66
|
+
type: "submit",
|
|
67
|
+
children: "Delete"
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
70
|
+
onClick: ()=>closeDeletePanelDialog(),
|
|
71
|
+
children: "Cancel"
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export default DeletePanelDialog;
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=DeletePanelDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/DeletePanelDialog.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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { usePanels, useLayouts } from '../../context';\nimport { DeletePanelDialog } from '../../context/DashboardProvider/panel-editing-slice';\n\nconst DeletePanelDialog = () => {\n const { deletePanelDialog, closeDeletePanelDialog } = usePanels();\n\n return (\n <Dialog open={deletePanelDialog !== undefined}>\n <DialogTitle>Delete Panel</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelDialog()}\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 {deletePanelDialog && <DeletePanelForm deletePanelDialog={deletePanelDialog} />}\n </Dialog>\n );\n};\n\ninterface DeletePanelFormProps {\n deletePanelDialog: DeletePanelDialog;\n}\n\nconst DeletePanelForm = ({ deletePanelDialog }: DeletePanelFormProps) => {\n const { layouts } = useLayouts();\n const { deletePanels, closeDeletePanelDialog } = usePanels();\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n const { layoutItem } = deletePanelDialog;\n deletePanels([layoutItem]);\n closeDeletePanelDialog();\n };\n return (\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>{`Are you sure you want to delete ${deletePanelDialog.panelName} from ${\n layouts[deletePanelDialog.layoutItem.groupIndex]?.title\n }? This action cannot be undone.`}</DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n );\n};\n\nexport default DeletePanelDialog;\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","usePanels","useLayouts","DeletePanelDialog","deletePanelDialog","closeDeletePanelDialog","open","undefined","aria-label","onClick","sx","theme","position","top","spacing","right","DeletePanelForm","layouts","deletePanels","handleDelete","e","preventDefault","layoutItem","form","onSubmit","width","panelName","groupIndex","title","variant","type"],"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;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,SAAS,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAGtD,MAAMC,iBAAiB,GAAG,IAAM;IAC9B,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,sBAAsB,CAAA,EAAE,GAAGJ,SAAS,EAAE,AAAC;IAElE,qBACE,MAACN,MAAM;QAACW,IAAI,EAAEF,iBAAiB,KAAKG,SAAS;;0BAC3C,KAACX,WAAW;0BAAC,cAAY;cAAc;0BACvC,KAACF,UAAU;gBACTc,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;gBACvCK,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QA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Q;kCAAC,QAE1C;sBAAS;kCACT,KAAC/B,MAAM;wBAACU,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;kCAAE,QAAM;sBAAS;;cAClD;;MACX,CACP;AACJ,CAAC,AAAC;AAEF,eAAeF,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAGL,SAAS,EAOV,MAAM,eAAe,CAAC;AAQvB,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eAwItC"}
|
|
@@ -1 +1,181 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useState, useMemo } from 'react';
|
|
15
|
+
import useResizeObserver from 'use-resize-observer';
|
|
16
|
+
import { useInView } from 'react-intersection-observer';
|
|
17
|
+
import { ErrorBoundary, ErrorAlert, InfoTooltip, TooltipPlacement } from '@perses-dev/components';
|
|
18
|
+
import { Box, Card, CardHeader, CardContent, Typography, IconButton as MuiIconButton, Stack, styled } from '@mui/material';
|
|
19
|
+
import InformationOutlineIcon from 'mdi-material-ui/InformationOutline';
|
|
20
|
+
import PencilIcon from 'mdi-material-ui/Pencil';
|
|
21
|
+
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
22
|
+
import DragIcon from 'mdi-material-ui/DragVertical';
|
|
23
|
+
import { usePanels, useEditMode } from '../../context';
|
|
24
|
+
import { PanelContent } from './PanelContent';
|
|
25
|
+
/**
|
|
26
|
+
* Renders a PanelDefinition's content inside of a Card.
|
|
27
|
+
*/ export function Panel(props) {
|
|
28
|
+
const { definition , groupIndex , itemIndex , ...others } = props;
|
|
29
|
+
const [contentElement, setContentElement] = useState(null);
|
|
30
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
31
|
+
const { width , height } = useResizeObserver({
|
|
32
|
+
ref: contentElement
|
|
33
|
+
});
|
|
34
|
+
const contentDimensions = useMemo(()=>{
|
|
35
|
+
if (width === undefined || height === undefined) return undefined;
|
|
36
|
+
return {
|
|
37
|
+
width,
|
|
38
|
+
height
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
width,
|
|
42
|
+
height
|
|
43
|
+
]);
|
|
44
|
+
const { ref , inView } = useInView({
|
|
45
|
+
threshold: 0.3,
|
|
46
|
+
initialInView: false,
|
|
47
|
+
triggerOnce: true
|
|
48
|
+
});
|
|
49
|
+
// TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
|
|
50
|
+
const panelPadding = 1.5;
|
|
51
|
+
const { isEditMode } = useEditMode();
|
|
52
|
+
const { editPanel , openDeletePanelDialog } = usePanels();
|
|
53
|
+
const handleEditButtonClick = ()=>{
|
|
54
|
+
editPanel({
|
|
55
|
+
groupIndex,
|
|
56
|
+
itemIndex
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return /*#__PURE__*/ _jsxs(Card, {
|
|
60
|
+
ref: ref,
|
|
61
|
+
sx: {
|
|
62
|
+
...others.sx,
|
|
63
|
+
width: '100%',
|
|
64
|
+
height: '100%',
|
|
65
|
+
display: 'flex',
|
|
66
|
+
flexFlow: 'column nowrap'
|
|
67
|
+
},
|
|
68
|
+
variant: "outlined",
|
|
69
|
+
...others,
|
|
70
|
+
onMouseEnter: ()=>setIsHovered(true),
|
|
71
|
+
onMouseLeave: ()=>setIsHovered(false),
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ _jsx(CardHeader, {
|
|
74
|
+
title: /*#__PURE__*/ _jsxs(Box, {
|
|
75
|
+
sx: {
|
|
76
|
+
display: 'flex',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
minHeight: '24px'
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
82
|
+
component: "h2",
|
|
83
|
+
variant: "body2",
|
|
84
|
+
fontWeight: (theme)=>theme.typography.fontWeightMedium,
|
|
85
|
+
whiteSpace: "nowrap",
|
|
86
|
+
overflow: "hidden",
|
|
87
|
+
textOverflow: "ellipsis",
|
|
88
|
+
children: definition.spec.display.name
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
91
|
+
sx: {
|
|
92
|
+
display: 'flex',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
marginLeft: 'auto'
|
|
95
|
+
},
|
|
96
|
+
children: [
|
|
97
|
+
!isEditMode && isHovered && definition.spec.display.description && /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
98
|
+
id: "info-tooltip",
|
|
99
|
+
description: definition.spec.display.description,
|
|
100
|
+
placement: TooltipPlacement.Bottom,
|
|
101
|
+
children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
|
|
102
|
+
"aria-describedby": "info-tooltip",
|
|
103
|
+
"aria-hidden": false,
|
|
104
|
+
fontSize: "small",
|
|
105
|
+
sx: {
|
|
106
|
+
cursor: 'pointer'
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
isEditMode && isHovered && /*#__PURE__*/ _jsxs(Stack, {
|
|
111
|
+
direction: "row",
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
spacing: 0.5,
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
116
|
+
"aria-label": "edit panel",
|
|
117
|
+
size: "small",
|
|
118
|
+
onClick: handleEditButtonClick,
|
|
119
|
+
children: /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
122
|
+
"aria-label": "delete panel",
|
|
123
|
+
size: "small",
|
|
124
|
+
onClick: ()=>openDeletePanelDialog({
|
|
125
|
+
groupIndex,
|
|
126
|
+
itemIndex
|
|
127
|
+
}),
|
|
128
|
+
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
131
|
+
"aria-label": "drag handle",
|
|
132
|
+
size: "small",
|
|
133
|
+
children: /*#__PURE__*/ _jsx(DragIcon, {
|
|
134
|
+
className: "drag-handle",
|
|
135
|
+
sx: {
|
|
136
|
+
cursor: 'grab'
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
}),
|
|
146
|
+
sx: {
|
|
147
|
+
display: 'block',
|
|
148
|
+
padding: (theme)=>theme.spacing(1, panelPadding),
|
|
149
|
+
borderBottom: (theme)=>`solid 1px ${theme.palette.divider}`
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
/*#__PURE__*/ _jsx(CardContent, {
|
|
153
|
+
sx: {
|
|
154
|
+
position: 'relative',
|
|
155
|
+
overflow: 'hidden',
|
|
156
|
+
flexGrow: 1,
|
|
157
|
+
padding: (theme)=>theme.spacing(panelPadding),
|
|
158
|
+
// Override MUI default style for last-child
|
|
159
|
+
':last-child': {
|
|
160
|
+
padding: (theme)=>theme.spacing(panelPadding)
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
ref: setContentElement,
|
|
164
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
165
|
+
FallbackComponent: ErrorAlert,
|
|
166
|
+
children: inView === true && /*#__PURE__*/ _jsx(PanelContent, {
|
|
167
|
+
panelPluginKind: definition.spec.plugin.kind,
|
|
168
|
+
spec: definition.spec.plugin.spec,
|
|
169
|
+
contentDimensions: contentDimensions
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const IconButton = styled(MuiIconButton)(({ theme })=>({
|
|
177
|
+
borderRadius: theme.shape.borderRadius,
|
|
178
|
+
padding: '4px'
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=Panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/Panel.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 { useState, useMemo } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { useInView } from 'react-intersection-observer';\nimport { ErrorBoundary, ErrorAlert, InfoTooltip, TooltipPlacement } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport {\n Box,\n Card,\n CardProps,\n CardHeader,\n CardContent,\n Typography,\n IconButton as MuiIconButton,\n Stack,\n styled,\n} from '@mui/material';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\nimport { usePanels, useEditMode } from '../../context';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps {\n definition: PanelDefinition;\n groupIndex: number;\n itemIndex: number;\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, groupIndex, itemIndex, ...others } = props;\n\n const [contentElement, setContentElement] = useState<HTMLDivElement | null>(null);\n const [isHovered, setIsHovered] = useState(false);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const { ref, inView } = useInView({\n threshold: 0.3,\n initialInView: false,\n triggerOnce: true,\n });\n\n // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart\n const panelPadding = 1.5;\n\n const { isEditMode } = useEditMode();\n\n const { editPanel, openDeletePanelDialog } = usePanels();\n\n const handleEditButtonClick = () => {\n editPanel({ groupIndex, itemIndex });\n };\n\n return (\n <Card\n ref={ref}\n sx={{\n ...others.sx,\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n }}\n variant=\"outlined\"\n {...others}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <CardHeader\n title={\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n minHeight: '24px',\n }}\n >\n <Typography\n component=\"h2\"\n variant=\"body2\"\n fontWeight={(theme) => theme.typography.fontWeightMedium}\n whiteSpace=\"nowrap\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n >\n {definition.spec.display.name}\n </Typography>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n marginLeft: 'auto',\n }}\n >\n {!isEditMode && isHovered && definition.spec.display.description && (\n <InfoTooltip\n id=\"info-tooltip\"\n description={definition.spec.display.description}\n placement={TooltipPlacement.Bottom}\n >\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"small\"\n sx={{ cursor: 'pointer' }}\n />\n </InfoTooltip>\n )}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <IconButton aria-label=\"edit panel\" size=\"small\" onClick={handleEditButtonClick}>\n <PencilIcon />\n </IconButton>\n <IconButton\n aria-label=\"delete panel\"\n size=\"small\"\n onClick={() => openDeletePanelDialog({ groupIndex, itemIndex })}\n >\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </IconButton>\n </Stack>\n )}\n </Box>\n </Box>\n }\n sx={{\n display: 'block',\n padding: (theme) => theme.spacing(1, panelPadding),\n borderBottom: (theme) => `solid 1px ${theme.palette.divider}`,\n }}\n />\n <CardContent\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n padding: (theme) => theme.spacing(panelPadding),\n // Override MUI default style for last-child\n ':last-child': {\n padding: (theme) => theme.spacing(panelPadding),\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {inView === true && (\n <PanelContent\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n />\n )}\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n}\n\nconst IconButton = styled(MuiIconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","InfoTooltip","TooltipPlacement","Box","Card","CardHeader","CardContent","Typography","IconButton","MuiIconButton","Stack","styled","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","usePanels","useEditMode","PanelContent","Panel","props","definition","groupIndex","itemIndex","others","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","isEditMode","editPanel","openDeletePanelDialog","handleEditButtonClick","sx","display","flexFlow","variant","onMouseEnter","onMouseLeave","title","alignItems","minHeight","component","fontWeight","theme","typography","fontWeightMedium","whiteSpace","overflow","textOverflow","spec","name","marginLeft","description","id","placement","Bottom","aria-describedby","aria-hidden","fontSize","cursor","direction","spacing","aria-label","size","onClick","className","padding","borderBottom","palette","divider","position","flexGrow","FallbackComponent","panelPluginKind","plugin","kind","borderRadius","shape"],"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,QAAQ,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC1C,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,SAASC,SAAS,QAAQ,6BAA6B,CAAC;AACxD,SAASC,aAAa,EAAEC,UAAU,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,wBAAwB,CAAC;AAElG,SACEC,GAAG,EACHC,IAAI,EAEJC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,UAAU,IAAIC,aAAa,EAC3BC,KAAK,EACLC,MAAM,QACD,eAAe,CAAC;AACvB,OAAOC,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAOC,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,QAAQ,MAAM,8BAA8B,CAAC;AACpD,SAASC,SAAS,EAAEC,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