@perses-dev/dashboards 0.14.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 +7 -3
- 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/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/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/testDashboard.js +1 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -7
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +7 -3
- 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/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/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/testDashboard.js +1 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +6 -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 +4 -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
|
@@ -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;QACv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D,EAAE;YACxDF,IAAI,EAAE,KAAK;YACXI,UAAU,EAAE,OAAO;YACnBH,MAAM,EAAE,WAAW;SACpB;QACD,6BAA6B,EAAE;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
|
});
|
|
@@ -1 +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 {
|
|
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 { Collapse, useTheme } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, PanelGroupId } from '../../context';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\nimport { GridContainer } from './GridContainer';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId /*...others */ } = props;\n const theme = useTheme();\n const groupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n return (\n <GridContainer>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false}>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ sm: theme.breakpoints.values.sm, xxs: 0 }}\n cols={{ sm: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n containerPadding={[0, 10]}\n layouts={{ sm: groupDefinition.itemLayouts }}\n onLayoutChange={updatePanelGroupLayouts}\n >\n {groupDefinition.itemLayouts.map(({ i }) => (\n <div key={i}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i }} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Collapse","useTheme","ErrorAlert","ErrorBoundary","useEditMode","usePanelGroup","usePanelGroupActions","GridTitle","GridItemContent","GridContainer","ResponsiveGridLayout","GridLayout","props","panelGroupId","theme","groupDefinition","updatePanelGroupLayouts","isOpen","setIsOpen","isCollapsed","isEditMode","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","appear","className","breakpoints","sm","values","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","containerPadding","layouts","itemLayouts","onLayoutChange","map","i","div","FallbackComponent","panelGroupItemId","panelGroupItemLayoutId"],"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,QAAQ,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AACnD,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,QAAsB,eAAe,CAAC;AAC/F,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AACpD,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAEhD,MAAMC,oBAAoB,GAAGX,aAAa,CAACD,UAAU,CAAC,AAAC;AAMvD;;CAEC,GACD,OAAO,SAASa,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,YAAY,CAAA,AAAC,YAAY,KAAI,GAAGD,KAAK,AAAC;IAC9C,MAAME,KAAK,GAAGb,QAAQ,EAAE,AAAC;IACzB,MAAMc,eAAe,GAAGV,aAAa,CAACQ,YAAY,CAAC,AAAC;IACpD,MAAM,EAAEG,uBAAuB,CAAA,EAAE,GAAGV,oBAAo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AC5CC,cAAc,EAAE3B,uBAAuB;8BAEtCD,eAAe,CAAC2B,WAAW,CAACE,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAE,iBACrC,KAACC,KAAG;sCACF,cAAA,KAAC3C,aAAa;gCAAC4C,iBAAiB,EAAE7C,UAAU;0CAC1C,cAAA,KAACM,eAAe;oCAACwC,gBAAgB,EAAE;wCAAEnC,YAAY;wCAAEoC,sBAAsB,EAAEJ,CAAC;qCAAE;kCAAI;8BACpE;2BAHRA,CAAC,CAIL,AACP,CAAC;kBACmB;cACd;;MACG,CAChB;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAqC,YAAY,
|
|
1
|
+
{"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAqC,YAAY,EAA6B,MAAM,eAAe,CAAC;AAE3G,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,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,eA0D9C"}
|
|
@@ -20,14 +20,15 @@ import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
|
20
20
|
import ArrowUpIcon from 'mdi-material-ui/ArrowUp';
|
|
21
21
|
import ArrowDownIcon from 'mdi-material-ui/ArrowDown';
|
|
22
22
|
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
23
|
-
import { usePanelGroupActions, useEditMode } from '../../context';
|
|
23
|
+
import { usePanelGroupActions, useEditMode, useDeletePanelGroupDialog } from '../../context';
|
|
24
24
|
/**
|
|
25
25
|
* Renders the title for a Grid section, optionally also supporting expanding
|
|
26
26
|
* and collapsing
|
|
27
27
|
*/ export function GridTitle(props) {
|
|
28
28
|
const { panelGroupId , title , collapse } = props;
|
|
29
29
|
const [isHovered, setIsHovered] = useState(false);
|
|
30
|
-
const { openAddPanel , openEditPanelGroup ,
|
|
30
|
+
const { openAddPanel , openEditPanelGroup , moveUp , moveDown } = usePanelGroupActions(panelGroupId);
|
|
31
|
+
const { openDeletePanelGroupDialog } = useDeletePanelGroupDialog();
|
|
31
32
|
const { isEditMode } = useEditMode();
|
|
32
33
|
const text = /*#__PURE__*/ _jsx(Typography, {
|
|
33
34
|
variant: "h2",
|
|
@@ -71,7 +72,7 @@ import { usePanelGroupActions, useEditMode } from '../../context';
|
|
|
71
72
|
}),
|
|
72
73
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
73
74
|
"aria-label": "delete group",
|
|
74
|
-
onClick:
|
|
75
|
+
onClick: ()=>openDeletePanelGroupDialog(panelGroupId),
|
|
75
76
|
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
76
77
|
}),
|
|
77
78
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
@@ -1 +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';\nimport { usePanelGroupActions, useEditMode, PanelGroupId } from '../../context';\n\nexport interface GridTitleProps {\n panelGroupId: PanelGroupId;\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 { panelGroupId, title, collapse } = props;\n\n const [isHovered, setIsHovered] = useState(false);\n const { openAddPanel, openEditPanelGroup,
|
|
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';\nimport { usePanelGroupActions, useEditMode, PanelGroupId, useDeletePanelGroupDialog } from '../../context';\n\nexport interface GridTitleProps {\n panelGroupId: PanelGroupId;\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 { panelGroupId, title, collapse } = props;\n\n const [isHovered, setIsHovered] = useState(false);\n const { openAddPanel, openEditPanelGroup, moveUp, moveDown } = usePanelGroupActions(panelGroupId);\n const { openDeletePanelGroupDialog } = useDeletePanelGroupDialog();\n const { isEditMode } = useEditMode();\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={openAddPanel}>\n <AddIcon />\n </IconButton>\n <IconButton aria-label=\"edit group\" onClick={openEditPanelGroup}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete group\" onClick={() => openDeletePanelGroupDialog(panelGroupId)}>\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"move group down\" disabled={moveDown === undefined} onClick={moveDown}>\n <ArrowDownIcon />\n </IconButton>\n <IconButton aria-label=\"move group up\" disabled={moveUp === undefined} onClick={moveUp}>\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","usePanelGroupActions","useEditMode","useDeletePanelGroupDialog","GridTitle","props","panelGroupId","title","collapse","isHovered","setIsHovered","openAddPanel","openEditPanelGroup","moveUp","moveDown","openDeletePanelGroupDialog","isEditMode","text","variant","sx","marginLeft","undefined","display","justifyContent","alignItems","padding","theme","spacing","backgroundColor","palette","background","default","onMouseEnter","onMouseLeave","onClick","onToggleOpen","isOpen","direction","aria-label","disabled"],"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;AACvD,SAASC,oBAAoB,EAAEC,WAAW,EAAgBC,yBAAyB,QAAQ,eAAe,CAAC;AAW3G;;;CAGC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAM,EAAEC,YAAY,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEhD,MAAM,CAACI,SAAS,EAAEC,YAAY,CAAC,GAAGrB,QAAQ,CAAC,KAAK,CAAC,AAAC;IAClD,MAAM,EAAEsB,YAAY,CAAA,EAAEC,kBAAkB,CAAA,EAAEC,MAAM,CAAA,EAAEC,QAAQ,CAAA,EAAE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,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA6C,eAAe,EAAU,MAAM,eAAe,CAAC;AAOnG,aAAK,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE1E,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC7B,kBAAkB,EAAE,MAAM,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,eAkE7G"}
|
|
@@ -82,17 +82,17 @@ export function PanelHeader({ id , title , description , editHandlers , isHovere
|
|
|
82
82
|
title: /*#__PURE__*/ _jsx(Typography, {
|
|
83
83
|
id: titleElementId,
|
|
84
84
|
variant: "subtitle1",
|
|
85
|
-
sx: {
|
|
86
|
-
whiteSpace: 'nowrap',
|
|
87
|
-
overflow: 'hidden',
|
|
88
|
-
textOverflow: 'ellipsis'
|
|
89
|
-
},
|
|
90
85
|
children: title
|
|
91
86
|
}),
|
|
92
87
|
action: action,
|
|
93
88
|
sx: combineSx((theme)=>({
|
|
94
89
|
padding: theme.spacing(1),
|
|
95
|
-
borderBottom: `solid 1px ${theme.palette.divider}
|
|
90
|
+
borderBottom: `solid 1px ${theme.palette.divider}`,
|
|
91
|
+
'.MuiCardHeader-content': {
|
|
92
|
+
whiteSpace: 'nowrap',
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
textOverflow: 'ellipsis'
|
|
95
|
+
}
|
|
96
96
|
}), sx),
|
|
97
97
|
...rest
|
|
98
98
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, Typography, Stack, IconButton, CardHeaderProps, styled } from '@mui/material';\nimport { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n isHovered: boolean;\n}\n\nexport function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps) {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n // Don't show any actions unless panel is hovered\n let action: CardHeaderProps['action'] = undefined;\n if (isHovered) {\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n action = (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <HeaderIconButton aria-label=\"edit panel\" size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label=\"delete panel\" size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </HeaderIconButton>\n </Stack>\n );\n } else if (description !== undefined) {\n // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description\n action = (\n <InfoTooltip id={descriptionTooltipId} description={description} placement={TooltipPlacement.Bottom}>\n <HeaderIconButton aria-label=\"Panel Description\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Typography
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, Typography, Stack, IconButton, CardHeaderProps, styled } from '@mui/material';\nimport { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n isHovered: boolean;\n}\n\nexport function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps) {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n // Don't show any actions unless panel is hovered\n let action: CardHeaderProps['action'] = undefined;\n if (isHovered) {\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n action = (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <HeaderIconButton aria-label=\"edit panel\" size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label=\"delete panel\" size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </HeaderIconButton>\n </Stack>\n );\n } else if (description !== undefined) {\n // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description\n action = (\n <InfoTooltip id={descriptionTooltipId} description={description} placement={TooltipPlacement.Bottom}>\n <HeaderIconButton aria-label=\"Panel Description\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Typography id={titleElementId} variant=\"subtitle1\">\n {title}\n </Typography>\n }\n action={action}\n sx={combineSx(\n (theme) => ({\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n\nconst HeaderIconButton = styled(IconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["CardHeader","Typography","Stack","IconButton","styled","InfoTooltip","TooltipPlacement","combineSx","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","PanelHeader","id","title","description","editHandlers","isHovered","sx","rest","titleElementId","descriptionTooltipId","action","undefined","direction","alignItems","spacing","HeaderIconButton","aria-label","size","onClick","onEditPanelClick","onDeletePanelClick","className","cursor","placement","Bottom","aria-describedby","aria-hidden","color","theme","palette","grey","component","aria-labelledby","disableTypography","variant","padding","borderBottom","divider","whiteSpace","overflow","textOverflow","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,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAmBC,MAAM,QAAQ,eAAe,CAAC;AACnG,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAClF,OAAOC,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,QAAQ,MAAM,8BAA8B,CAAC;AAepD,OAAO,SAASC,WAAW,CAAC,EAAEC,EAAE,CAAA,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,YAAY,CAAA,EAAEC,SAAS,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,IAAI,EAAoB,EAAE;IAC9G,MAAMC,cAAc,GAAG,CAAC,EAAEP,EAAE,CAAC,MAA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