@perses-dev/dashboards 0.13.0 → 0.15.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/DashboardToolbar/DashboardToolbar.js +13 -14
- package/dist/cjs/{css/styles.js → components/GridLayout/GridContainer.js} +66 -39
- package/dist/cjs/components/GridLayout/GridLayout.js +51 -64
- package/dist/cjs/components/GridLayout/GridTitle.js +3 -2
- package/dist/cjs/components/Panel/PanelHeader.js +6 -6
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -2
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +7 -5
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +15 -54
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +25 -11
- package/dist/cjs/components/Variables/Variable.js +11 -4
- package/dist/cjs/components/Variables/VariableEditor.js +1 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -2
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
- package/dist/cjs/components/Variables/VariableList.js +76 -17
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -1
- package/dist/cjs/context/DashboardProvider/common.js +3 -3
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +68 -39
- package/dist/cjs/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
- package/dist/cjs/{utils → context/TimeRangeProvider}/index.js +2 -1
- package/dist/cjs/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +11 -5
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/test/render.js +0 -1
- package/dist/cjs/test/testDashboard.js +1 -1
- package/dist/cjs/utils/component-ids.js +3 -3
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +3 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +7 -7
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +13 -14
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.d.ts +6 -0
- package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
- package/dist/{css/styles.js → components/GridLayout/GridContainer.js} +65 -38
- package/dist/components/GridLayout/GridContainer.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.d.ts +1 -2
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +53 -66
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +4 -3
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +6 -6
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +1 -2
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +8 -6
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -58
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +25 -11
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.js +11 -4
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +1 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +5 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +38 -18
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +4 -4
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +70 -41
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/{TimeRangeProvider.d.ts → TimeRangeProvider/TimeRangeProvider.d.ts} +2 -2
- package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
- package/dist/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
- package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider/index.d.ts +3 -0
- package/dist/context/TimeRangeProvider/index.d.ts.map +1 -0
- package/dist/{utils → context/TimeRangeProvider}/index.js +2 -1
- package/dist/context/TimeRangeProvider/index.js.map +1 -0
- package/dist/{utils/time-range-params.d.ts → context/TimeRangeProvider/query-params.d.ts} +3 -3
- package/dist/context/TimeRangeProvider/query-params.d.ts.map +1 -0
- package/dist/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +13 -7
- package/dist/context/TimeRangeProvider/query-params.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/test/render.js +0 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.js +1 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/component-ids.d.ts.map +1 -1
- package/dist/utils/component-ids.js +3 -3
- package/dist/utils/component-ids.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +3 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- 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 +7 -7
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +5 -4
- package/dist/context/TimeRangeProvider.d.ts.map +0 -1
- package/dist/context/TimeRangeProvider.js.map +0 -1
- package/dist/css/styles.d.ts +0 -172
- package/dist/css/styles.d.ts.map +0 -1
- package/dist/css/styles.js.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/time-range-params.d.ts.map +0 -1
- package/dist/utils/time-range-params.js.map +0 -1
|
@@ -22,15 +22,13 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _components = require("@perses-dev/components");
|
|
24
24
|
const _context = require("../../context");
|
|
25
|
-
const _utils = require("../../utils");
|
|
26
25
|
const _dashboardApp = require("./DashboardApp");
|
|
27
26
|
function ViewDashboard(props) {
|
|
28
|
-
const { dashboardResource , datasourceApi , sx , ...others } = props;
|
|
27
|
+
const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , sx , ...others } = props;
|
|
29
28
|
const { spec } = dashboardResource;
|
|
30
29
|
var _duration;
|
|
31
30
|
const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
|
|
32
|
-
const initialTimeRange = (0,
|
|
33
|
-
const { timeRange , setTimeRange } = (0, _utils.useSetTimeRangeParams)(initialTimeRange, true);
|
|
31
|
+
const initialTimeRange = (0, _context.useInitialTimeRange)(dashboardDuration);
|
|
34
32
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DatasourceStoreProvider, {
|
|
35
33
|
dashboardResource: dashboardResource,
|
|
36
34
|
datasourceApi: datasourceApi,
|
|
@@ -39,8 +37,8 @@ function ViewDashboard(props) {
|
|
|
39
37
|
dashboardResource
|
|
40
38
|
},
|
|
41
39
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TimeRangeProvider, {
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
initialTimeRange: initialTimeRange,
|
|
41
|
+
enabledURLParams: true,
|
|
44
42
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TemplateVariableProvider, {
|
|
45
43
|
initialVariableDefinitions: spec.variables,
|
|
46
44
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -55,7 +53,9 @@ function ViewDashboard(props) {
|
|
|
55
53
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
56
54
|
FallbackComponent: _components.ErrorAlert,
|
|
57
55
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
|
|
58
|
-
dashboardResource: dashboardResource
|
|
56
|
+
dashboardResource: dashboardResource,
|
|
57
|
+
dashboardTitleComponent: dashboardTitleComponent,
|
|
58
|
+
initialVariableIsSticky: initialVariableIsSticky
|
|
59
59
|
})
|
|
60
60
|
})
|
|
61
61
|
})
|
|
@@ -28,7 +28,7 @@ function _interopRequireDefault(obj) {
|
|
|
28
28
|
describe('Panel Groups', ()=>{
|
|
29
29
|
const renderDashboard = ()=>{
|
|
30
30
|
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TimeRangeProvider, {
|
|
31
|
-
|
|
31
|
+
initialTimeRange: {
|
|
32
32
|
pastDuration: '30m'
|
|
33
33
|
},
|
|
34
34
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TemplateVariableProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAsBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,
|
|
1
|
+
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAsBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBAmF5D,CAAC"}
|
|
@@ -20,10 +20,14 @@ import { useDashboardActions, useEditMode } from '../../context';
|
|
|
20
20
|
import { TemplateVariableList } from '../Variables';
|
|
21
21
|
import { TimeRangeControls } from '../TimeRangeControls';
|
|
22
22
|
export const DashboardToolbar = (props)=>{
|
|
23
|
-
const { dashboardName , onEditButtonClick , onCancelButtonClick } = props;
|
|
23
|
+
const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , onEditButtonClick , onCancelButtonClick } = props;
|
|
24
24
|
const { isEditMode , setEditMode } = useEditMode();
|
|
25
25
|
const { openAddPanelGroup , openAddPanel } = useDashboardActions();
|
|
26
26
|
const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));
|
|
27
|
+
const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ _jsx(Typography, {
|
|
28
|
+
variant: "h2",
|
|
29
|
+
children: dashboardName
|
|
30
|
+
});
|
|
27
31
|
const onSave = ()=>{
|
|
28
32
|
setEditMode(false);
|
|
29
33
|
};
|
|
@@ -39,13 +43,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
39
43
|
padding: 2,
|
|
40
44
|
display: "flex",
|
|
41
45
|
children: [
|
|
42
|
-
|
|
43
|
-
variant: "h2",
|
|
44
|
-
children: [
|
|
45
|
-
"Edit ",
|
|
46
|
-
dashboardName
|
|
47
|
-
]
|
|
48
|
-
}),
|
|
46
|
+
dashboardTitle,
|
|
49
47
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
50
48
|
direction: "row",
|
|
51
49
|
spacing: 1,
|
|
@@ -78,7 +76,9 @@ export const DashboardToolbar = (props)=>{
|
|
|
78
76
|
children: [
|
|
79
77
|
/*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
80
78
|
FallbackComponent: ErrorAlert,
|
|
81
|
-
children: /*#__PURE__*/ _jsx(TemplateVariableList, {
|
|
79
|
+
children: /*#__PURE__*/ _jsx(TemplateVariableList, {
|
|
80
|
+
initialVariableIsSticky: initialVariableIsSticky
|
|
81
|
+
})
|
|
82
82
|
}),
|
|
83
83
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
84
84
|
direction: 'row',
|
|
@@ -113,10 +113,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
113
113
|
width: '100%'
|
|
114
114
|
},
|
|
115
115
|
children: [
|
|
116
|
-
|
|
117
|
-
variant: "h2",
|
|
118
|
-
children: dashboardName
|
|
119
|
-
}),
|
|
116
|
+
dashboardTitle,
|
|
120
117
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
121
118
|
direction: "row",
|
|
122
119
|
spacing: 2,
|
|
@@ -142,7 +139,9 @@ export const DashboardToolbar = (props)=>{
|
|
|
142
139
|
paddingY: 2,
|
|
143
140
|
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
144
141
|
FallbackComponent: ErrorAlert,
|
|
145
|
-
children: /*#__PURE__*/ _jsx(TemplateVariableList, {
|
|
142
|
+
children: /*#__PURE__*/ _jsx(TemplateVariableList, {
|
|
143
|
+
initialVariableIsSticky: initialVariableIsSticky
|
|
144
|
+
})
|
|
146
145
|
})
|
|
147
146
|
})
|
|
148
147
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.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 { Typography, Stack, Button, Box, useTheme, useMediaQuery } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useDashboardActions, useEditMode } from '../../context';\nimport { TemplateVariableList } from '../Variables';\nimport { TimeRangeControls } from '../TimeRangeControls';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const { dashboardName, onEditButtonClick, onCancelButtonClick }
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.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 { Typography, Stack, Button, Box, useTheme, useMediaQuery } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useDashboardActions, useEditMode } from '../../context';\nimport { TemplateVariableList } from '../Variables';\nimport { TimeRangeControls } from '../TimeRangeControls';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const { dashboardName, dashboardTitleComponent, initialVariableIsSticky, onEditButtonClick, onCancelButtonClick } =\n props;\n\n const { isEditMode, setEditMode } = useEditMode();\n const { openAddPanelGroup, openAddPanel } = useDashboardActions();\n const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const onSave = () => {\n setEditMode(false);\n };\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={2}>\n <Box sx={{ backgroundColor: (theme) => theme.palette.primary.light + '20' }}>\n <Box padding={2} display=\"flex\">\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'flex-start',\n padding: (theme) => theme.spacing(2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList initialVariableIsSticky={initialVariableIsSticky} />\n </ErrorBoundary>\n <Stack direction={'row'} spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button startIcon={<AddPanelGroupIcon />} onClick={openAddPanelGroup}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel}>\n Add Panel\n </Button>\n <TimeRangeControls />\n </Stack>\n </Box>\n </Stack>\n ) : (\n <Stack spacing={2} padding={2}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={2} sx={{ marginLeft: 'auto' }}>\n <TimeRangeControls />\n {isLaptopSize && (\n <Button\n variant=\"outlined\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n )}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList initialVariableIsSticky={initialVariableIsSticky} />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","useDashboardActions","useEditMode","TemplateVariableList","TimeRangeControls","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","onEditButtonClick","onCancelButtonClick","isEditMode","setEditMode","openAddPanelGroup","openAddPanel","isLaptopSize","breakpoints","up","dashboardTitle","variant","onSave","spacing","sx","backgroundColor","theme","palette","primary","light","padding","display","direction","marginLeft","onClick","width","alignItems","FallbackComponent","startIcon","paddingY"],"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,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,eAAe,CAAC;AACxF,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAOC,YAAY,MAAM,qCAAqC,CAAC;AAC/D,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,mBAAmB,EAAEC,WAAW,QAAQ,eAAe,CAAC;AACjE,SAASC,oBAAoB,QAAQ,cAAc,CAAC;AACpD,SAASC,iBAAiB,QAAQ,sBAAsB,CAAC;AAUzD,OAAO,MAAMC,gBAAgB,GAAG,CAACC,KAA4B,GAAK;IAChE,MAAM,EAAEC,aAAa,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,iBAAiB,CAAA,EAAEC,mBAAmB,CAAA,EAAE,GAC/GL,KAAK,AAAC;IAER,MAAM,EAAEM,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGX,WAAW,EAAE,AAAC;IAClD,MAAM,EAAEY,iBAAiB,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGd,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AuB,EAAEA,uBAAuB;0BAAI;sBAC5D;kBACZ;;UACA,AACT;MACA,CACH;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +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,eAqBtD"}
|
|
@@ -10,36 +10,64 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useEffect, useState } from 'react';
|
|
15
|
+
import { styled } from '@mui/material';
|
|
16
|
+
export function GridContainer(props) {
|
|
17
|
+
const [isFirstRender, setIsFirstRender] = useState(true);
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
if (isFirstRender) {
|
|
20
|
+
setIsFirstRender(false);
|
|
21
|
+
}
|
|
22
|
+
}, [
|
|
23
|
+
isFirstRender
|
|
24
|
+
]);
|
|
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)
|
|
30
|
+
},
|
|
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
|
+
},
|
|
37
|
+
children: props.children
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* These are the classes needed by react-grid-layout from their CSS stylesheet.
|
|
42
|
+
*/ const ReactGridLayoutContainer = styled('section')(({ theme })=>({
|
|
43
|
+
'& .react-grid-layout': {
|
|
16
44
|
position: 'relative',
|
|
17
45
|
transition: 'height 200ms ease'
|
|
18
46
|
},
|
|
19
|
-
'
|
|
47
|
+
'& .react-grid-item': {
|
|
20
48
|
transition: 'all 200ms ease',
|
|
21
49
|
transitionProperty: 'left, top'
|
|
22
50
|
},
|
|
23
|
-
'
|
|
51
|
+
'& .react-grid-item img': {
|
|
24
52
|
pointerEvents: 'none',
|
|
25
53
|
userSelect: 'none'
|
|
26
54
|
},
|
|
27
|
-
'
|
|
55
|
+
'& .react-grid-item.cssTransforms': {
|
|
28
56
|
transitionProperty: 'transform'
|
|
29
57
|
},
|
|
30
|
-
'
|
|
58
|
+
'& .react-grid-item.resizing': {
|
|
31
59
|
zIndex: 1,
|
|
32
60
|
willChange: 'width, height'
|
|
33
61
|
},
|
|
34
|
-
'
|
|
62
|
+
'& .react-grid-item.react-draggable-dragging': {
|
|
35
63
|
transition: 'none',
|
|
36
64
|
zIndex: 3,
|
|
37
65
|
willChange: 'transform'
|
|
38
66
|
},
|
|
39
|
-
'
|
|
67
|
+
'& .react-grid-item.dropping': {
|
|
40
68
|
visibility: 'hidden'
|
|
41
69
|
},
|
|
42
|
-
'
|
|
70
|
+
'& .react-grid-item.react-grid-placeholder': {
|
|
43
71
|
background: theme.palette.primary.main,
|
|
44
72
|
opacity: 0.2,
|
|
45
73
|
transitionDuration: '100ms',
|
|
@@ -50,12 +78,12 @@ export const styles = (theme)=>{
|
|
|
50
78
|
msUserSelect: 'none',
|
|
51
79
|
OUserSelect: 'none'
|
|
52
80
|
},
|
|
53
|
-
'
|
|
81
|
+
'& .react-grid-item > .react-resizable-handle': {
|
|
54
82
|
position: 'absolute',
|
|
55
83
|
width: '20px',
|
|
56
84
|
height: '20px'
|
|
57
85
|
},
|
|
58
|
-
'
|
|
86
|
+
'& .react-grid-item > .react-resizable-handle::after': {
|
|
59
87
|
content: '""',
|
|
60
88
|
position: 'absolute',
|
|
61
89
|
right: '3px',
|
|
@@ -65,62 +93,62 @@ export const styles = (theme)=>{
|
|
|
65
93
|
borderRight: '2px solid rgba(0, 0, 0, 0.4)',
|
|
66
94
|
borderBottom: '2px solid rgba(0, 0, 0, 0.4)'
|
|
67
95
|
},
|
|
68
|
-
'
|
|
96
|
+
'& .react-resizable-hide > .react-resizable-handle': {
|
|
69
97
|
display: 'none'
|
|
70
98
|
},
|
|
71
|
-
'
|
|
99
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {
|
|
72
100
|
bottom: '0',
|
|
73
101
|
left: '0',
|
|
74
102
|
cursor: 'sw-resize',
|
|
75
103
|
transform: 'rotate(90deg)'
|
|
76
104
|
},
|
|
77
|
-
'
|
|
105
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-se': {
|
|
78
106
|
bottom: '0',
|
|
79
107
|
right: '0',
|
|
80
108
|
cursor: 'se-resize'
|
|
81
109
|
},
|
|
82
|
-
'
|
|
110
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {
|
|
83
111
|
top: '0',
|
|
84
112
|
left: '0',
|
|
85
113
|
cursor: 'nw-resize',
|
|
86
114
|
transform: 'rotate(180deg)'
|
|
87
115
|
},
|
|
88
|
-
'
|
|
116
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {
|
|
89
117
|
top: '0',
|
|
90
118
|
right: '0',
|
|
91
119
|
cursor: 'ne-resize',
|
|
92
120
|
transform: 'rotate(270deg)'
|
|
93
121
|
},
|
|
94
|
-
'
|
|
122
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
|
|
95
123
|
top: '50%',
|
|
96
124
|
marginTop: '-10px',
|
|
97
125
|
cursor: 'ew-resize'
|
|
98
126
|
},
|
|
99
|
-
'
|
|
127
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
|
|
100
128
|
left: '0',
|
|
101
129
|
transform: 'rotate(135deg)'
|
|
102
130
|
},
|
|
103
|
-
'
|
|
131
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
|
|
104
132
|
right: '0',
|
|
105
133
|
transform: 'rotate(315deg)'
|
|
106
134
|
},
|
|
107
|
-
'
|
|
135
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
|
|
108
136
|
left: '50%',
|
|
109
137
|
marginLeft: '-10px',
|
|
110
138
|
cursor: 'ns-resize'
|
|
111
139
|
},
|
|
112
|
-
'
|
|
140
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
|
|
113
141
|
top: '0',
|
|
114
142
|
transform: 'rotate(225deg)'
|
|
115
143
|
},
|
|
116
|
-
'
|
|
144
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
|
|
117
145
|
bottom: '0',
|
|
118
146
|
transform: 'rotate(45deg)'
|
|
119
147
|
},
|
|
120
|
-
'
|
|
148
|
+
'& .react-resizable': {
|
|
121
149
|
position: 'relative'
|
|
122
150
|
},
|
|
123
|
-
'
|
|
151
|
+
'& .react-resizable-handle': {
|
|
124
152
|
position: 'absolute',
|
|
125
153
|
width: '20px',
|
|
126
154
|
height: '20px',
|
|
@@ -131,56 +159,55 @@ export const styles = (theme)=>{
|
|
|
131
159
|
backgroundPosition: 'bottom right',
|
|
132
160
|
padding: '0 3px 3px 0'
|
|
133
161
|
},
|
|
134
|
-
'
|
|
162
|
+
'& .react-resizable-handle-sw': {
|
|
135
163
|
bottom: '0',
|
|
136
164
|
left: '0',
|
|
137
165
|
cursor: 'sw-resize',
|
|
138
166
|
transform: 'rotate(90deg)'
|
|
139
167
|
},
|
|
140
|
-
'
|
|
168
|
+
'& .react-resizable-handle-se': {
|
|
141
169
|
bottom: '0',
|
|
142
170
|
right: '0',
|
|
143
171
|
cursor: 'se-resize'
|
|
144
172
|
},
|
|
145
|
-
'
|
|
173
|
+
'& .react-resizable-handle-nw': {
|
|
146
174
|
top: '0',
|
|
147
175
|
left: '0',
|
|
148
176
|
cursor: 'nw-resize',
|
|
149
177
|
transform: 'rotate(180deg)'
|
|
150
178
|
},
|
|
151
|
-
'
|
|
179
|
+
'& .react-resizable-handle-ne': {
|
|
152
180
|
top: '0',
|
|
153
181
|
right: '0',
|
|
154
182
|
cursor: 'ne-resize',
|
|
155
183
|
transform: 'rotate(270deg)'
|
|
156
184
|
},
|
|
157
|
-
'
|
|
185
|
+
'& .react-resizable-handle-w, .react-resizable-handle-e': {
|
|
158
186
|
top: '50%',
|
|
159
187
|
marginTop: '-10px',
|
|
160
188
|
cursor: 'ew-resize'
|
|
161
189
|
},
|
|
162
|
-
'
|
|
190
|
+
'& .react-resizable-handle-w': {
|
|
163
191
|
left: '0',
|
|
164
192
|
transform: 'rotate(135deg)'
|
|
165
193
|
},
|
|
166
|
-
'
|
|
194
|
+
'& .react-resizable-handle-e': {
|
|
167
195
|
right: '0',
|
|
168
196
|
transform: 'rotate(315deg)'
|
|
169
197
|
},
|
|
170
|
-
'
|
|
198
|
+
'& .react-resizable-handle-n, .react-resizable-handle-s': {
|
|
171
199
|
left: '50%',
|
|
172
200
|
marginLeft: '-10px',
|
|
173
201
|
cursor: 'ns-resize'
|
|
174
202
|
},
|
|
175
|
-
'
|
|
203
|
+
'& .react-resizable-handle-n': {
|
|
176
204
|
top: '0',
|
|
177
205
|
transform: 'rotate(225deg)'
|
|
178
206
|
},
|
|
179
|
-
'
|
|
207
|
+
'& .react-resizable-handle-s': {
|
|
180
208
|
bottom: '0',
|
|
181
209
|
transform: 'rotate(45deg)'
|
|
182
210
|
}
|
|
183
|
-
};
|
|
184
|
-
};
|
|
211
|
+
}));
|
|
185
212
|
|
|
186
|
-
//# sourceMappingURL=
|
|
213
|
+
//# sourceMappingURL=GridContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridContainer.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 { 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 >\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 rgba(0, 0, 0, 0.4)',\n borderBottom: '2px solid rgba(0, 0, 0, 0.4)',\n },\n\n '& .react-resizable-hide > .react-resizable-handle': {\n display: 'none',\n },\n\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {\n bottom: '0',\n left: '0',\n cursor: 'sw-resize',\n transform: 'rotate(90deg)',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-se': {\n bottom: '0',\n right: '0',\n cursor: 'se-resize',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {\n top: '0',\n left: '0',\n cursor: 'nw-resize',\n transform: 'rotate(180deg)',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {\n top: '0',\n right: '0',\n cursor: 'ne-resize',\n transform: 'rotate(270deg)',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e':\n {\n top: '50%',\n marginTop: '-10px',\n cursor: 'ew-resize',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-w': {\n left: '0',\n transform: 'rotate(135deg)',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-e': {\n right: '0',\n transform: 'rotate(315deg)',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s':\n {\n left: '50%',\n marginLeft: '-10px',\n cursor: 'ns-resize',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-n': {\n top: '0',\n transform: 'rotate(225deg)',\n },\n '& .react-grid-item > .react-resizable-handle.react-resizable-handle-s': {\n bottom: '0',\n transform: 'rotate(45deg)',\n },\n '& .react-resizable': {\n position: 'relative',\n },\n '& .react-resizable-handle': {\n position: 'absolute',\n width: '20px',\n height: '20px',\n backgroundRepeat: 'no-repeat',\n backgroundOrigin: 'content-box',\n boxSizing: 'border-box',\n backgroundImage: `url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+')`,\n backgroundPosition: 'bottom right',\n padding: '0 3px 3px 0',\n },\n '& .react-resizable-handle-sw': {\n bottom: '0',\n left: '0',\n cursor: 'sw-resize',\n transform: 'rotate(90deg)',\n },\n '& .react-resizable-handle-se': {\n bottom: '0',\n right: '0',\n cursor: 'se-resize',\n },\n '& .react-resizable-handle-nw': {\n top: '0',\n left: '0',\n cursor: 'nw-resize',\n transform: 'rotate(180deg)',\n },\n '& .react-resizable-handle-ne': {\n top: '0',\n right: '0',\n cursor: 'ne-resize',\n transform: 'rotate(270deg)',\n },\n '& .react-resizable-handle-w, .react-resizable-handle-e': {\n top: '50%',\n marginTop: '-10px',\n cursor: 'ew-resize',\n },\n '& .react-resizable-handle-w': {\n left: '0',\n transform: 'rotate(135deg)',\n },\n '& .react-resizable-handle-e': {\n right: '0',\n transform: 'rotate(315deg)',\n },\n '& .react-resizable-handle-n, .react-resizable-handle-s': {\n left: '50%',\n marginLeft: '-10px',\n cursor: 'ns-resize',\n },\n '& .react-resizable-handle-n': {\n top: '0',\n transform: 'rotate(225deg)',\n },\n '& .react-resizable-handle-s': {\n bottom: '0',\n transform: 'rotate(45deg)',\n },\n}));\n"],"names":["useEffect","useState","styled","GridContainer","props","isFirstRender","setIsFirstRender","ReactGridLayoutContainer","sx","marginTop","theme","spacing","transitionProperty","children","position","transition","pointerEvents","userSelect","zIndex","willChange","visibility","background","palette","primary","main","opacity","transitionDuration","WebkitUserSelect","MozUserSelect","msUserSelect","OUserSelect","width","height","content","right","bottom","borderRight","borderBottom","display","left","cursor","transform","top","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;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC5C,SAASC,MAAM,QAAQ,eAAe,CAAC;AAMvC,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGL,QAAQ,CAAC,IAAI,CAAC,AAAC;IACzDD,SAAS,CAAC,IAAM;QACd,IAAIK,aAAa,EAAE;YACjBC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,EAAE;QAACD,aAAa;KAAC,CAAC,CAAC;IAEpB,qBACE,KAACE,wBAAwB;QACvBC,EAAE,EAAE;YACF,iEAAiE;YACjE,OAAO,EAAE;gBAAEC,SAAS,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,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AE;YAC7BE,GAAG,EAAE,GAAG;YACRD,SAAS,EAAE,gBAAgB;SAC5B;QACD,6BAA6B,EAAE;YAC7BN,MAAM,EAAE,GAAG;YACXM,SAAS,EAAE,eAAe;SAC3B;KACF,CAAA,AAAC,CAAC,AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAoD,YAAY,EAAE,MAAM,eAAe,CAAC;AAO/F,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA+ChD"}
|
|
@@ -10,90 +10,77 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useState } from 'react';
|
|
15
15
|
import { Responsive, WidthProvider } from 'react-grid-layout';
|
|
16
|
-
import {
|
|
16
|
+
import { Collapse, useTheme } from '@mui/material';
|
|
17
17
|
import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
18
|
-
import { styles } from '../../css/styles';
|
|
19
18
|
import { useEditMode, usePanelGroup, usePanelGroupActions } from '../../context';
|
|
20
19
|
import { GridTitle } from './GridTitle';
|
|
21
20
|
import { GridItemContent } from './GridItemContent';
|
|
21
|
+
import { GridContainer } from './GridContainer';
|
|
22
22
|
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
23
23
|
/**
|
|
24
24
|
* Layout component that arranges children in a Grid based on the definition.
|
|
25
25
|
*/ export function GridLayout(props) {
|
|
26
|
-
const { panelGroupId
|
|
26
|
+
const { panelGroupId /*...others */ } = props;
|
|
27
27
|
const theme = useTheme();
|
|
28
28
|
const groupDefinition = usePanelGroup(panelGroupId);
|
|
29
29
|
const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);
|
|
30
30
|
var ref;
|
|
31
31
|
const [isOpen, setIsOpen] = useState((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
32
32
|
const { isEditMode } = useEditMode();
|
|
33
|
-
return /*#__PURE__*/ _jsxs(
|
|
33
|
+
return /*#__PURE__*/ _jsxs(GridContainer, {
|
|
34
34
|
children: [
|
|
35
|
-
/*#__PURE__*/ _jsx(
|
|
36
|
-
|
|
35
|
+
groupDefinition.title !== undefined && /*#__PURE__*/ _jsx(GridTitle, {
|
|
36
|
+
panelGroupId: panelGroupId,
|
|
37
|
+
title: groupDefinition.title,
|
|
38
|
+
collapse: groupDefinition.isCollapsed === undefined ? undefined : {
|
|
39
|
+
isOpen,
|
|
40
|
+
onToggleOpen: ()=>setIsOpen((current)=>!current)
|
|
41
|
+
}
|
|
37
42
|
}),
|
|
38
|
-
/*#__PURE__*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
layouts: {
|
|
80
|
-
sm: groupDefinition.itemLayouts
|
|
81
|
-
},
|
|
82
|
-
onLayoutChange: updatePanelGroupLayouts,
|
|
83
|
-
children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ _jsx("div", {
|
|
84
|
-
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
85
|
-
FallbackComponent: ErrorAlert,
|
|
86
|
-
children: /*#__PURE__*/ _jsx(GridItemContent, {
|
|
87
|
-
panelGroupItemId: {
|
|
88
|
-
panelGroupId,
|
|
89
|
-
panelGroupItemLayoutId: i
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
}, i))
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
]
|
|
43
|
+
/*#__PURE__*/ _jsx(Collapse, {
|
|
44
|
+
in: isOpen,
|
|
45
|
+
unmountOnExit: true,
|
|
46
|
+
appear: false,
|
|
47
|
+
children: /*#__PURE__*/ _jsx(ResponsiveGridLayout, {
|
|
48
|
+
className: "layout",
|
|
49
|
+
breakpoints: {
|
|
50
|
+
sm: theme.breakpoints.values.sm,
|
|
51
|
+
xxs: 0
|
|
52
|
+
},
|
|
53
|
+
cols: {
|
|
54
|
+
sm: 24,
|
|
55
|
+
xxs: 2
|
|
56
|
+
},
|
|
57
|
+
rowHeight: 30,
|
|
58
|
+
draggableHandle: '.drag-handle',
|
|
59
|
+
resizeHandles: [
|
|
60
|
+
'se'
|
|
61
|
+
],
|
|
62
|
+
isDraggable: isEditMode,
|
|
63
|
+
isResizable: isEditMode,
|
|
64
|
+
containerPadding: [
|
|
65
|
+
0,
|
|
66
|
+
10
|
|
67
|
+
],
|
|
68
|
+
layouts: {
|
|
69
|
+
sm: groupDefinition.itemLayouts
|
|
70
|
+
},
|
|
71
|
+
onLayoutChange: updatePanelGroupLayouts,
|
|
72
|
+
children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ _jsx("div", {
|
|
73
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
74
|
+
FallbackComponent: ErrorAlert,
|
|
75
|
+
children: /*#__PURE__*/ _jsx(GridItemContent, {
|
|
76
|
+
panelGroupItemId: {
|
|
77
|
+
panelGroupId,
|
|
78
|
+
panelGroupItemLayoutId: i
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}, i))
|
|
83
|
+
})
|
|
97
84
|
})
|
|
98
85
|
]
|
|
99
86
|
});
|