@grafana/scenes 0.1.0 → 0.2.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/CHANGELOG.md +60 -0
- package/dist/esm/components/NestedScene.js +8 -0
- package/dist/esm/components/NestedScene.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +30 -5
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/components/layout/SceneFlexLayout.js +42 -45
- package/dist/esm/components/layout/SceneFlexLayout.js.map +1 -1
- package/dist/esm/components/layout/{SceneGridLayout.js → grid/SceneGridLayout.js} +57 -43
- package/dist/esm/components/layout/grid/SceneGridLayout.js.map +1 -0
- package/dist/esm/components/layout/{SceneGridRow.js → grid/SceneGridRow.js} +13 -14
- package/dist/esm/components/layout/grid/SceneGridRow.js.map +1 -0
- package/dist/esm/components/layout/grid/constants.js.map +1 -0
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/variables/interpolation/formatRegistry.js +18 -36
- package/dist/esm/variables/interpolation/formatRegistry.js.map +1 -1
- package/dist/esm/variables/interpolation/sceneInterpolator.js +4 -3
- package/dist/esm/variables/interpolation/sceneInterpolator.js.map +1 -1
- package/dist/esm/variables/macros/AllVariablesMacro.js +4 -3
- package/dist/esm/variables/macros/AllVariablesMacro.js.map +1 -1
- package/dist/esm/variables/variants/MultiValueVariable.js +7 -6
- package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
- package/dist/index.d.ts +57 -35
- package/dist/index.js +261 -235
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/components/layout/SceneGridLayout.js.map +0 -1
- package/dist/esm/components/layout/SceneGridRow.js.map +0 -1
- package/dist/esm/components/layout/constants.js.map +0 -1
- /package/dist/esm/components/layout/{constants.js → grid/constants.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactGridLayout from 'react-grid-layout';
|
|
3
3
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
4
|
-
import { SceneObjectBase } from '
|
|
5
|
-
import {
|
|
4
|
+
import { SceneObjectBase } from '../../../core/SceneObjectBase.js';
|
|
5
|
+
import { GRID_CELL_VMARGIN, GRID_COLUMN_COUNT, GRID_CELL_HEIGHT, DEFAULT_PANEL_SPAN } from './constants.js';
|
|
6
6
|
import { SceneGridRow } from './SceneGridRow.js';
|
|
7
7
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
@@ -24,11 +24,10 @@ var __spreadValues = (a, b) => {
|
|
|
24
24
|
return a;
|
|
25
25
|
};
|
|
26
26
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
-
class
|
|
27
|
+
const _SceneGridLayout = class extends SceneObjectBase {
|
|
28
28
|
constructor(state) {
|
|
29
29
|
super(__spreadProps(__spreadValues({}, state), {
|
|
30
30
|
isDraggable: true,
|
|
31
|
-
placement: state.placement,
|
|
32
31
|
children: sortChildrenByPosition(state.children)
|
|
33
32
|
}));
|
|
34
33
|
this._skipOnLayoutChange = false;
|
|
@@ -45,10 +44,8 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
45
44
|
width: item.w,
|
|
46
45
|
height: item.h
|
|
47
46
|
};
|
|
48
|
-
if (!isItemSizeEqual(child.state
|
|
49
|
-
child.setState({
|
|
50
|
-
placement: __spreadValues(__spreadValues({}, child.state.placement), nextSize)
|
|
51
|
-
});
|
|
47
|
+
if (!isItemSizeEqual(child.state, nextSize)) {
|
|
48
|
+
child.setState(__spreadValues({}, nextSize));
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
this.setState({ children: sortChildrenByPosition(this.state.children) });
|
|
@@ -56,10 +53,8 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
56
53
|
this.onResizeStop = (_, o, n) => {
|
|
57
54
|
const child = this.getSceneLayoutChild(n.i);
|
|
58
55
|
child.setState({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
height: n.h
|
|
62
|
-
})
|
|
56
|
+
width: n.w,
|
|
57
|
+
height: n.h
|
|
63
58
|
});
|
|
64
59
|
};
|
|
65
60
|
this.onDragStop = (gridLayout, o, updatedItem) => {
|
|
@@ -68,13 +63,11 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
68
63
|
for (let i = 0; i < gridLayout.length; i++) {
|
|
69
64
|
const gridItem = gridLayout[i];
|
|
70
65
|
const child = this.getSceneLayoutChild(gridItem.i);
|
|
71
|
-
const childSize = child.state
|
|
66
|
+
const childSize = child.state;
|
|
72
67
|
if ((childSize == null ? void 0 : childSize.x) !== gridItem.x || (childSize == null ? void 0 : childSize.y) !== gridItem.y) {
|
|
73
68
|
child.setState({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
y: gridItem.y
|
|
77
|
-
})
|
|
69
|
+
x: gridItem.x,
|
|
70
|
+
y: gridItem.y
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
73
|
}
|
|
@@ -99,7 +92,7 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
99
92
|
return `grid-drag-cancel`;
|
|
100
93
|
}
|
|
101
94
|
toggleRow(row) {
|
|
102
|
-
var _a, _b
|
|
95
|
+
var _a, _b;
|
|
103
96
|
const isCollapsed = row.state.isCollapsed;
|
|
104
97
|
if (!isCollapsed) {
|
|
105
98
|
row.setState({ isCollapsed: true });
|
|
@@ -112,27 +105,27 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
112
105
|
this.setState({});
|
|
113
106
|
return;
|
|
114
107
|
}
|
|
115
|
-
const rowY =
|
|
116
|
-
const firstPanelYPos = (
|
|
108
|
+
const rowY = row.state.y;
|
|
109
|
+
const firstPanelYPos = (_a = rowChildren[0].state.y) != null ? _a : rowY;
|
|
117
110
|
const yDiff = firstPanelYPos - (rowY + 1);
|
|
118
111
|
let yMax = rowY;
|
|
119
112
|
for (const panel of rowChildren) {
|
|
120
|
-
const newSize = __spreadValues({}, panel.state
|
|
121
|
-
newSize.y = (
|
|
113
|
+
const newSize = __spreadValues({}, panel.state);
|
|
114
|
+
newSize.y = (_b = newSize.y) != null ? _b : rowY;
|
|
122
115
|
newSize.y -= yDiff;
|
|
123
|
-
if (newSize.y >
|
|
124
|
-
panel.setState(
|
|
116
|
+
if (newSize.y > panel.state.y) {
|
|
117
|
+
panel.setState(newSize);
|
|
125
118
|
}
|
|
126
119
|
yMax = Math.max(yMax, Number(newSize.y) + Number(newSize.height));
|
|
127
120
|
}
|
|
128
121
|
const pushDownAmount = yMax - rowY - 1;
|
|
129
122
|
for (const child of this.state.children) {
|
|
130
|
-
if (
|
|
123
|
+
if (child.state.y > rowY) {
|
|
131
124
|
this.pushChildDown(child, pushDownAmount);
|
|
132
125
|
}
|
|
133
|
-
if (child
|
|
126
|
+
if (isSceneGridRow(child) && child !== row) {
|
|
134
127
|
for (const rowChild of child.state.children) {
|
|
135
|
-
if (
|
|
128
|
+
if (rowChild.state.y > rowY) {
|
|
136
129
|
this.pushChildDown(rowChild, pushDownAmount);
|
|
137
130
|
}
|
|
138
131
|
}
|
|
@@ -157,11 +150,8 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
157
150
|
throw new Error("Scene layout child not found for GridItem");
|
|
158
151
|
}
|
|
159
152
|
pushChildDown(child, amount) {
|
|
160
|
-
var _a;
|
|
161
153
|
child.setState({
|
|
162
|
-
|
|
163
|
-
y: ((_a = child.state.placement) == null ? void 0 : _a.y) + amount
|
|
164
|
-
})
|
|
154
|
+
y: child.state.y + amount
|
|
165
155
|
});
|
|
166
156
|
}
|
|
167
157
|
findGridItemSceneParent(layout, startAt) {
|
|
@@ -193,21 +183,23 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
193
183
|
rootChildren = [...rootChildren, newChild];
|
|
194
184
|
}
|
|
195
185
|
} else {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
186
|
+
if (!(target instanceof _SceneGridLayout)) {
|
|
187
|
+
rootChildren = rootChildren.filter((c) => c.state.key !== child.state.key);
|
|
188
|
+
const targetRow = target.clone({ children: [...target.state.children, newChild] });
|
|
189
|
+
rootChildren = rootChildren.map((c) => c === target ? targetRow : c);
|
|
190
|
+
}
|
|
199
191
|
}
|
|
200
192
|
return rootChildren;
|
|
201
193
|
}
|
|
202
194
|
toGridCell(child) {
|
|
203
|
-
var _a, _b
|
|
204
|
-
const size = child.state
|
|
195
|
+
var _a, _b;
|
|
196
|
+
const size = child.state;
|
|
205
197
|
let x = (_a = size.x) != null ? _a : 0;
|
|
206
198
|
let y = (_b = size.y) != null ? _b : 0;
|
|
207
199
|
const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;
|
|
208
200
|
const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;
|
|
209
|
-
let isDraggable = Boolean(
|
|
210
|
-
let isResizable = Boolean(
|
|
201
|
+
let isDraggable = Boolean(child.state.isDraggable);
|
|
202
|
+
let isResizable = Boolean(child.state.isResizable);
|
|
211
203
|
if (child instanceof SceneGridRow) {
|
|
212
204
|
isDraggable = child.state.isCollapsed ? true : false;
|
|
213
205
|
isResizable = false;
|
|
@@ -232,7 +224,8 @@ class SceneGridLayout extends SceneObjectBase {
|
|
|
232
224
|
this._skipOnLayoutChange = false;
|
|
233
225
|
return cells;
|
|
234
226
|
}
|
|
235
|
-
}
|
|
227
|
+
};
|
|
228
|
+
let SceneGridLayout = _SceneGridLayout;
|
|
236
229
|
SceneGridLayout.Component = SceneGridLayoutRenderer;
|
|
237
230
|
function SceneGridLayoutRenderer({ model }) {
|
|
238
231
|
const { children } = model.useState();
|
|
@@ -274,9 +267,25 @@ function SceneGridLayoutRenderer({ model }) {
|
|
|
274
267
|
})));
|
|
275
268
|
});
|
|
276
269
|
}
|
|
270
|
+
class SceneGridItem extends SceneObjectBase {
|
|
271
|
+
}
|
|
272
|
+
SceneGridItem.Component = SceneGridItemRenderer;
|
|
273
|
+
function SceneGridItemRenderer({ model }) {
|
|
274
|
+
const { body } = model.useState();
|
|
275
|
+
const parent = model.parent;
|
|
276
|
+
if (parent && !isSceneGridLayout(parent) && !isSceneGridRow(parent)) {
|
|
277
|
+
throw new Error("SceneGridItem must be a child of SceneGridLayout or SceneGridRow");
|
|
278
|
+
}
|
|
279
|
+
if (!body) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return /* @__PURE__ */ React.createElement(body.Component, {
|
|
283
|
+
model: body
|
|
284
|
+
});
|
|
285
|
+
}
|
|
277
286
|
function validateChildrenSize(children) {
|
|
278
287
|
if (children.find(
|
|
279
|
-
(c) =>
|
|
288
|
+
(c) => c.state.height === void 0 || c.state.width === void 0 || c.state.x === void 0 || c.state.y === void 0
|
|
280
289
|
)) {
|
|
281
290
|
throw new Error("All children must have a size specified");
|
|
282
291
|
}
|
|
@@ -286,13 +295,18 @@ function isItemSizeEqual(a, b) {
|
|
|
286
295
|
}
|
|
287
296
|
function sortChildrenByPosition(children) {
|
|
288
297
|
return [...children].sort((a, b) => {
|
|
289
|
-
|
|
290
|
-
return ((_a = a.state.placement) == null ? void 0 : _a.y) - ((_b = b.state.placement) == null ? void 0 : _b.y) || ((_c = a.state.placement) == null ? void 0 : _c.x) - ((_d = b.state.placement) == null ? void 0 : _d.x);
|
|
298
|
+
return a.state.y - b.state.y || a.state.x - b.state.x;
|
|
291
299
|
});
|
|
292
300
|
}
|
|
293
301
|
function sortGridLayout(layout) {
|
|
294
302
|
return [...layout].sort((a, b) => a.y - b.y || a.x - b.x);
|
|
295
303
|
}
|
|
304
|
+
function isSceneGridRow(child) {
|
|
305
|
+
return child instanceof SceneGridRow;
|
|
306
|
+
}
|
|
307
|
+
function isSceneGridLayout(child) {
|
|
308
|
+
return child instanceof SceneGridLayout;
|
|
309
|
+
}
|
|
296
310
|
|
|
297
|
-
export { SceneGridLayout };
|
|
311
|
+
export { SceneGridItem, SceneGridLayout };
|
|
298
312
|
//# sourceMappingURL=SceneGridLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneGridLayout.js","sources":["../../../../../src/components/layout/grid/SceneGridLayout.tsx"],"sourcesContent":["import React from 'react';\nimport ReactGridLayout from 'react-grid-layout';\nimport AutoSizer from 'react-virtualized-auto-sizer';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport {\n SceneComponentProps,\n SceneLayout,\n SceneLayoutItemState,\n SceneObject,\n SceneObjectStatePlain,\n} from '../../../core/types';\nimport { DEFAULT_PANEL_SPAN, GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from './constants';\n\nimport { SceneGridRow } from './SceneGridRow';\nimport { SceneGridItemLike, SceneGridItemPlacement, SceneGridItemStateLike } from './types';\n\ninterface SceneGridLayoutState extends SceneObjectStatePlain {\n /**\n * Turn on or off dragging for all items. Indiviadual items can still disabled via isDraggable property\n **/\n isDraggable?: boolean;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> implements SceneLayout {\n public static Component = SceneGridLayoutRenderer;\n\n private _skipOnLayoutChange = false;\n\n public constructor(state: SceneGridLayoutState) {\n super({\n ...state,\n isDraggable: true,\n children: sortChildrenByPosition(state.children),\n });\n }\n\n /**\n * SceneLayout interface. Used for example by VizPanelRenderer\n */\n public isDraggable(): boolean {\n return this.state.isDraggable ?? false;\n }\n\n public getDragClass() {\n return `grid-drag-handle-${this.state.key}`;\n }\n\n public getDragClassCancel() {\n return `grid-drag-cancel`;\n }\n\n public toggleRow(row: SceneGridRow) {\n const isCollapsed = row.state.isCollapsed;\n\n if (!isCollapsed) {\n row.setState({ isCollapsed: true });\n // To force re-render\n this.setState({});\n return;\n }\n\n const rowChildren = row.state.children;\n\n if (rowChildren.length === 0) {\n row.setState({ isCollapsed: false });\n this.setState({});\n return;\n }\n\n // Ok we are expanding row. We need to update row children y pos (incase they are incorrect) and push items below down\n // Code copied from DashboardModel toggleRow()\n\n const rowY = row.state.y!;\n const firstPanelYPos = rowChildren[0].state.y ?? rowY;\n const yDiff = firstPanelYPos - (rowY + 1);\n\n // y max will represent the bottom y pos after all panels have been added\n // needed to know home much panels below should be pushed down\n let yMax = rowY;\n\n for (const panel of rowChildren) {\n // set the y gridPos if it wasn't already set\n const newSize = { ...panel.state };\n newSize.y = newSize.y ?? rowY;\n // make sure y is adjusted (in case row moved while collapsed)\n newSize.y -= yDiff;\n if (newSize.y! > panel.state.y!) {\n panel.setState(newSize);\n }\n // update insert post and y max\n yMax = Math.max(yMax, Number(newSize.y!) + Number(newSize.height!));\n }\n\n const pushDownAmount = yMax - rowY - 1;\n\n // push panels below down\n for (const child of this.state.children) {\n if (child.state.y! > rowY) {\n this.pushChildDown(child, pushDownAmount);\n }\n\n if (isSceneGridRow(child) && child !== row) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.y! > rowY) {\n this.pushChildDown(rowChild, pushDownAmount);\n }\n }\n }\n }\n\n row.setState({ isCollapsed: false });\n // Trigger re-render\n this.setState({});\n }\n\n public onLayoutChange = (layout: ReactGridLayout.Layout[]) => {\n if (this._skipOnLayoutChange) {\n // Layout has been updated by other RTL handler already\n this._skipOnLayoutChange = false;\n return;\n }\n\n for (const item of layout) {\n const child = this.getSceneLayoutChild(item.i);\n\n const nextSize: SceneGridItemPlacement = {\n x: item.x,\n y: item.y,\n width: item.w,\n height: item.h,\n };\n\n if (!isItemSizeEqual(child.state, nextSize)) {\n child.setState({\n ...nextSize,\n });\n }\n }\n\n this.setState({ children: sortChildrenByPosition(this.state.children) });\n };\n\n /**\n * Will also scan row children and return child of the row\n */\n public getSceneLayoutChild(key: string) {\n for (const child of this.state.children) {\n if (child.state.key === key) {\n return child;\n }\n\n if (child instanceof SceneGridRow) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.key === key) {\n return rowChild;\n }\n }\n }\n }\n\n throw new Error('Scene layout child not found for GridItem');\n }\n\n public onResizeStop: ReactGridLayout.ItemCallback = (_, o, n) => {\n const child = this.getSceneLayoutChild(n.i);\n child.setState({\n width: n.w,\n height: n.h,\n });\n };\n\n private pushChildDown(child: SceneGridItemLike, amount: number) {\n child.setState({\n y: child.state.y! + amount,\n });\n }\n\n /**\n * We assume the layout array is storted according to y pos, and walk upwards until we find a row.\n * If it is collapsed there is no row to add it to. The default is then to return the SceneGridLayout itself\n */\n private findGridItemSceneParent(layout: ReactGridLayout.Layout[], startAt: number): SceneGridRow | SceneGridLayout {\n for (let i = startAt; i >= 0; i--) {\n const gridItem = layout[i];\n const sceneChild = this.getSceneLayoutChild(gridItem.i);\n\n if (sceneChild instanceof SceneGridRow) {\n // the closest row is collapsed return null\n if (sceneChild.state.isCollapsed) {\n return this;\n }\n\n return sceneChild;\n }\n }\n\n return this;\n }\n\n /**\n * This likely needs a slighltly different approach. Where we clone or deactivate or and re-activate the moved child\n */\n public moveChildTo(child: SceneGridItemLike, target: SceneGridLayout | SceneGridRow) {\n const currentParent = child.parent!;\n let rootChildren = this.state.children;\n\n const newChild = child.clone({ key: child.state.key });\n\n // Remove from current parent row\n if (currentParent instanceof SceneGridRow) {\n const newRow = currentParent.clone({\n children: currentParent.state.children.filter((c) => c.state.key !== child.state.key),\n });\n\n // new children with new row\n rootChildren = rootChildren.map((c) => (c === currentParent ? newRow : c));\n\n // if target is also a row\n if (target instanceof SceneGridRow) {\n const targetRow = target.clone({ children: [...target.state.children, newChild] });\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n } else {\n // target is the main grid\n rootChildren = [...rootChildren, newChild];\n }\n } else {\n if (!(target instanceof SceneGridLayout)) {\n // current parent is the main grid remove it from there\n rootChildren = rootChildren.filter((c) => c.state.key !== child.state.key);\n // Clone the target row and add the child\n const targetRow = target.clone({ children: [...target.state.children, newChild] });\n // Replace row with new row\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n }\n }\n\n return rootChildren;\n }\n\n public onDragStop: ReactGridLayout.ItemCallback = (gridLayout, o, updatedItem) => {\n const sceneChild = this.getSceneLayoutChild(updatedItem.i)!;\n\n // Need to resort the grid layout based on new position (needed to to find the new parent)\n gridLayout = sortGridLayout(gridLayout);\n\n // Update children positions if they have changed\n for (let i = 0; i < gridLayout.length; i++) {\n const gridItem = gridLayout[i];\n const child = this.getSceneLayoutChild(gridItem.i)!;\n const childSize = child.state;\n\n if (childSize?.x !== gridItem.x || childSize?.y !== gridItem.y) {\n child.setState({\n x: gridItem.x,\n y: gridItem.y,\n });\n }\n }\n\n // Update the parent if the child if it has moved to a row or back to the grid\n const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);\n const newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);\n let newChildren = this.state.children;\n\n if (newParent !== sceneChild.parent) {\n newChildren = this.moveChildTo(sceneChild, newParent);\n }\n\n this.setState({ children: sortChildrenByPosition(newChildren) });\n this._skipOnLayoutChange = true;\n };\n\n private toGridCell(child: SceneGridItemLike): ReactGridLayout.Layout {\n const size = child.state;\n\n let x = size.x ?? 0;\n let y = size.y ?? 0;\n const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;\n const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;\n\n let isDraggable = Boolean(child.state.isDraggable);\n let isResizable = Boolean(child.state.isResizable);\n\n if (child instanceof SceneGridRow) {\n isDraggable = child.state.isCollapsed ? true : false;\n isResizable = false;\n }\n\n return { i: child.state.key!, x, y, h, w, isResizable, isDraggable };\n }\n\n public buildGridLayout(width: number): ReactGridLayout.Layout[] {\n let cells: ReactGridLayout.Layout[] = [];\n\n for (const child of this.state.children) {\n cells.push(this.toGridCell(child));\n\n if (child instanceof SceneGridRow && !child.state.isCollapsed) {\n for (const rowChild of child.state.children) {\n cells.push(this.toGridCell(rowChild));\n }\n }\n }\n\n // Sort by position\n cells = sortGridLayout(cells);\n\n if (width < 768) {\n // We should not persist the mobile layout\n this._skipOnLayoutChange = true;\n return cells.map((cell) => ({ ...cell, w: 24 }));\n }\n\n this._skipOnLayoutChange = false;\n\n return cells;\n }\n}\n\nfunction SceneGridLayoutRenderer({ model }: SceneComponentProps<SceneGridLayout>) {\n const { children } = model.useState();\n validateChildrenSize(children);\n\n return (\n <AutoSizer disableHeight>\n {({ width }) => {\n if (width === 0) {\n return null;\n }\n\n const layout = model.buildGridLayout(width);\n\n return (\n /**\n * The children is using a width of 100% so we need to guarantee that it is wrapped\n * in an element that has the calculated size given by the AutoSizer. The AutoSizer\n * has a width of 0 and will let its content overflow its div.\n */\n <div style={{ width: `${width}px`, height: '100%' }}>\n <ReactGridLayout\n width={width}\n /*\n Disable draggable if mobile device, solving an issue with unintentionally\n moving panels. https://github.com/grafana/grafana/issues/18497\n theme.breakpoints.md = 769\n */\n isDraggable={width > 768}\n isResizable={false}\n containerPadding={[0, 0]}\n useCSSTransforms={false}\n margin={[GRID_CELL_VMARGIN, GRID_CELL_VMARGIN]}\n cols={GRID_COLUMN_COUNT}\n rowHeight={GRID_CELL_HEIGHT}\n draggableHandle={`.grid-drag-handle-${model.state.key}`}\n draggableCancel=\".grid-drag-cancel\"\n // @ts-ignore: ignoring for now until we make the size type numbers-only\n layout={layout}\n onDragStop={model.onDragStop}\n onResizeStop={model.onResizeStop}\n onLayoutChange={model.onLayoutChange}\n isBounded={false}\n >\n {layout.map((gridItem) => {\n const sceneChild = model.getSceneLayoutChild(gridItem.i)!;\n return (\n <div key={sceneChild.state.key} style={{ display: 'flex' }}>\n <sceneChild.Component model={sceneChild} key={sceneChild.state.key} />\n </div>\n );\n })}\n </ReactGridLayout>\n </div>\n );\n }}\n </AutoSizer>\n );\n}\n\ninterface SceneGridItemState extends SceneGridItemStateLike, SceneLayoutItemState {}\n\nexport class SceneGridItem extends SceneObjectBase<SceneGridItemState> implements SceneGridItemLike {\n static Component = SceneGridItemRenderer;\n}\n\nfunction SceneGridItemRenderer({ model }: SceneComponentProps<SceneGridItem>) {\n const { body } = model.useState();\n const parent = model.parent;\n\n if (parent && !isSceneGridLayout(parent) && !isSceneGridRow(parent)) {\n throw new Error('SceneGridItem must be a child of SceneGridLayout or SceneGridRow');\n }\n\n if (!body) {\n return null;\n }\n\n return <body.Component model={body} />;\n}\n\nfunction validateChildrenSize(children: SceneGridItemLike[]) {\n if (\n children.find(\n (c) =>\n c.state.height === undefined ||\n c.state.width === undefined ||\n c.state.x === undefined ||\n c.state.y === undefined\n )\n ) {\n throw new Error('All children must have a size specified');\n }\n}\n\nfunction isItemSizeEqual(a: SceneGridItemPlacement, b: SceneGridItemPlacement) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\nfunction sortChildrenByPosition(children: SceneGridItemLike[]) {\n return [...children].sort((a, b) => {\n return a.state.y! - b.state.y! || a.state.x! - b.state.x!;\n });\n}\n\nfunction sortGridLayout(layout: ReactGridLayout.Layout[]) {\n return [...layout].sort((a, b) => a.y - b.y || a.x! - b.x);\n}\n\nfunction isSceneGridRow(child: SceneObject): child is SceneGridRow {\n return child instanceof SceneGridRow;\n}\n\nfunction isSceneGridLayout(child: SceneObject): child is SceneGridLayout {\n return child instanceof SceneGridLayout;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,gBAAA,GAAN,cAA8B,eAA6D,CAAA;AAAA,EAKzF,YAAY,KAA6B,EAAA;AAC9C,IAAA,KAAA,CAAM,iCACD,KADC,CAAA,EAAA;AAAA,MAEJ,WAAa,EAAA,IAAA;AAAA,MACb,QAAA,EAAU,sBAAuB,CAAA,KAAA,CAAM,QAAQ,CAAA;AAAA,KAChD,CAAA,CAAA,CAAA;AAPH,IAAA,IAAA,CAAQ,mBAAsB,GAAA,KAAA,CAAA;AAyF9B,IAAO,IAAA,CAAA,cAAA,GAAiB,CAAC,MAAqC,KAAA;AAC5D,MAAA,IAAI,KAAK,mBAAqB,EAAA;AAE5B,QAAA,IAAA,CAAK,mBAAsB,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,SAAS,kBAAkB,KAA8C,EAAA;AACvE,EAAA,OAAO,KAAiB,YAAA,eAAA,CAAA;AAC1B;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cx, css } from '@emotion/css';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useStyles2, Icon } from '@grafana/ui';
|
|
4
|
-
import { SceneObjectBase } from '
|
|
5
|
-
import { SceneObjectUrlSyncConfig } from '
|
|
6
|
-
import { SceneDragHandle } from '
|
|
4
|
+
import { SceneObjectBase } from '../../../core/SceneObjectBase.js';
|
|
5
|
+
import { SceneObjectUrlSyncConfig } from '../../../services/SceneObjectUrlSyncConfig.js';
|
|
6
|
+
import { SceneDragHandle } from '../../SceneDragHandle.js';
|
|
7
7
|
import { SceneGridLayout } from './SceneGridLayout.js';
|
|
8
8
|
import { GRID_COLUMN_COUNT } from './constants.js';
|
|
9
9
|
|
|
@@ -29,16 +29,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29
29
|
class SceneGridRow extends SceneObjectBase {
|
|
30
30
|
constructor(state) {
|
|
31
31
|
super(__spreadProps(__spreadValues({
|
|
32
|
-
|
|
32
|
+
children: state.children || [],
|
|
33
|
+
isCollapsible: state.isCollapsible || true,
|
|
34
|
+
title: state.title || "",
|
|
35
|
+
isDraggable: state.isDraggable || true,
|
|
36
|
+
isResizable: state.isResizable || false
|
|
33
37
|
}, state), {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, state.placement), {
|
|
38
|
-
x: 0,
|
|
39
|
-
height: 1,
|
|
40
|
-
width: GRID_COLUMN_COUNT
|
|
41
|
-
})
|
|
38
|
+
x: 0,
|
|
39
|
+
height: 1,
|
|
40
|
+
width: GRID_COLUMN_COUNT
|
|
42
41
|
}));
|
|
43
42
|
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["rowc"] });
|
|
44
43
|
this.onCollapseToggle = () => {
|
|
@@ -68,7 +67,7 @@ class SceneGridRow extends SceneObjectBase {
|
|
|
68
67
|
SceneGridRow.Component = SceneGridRowRenderer;
|
|
69
68
|
function SceneGridRowRenderer({ model }) {
|
|
70
69
|
const styles = useStyles2(getSceneGridRowStyles);
|
|
71
|
-
const { isCollapsible, isCollapsed, title,
|
|
70
|
+
const { isCollapsible, isCollapsed, title, isDraggable } = model.useState();
|
|
72
71
|
const dragHandle = /* @__PURE__ */ React.createElement(SceneDragHandle, {
|
|
73
72
|
dragClass: model.getGridLayout().getDragClass()
|
|
74
73
|
});
|
|
@@ -83,7 +82,7 @@ function SceneGridRowRenderer({ model }) {
|
|
|
83
82
|
name: isCollapsed ? "angle-right" : "angle-down"
|
|
84
83
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
85
84
|
className: styles.rowTitle
|
|
86
|
-
}, title)),
|
|
85
|
+
}, title)), isDraggable && isCollapsed && /* @__PURE__ */ React.createElement("div", null, dragHandle)));
|
|
87
86
|
}
|
|
88
87
|
const getSceneGridRowStyles = (theme) => {
|
|
89
88
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneGridRow.js","sources":["../../../../../src/components/layout/grid/SceneGridRow.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport React from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Icon, useStyles2 } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectUrlValues } from '../../../core/types';\nimport { SceneObjectUrlSyncConfig } from '../../../services/SceneObjectUrlSyncConfig';\nimport { SceneDragHandle } from '../../SceneDragHandle';\n\nimport { SceneGridLayout } from './SceneGridLayout';\nimport { GRID_COLUMN_COUNT } from './constants';\nimport { SceneGridItemLike, SceneGridItemStateLike } from './types';\n\nexport interface SceneGridRowState extends SceneGridItemStateLike {\n title: string;\n isCollapsible?: boolean;\n isCollapsed?: boolean;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridRow extends SceneObjectBase<SceneGridRowState> {\n public static Component = SceneGridRowRenderer;\n\n protected _urlSync = new SceneObjectUrlSyncConfig(this, { keys: ['rowc'] });\n\n public constructor(state: Partial<SceneGridRowState>) {\n super({\n children: state.children || [],\n isCollapsible: state.isCollapsible || true,\n title: state.title || '',\n isDraggable: state.isDraggable || true,\n isResizable: state.isResizable || false,\n ...state,\n x: 0,\n height: 1,\n width: GRID_COLUMN_COUNT,\n });\n }\n\n public getGridLayout(): SceneGridLayout {\n const layout = this.parent;\n\n if (!layout || !(layout instanceof SceneGridLayout)) {\n throw new Error('SceneGridRow must be a child of SceneGridLayout');\n }\n\n return layout;\n }\n\n public onCollapseToggle = () => {\n if (!this.state.isCollapsible) {\n return;\n }\n\n this.getGridLayout().toggleRow(this);\n };\n\n public getUrlState() {\n return { rowc: this.state.isCollapsed ? '1' : '0' };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const isCollapsed = values.rowc === '1';\n if (isCollapsed !== this.state.isCollapsed) {\n this.onCollapseToggle();\n }\n }\n}\n\nexport function SceneGridRowRenderer({ model }: SceneComponentProps<SceneGridRow>) {\n const styles = useStyles2(getSceneGridRowStyles);\n const { isCollapsible, isCollapsed, title, isDraggable } = model.useState();\n const dragHandle = <SceneDragHandle dragClass={model.getGridLayout().getDragClass()} />;\n\n return (\n <div className={styles.row}>\n <div className={cx(styles.rowHeader, isCollapsed && styles.rowHeaderCollapsed)}>\n <button onClick={model.onCollapseToggle} className={styles.rowTitleButton}>\n {isCollapsible && <Icon name={isCollapsed ? 'angle-right' : 'angle-down'} />}\n <span className={styles.rowTitle}>{title}</span>\n </button>\n {isDraggable && isCollapsed && <div>{dragHandle}</div>}\n </div>\n </div>\n );\n}\n\nconst getSceneGridRowStyles = (theme: GrafanaTheme2) => {\n return {\n row: css({\n width: '100%',\n height: '100%',\n position: 'relative',\n zIndex: 0,\n display: 'flex',\n flexDirection: 'column',\n }),\n rowHeader: css({\n width: '100%',\n height: '30px',\n display: 'flex',\n justifyContent: 'space-between',\n marginBottom: '8px',\n border: `1px solid transparent`,\n }),\n rowTitleButton: css({\n display: 'flex',\n alignItems: 'center',\n cursor: 'pointer',\n background: 'transparent',\n border: 'none',\n gap: theme.spacing(1),\n }),\n rowHeaderCollapsed: css({\n marginBottom: '0px',\n background: theme.colors.background.primary,\n border: `1px solid ${theme.colors.border.weak}`,\n borderRadius: theme.shape.borderRadius(1),\n }),\n rowTitle: css({\n fontSize: theme.typography.h5.fontSize,\n fontWeight: theme.typography.fontWeightMedium,\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,qBAAqB,eAAmC,CAAA;AAAA,EAK5D,YAAY,KAAmC,EAAA;AACpD,IAAM,KAAA,CAAA,aAAA,CAAA,cAAA,CAAA;AAAA,MACJ,QAAA,EAAU,KAAM,CAAA,QAAA,IAAY,EAAC;AAAA,MAC7B,aAAA,EAAe,MAAM,aAAiB,IAAA,IAAA;AAAA,MACtC,KAAA,EAAO,MAAM,KAAS,IAAA,EAAA;AAAA,MACtB,WAAA,EAAa,MAAM,WAAe,IAAA,IAAA;AAAA,MAClC,WAAA,EAAa,MAAM,WAAe,IAAA,KAAA;AAAA,KAAA,EAC/B,KANC,CAAA,EAAA;AAAA,MAOJ,CAAG,EAAA,CAAA;AAAA,MACH,MAAQ,EAAA,CAAA;AAAA,MACR,KAAO,EAAA,iBAAA;AAAA,KACR,CAAA,CAAA,CAAA;AAbH,IAAU,IAAA,CAAA,QAAA,GAAW,IAAI,wBAAyB,CAAA,IAAA,EAAM,EAAE,IAAM,EAAA,CAAC,MAAM,CAAA,EAAG,CAAA,CAAA;AA0B1E,IAAA,IAAA,CAAO,mBAAmB,MAAM;AAC9B,MAAI,IAAA,CAAC,IAAK,CAAA,KAAA,CAAM,aAAe,EAAA;AAC7B,QAAA,OAAA;AAAA,OACF;AAEA,MAAK,IAAA,CAAA,aAAA,EAAgB,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA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Z,MAAQ,EAAA,MAAA;AAAA,MACR,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,KACrB,CAAA;AAAA,IACD,oBAAoB,GAAI,CAAA;AAAA,MACtB,YAAc,EAAA,KAAA;AAAA,MACd,UAAA,EAAY,KAAM,CAAA,MAAA,CAAO,UAAW,CAAA,OAAA;AAAA,MACpC,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,IAAA,CAAA,CAAA;AAAA,MACzC,YAAc,EAAA,KAAA,CAAM,KAAM,CAAA,YAAA,CAAa,CAAC,CAAA;AAAA,KACzC,CAAA;AAAA,IACD,UAAU,GAAI,CAAA;AAAA,MACZ,QAAA,EAAU,KAAM,CAAA,UAAA,CAAW,EAAG,CAAA,QAAA;AAAA,MAC9B,UAAA,EAAY,MAAM,UAAW,CAAA,gBAAA;AAAA,KAC9B,CAAA;AAAA,GACH,CAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../src/components/layout/grid/constants.ts"],"sourcesContent":["export const DEFAULT_PANEL_SPAN = 4;\nexport const GRID_CELL_HEIGHT = 30;\nexport const GRID_CELL_VMARGIN = 8;\nexport const GRID_COLUMN_COUNT = 24;\n"],"names":[],"mappings":"AAAO,MAAM,kBAAqB,GAAA,EAAA;AAC3B,MAAM,gBAAmB,GAAA,GAAA;AACzB,MAAM,iBAAoB,GAAA,EAAA;AAC1B,MAAM,iBAAoB,GAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/core/types.ts"],"sourcesContent":["import React from 'react';\nimport { MonoTypeOperatorFunction, Unsubscribable } from 'rxjs';\n\nimport {\n BusEvent,\n BusEventHandler,\n BusEventType,\n DataFrame,\n DataTransformContext,\n PanelData,\n TimeRange,\n TimeZone,\n} from '@grafana/data';\n\nimport { SceneVariableDependencyConfigLike, SceneVariables } from '../variables/types';\n\nexport interface SceneObjectStatePlain {\n key?: string;\n $timeRange?: SceneTimeRangeLike;\n $data?: SceneDataProvider;\n $variables?: SceneVariables;\n}\n\nexport interface SceneLayoutChildState extends SceneObjectStatePlain {\n placement?: SceneLayoutChildOptions;\n}\n\nexport type SceneObjectState = SceneObjectStatePlain | SceneLayoutState | SceneLayoutChildState;\n\nexport interface SceneLayoutChildOptions {\n width?: number | string;\n height?: number | string;\n xSizing?: 'fill' | 'content';\n ySizing?: 'fill' | 'content';\n x?: number;\n y?: number;\n minWidth?: number | string;\n minHeight?: number | string;\n isDraggable?: boolean;\n isResizable?: boolean;\n}\n\nexport interface SceneComponentProps<T> {\n model: T;\n}\n\nexport interface SceneComponentWrapperProps {\n model: SceneObject;\n children: React.ReactNode;\n}\n\nexport type SceneComponent<TModel> = (props: SceneComponentProps<TModel>) => React.ReactElement | null;\nexport type SceneComponentCustomWrapper = (props: SceneComponentWrapperProps) => React.ReactElement | null;\n\nexport interface SceneDataState extends SceneObjectStatePlain {\n data?: PanelData;\n}\n\nexport interface SceneObject<TState extends SceneObjectState = SceneObjectState> {\n /** The current state */\n readonly state: TState;\n\n /** True when there is a React component mounted for this Object */\n readonly isActive: boolean;\n\n /** SceneObject parent */\n readonly parent?: SceneObject;\n\n /** This abtractions declares what variables the scene object depends on and how to handle when they change value. **/\n readonly variableDependency?: SceneVariableDependencyConfigLike;\n\n /** This abstraction declares URL sync dependencies of a scene object. **/\n readonly urlSync?: SceneObjectUrlSyncHandler;\n\n /** Subscribe to state changes */\n subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;\n\n /** Subscribe to a scene event */\n subscribeToEvent<T extends BusEvent>(typeFilter: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;\n\n /** Publish an event and optionally bubble it up the scene */\n publishEvent(event: BusEvent, bubble?: boolean): void;\n\n /** Utility hook that wraps useObservable. Used by React components to subscribes to state changes */\n useState(): TState;\n\n /** How to modify state */\n setState(state: Partial<TState>): void;\n\n /**\n * Called when the Component is mounted. This will also activate any $data, $variables or $timeRange scene object on this level.\n * Don't override this in your custom SceneObjects, instead use addActivationHandler from the constructor. The activation handler can return a deactivation handler.\n **/\n activate(): void;\n\n /** Called when component unmounts. This will also deactivate any $data, $variables or $timeRange scene object on this level.\n * Don't override this in your custom SceneObjects, instead use addActivationHandler from the constructor. The activation handler can return a deactivation handler.\n */\n deactivate(): void;\n\n /** Get the scene root */\n getRoot(): SceneObject;\n\n /** Returns a deep clone this object and all its children */\n clone(state?: Partial<TState>): this;\n\n /** A React component to use for rendering the object */\n Component(props: SceneComponentProps<SceneObject<TState>>): React.ReactElement | null;\n\n /** Force a re-render, should only be needed when variable values change */\n forceRender(): void;\n\n /**\n * Allows external code to register code that is executed on activate and deactivate. This allow you\n * to wire up scene objects that need to respond to state changes in other objects from the outside.\n **/\n addActivationHandler(handler: SceneActivationHandler): void;\n}\n\nexport type SceneActivationHandler = () => SceneDeactivationHandler | void;\nexport type SceneDeactivationHandler = () => void;\n\nexport type SceneLayoutChild = SceneObject<SceneLayoutChildState | SceneLayoutState>;\n\nexport interface SceneLayoutState extends SceneLayoutChildState {\n children:
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/core/types.ts"],"sourcesContent":["import React from 'react';\nimport { MonoTypeOperatorFunction, Unsubscribable } from 'rxjs';\n\nimport {\n BusEvent,\n BusEventHandler,\n BusEventType,\n DataFrame,\n DataTransformContext,\n PanelData,\n TimeRange,\n TimeZone,\n} from '@grafana/data';\n\nimport { SceneVariableDependencyConfigLike, SceneVariables } from '../variables/types';\n\nexport interface SceneObjectStatePlain {\n key?: string;\n $timeRange?: SceneTimeRangeLike;\n $data?: SceneDataProvider;\n $variables?: SceneVariables;\n}\n\nexport interface SceneLayoutChildState extends SceneObjectStatePlain {\n placement?: SceneLayoutChildOptions;\n}\n\nexport interface SceneLayoutItemState extends SceneObjectStatePlain {\n body: SceneObject | undefined;\n}\n\nexport type SceneObjectState = SceneObjectStatePlain | SceneLayoutState | SceneLayoutChildState;\n\nexport interface SceneLayoutChildOptions {\n width?: number | string;\n height?: number | string;\n xSizing?: 'fill' | 'content';\n ySizing?: 'fill' | 'content';\n x?: number;\n y?: number;\n minWidth?: number | string;\n minHeight?: number | string;\n isDraggable?: boolean;\n isResizable?: boolean;\n}\n\nexport interface SceneComponentProps<T> {\n model: T;\n}\n\nexport interface SceneComponentWrapperProps {\n model: SceneObject;\n children: React.ReactNode;\n}\n\nexport type SceneComponent<TModel> = (props: SceneComponentProps<TModel>) => React.ReactElement | null;\nexport type SceneComponentCustomWrapper = (props: SceneComponentWrapperProps) => React.ReactElement | null;\n\nexport interface SceneDataState extends SceneObjectStatePlain {\n data?: PanelData;\n}\n\nexport interface SceneObject<TState extends SceneObjectState = SceneObjectState> {\n /** The current state */\n readonly state: TState;\n\n /** True when there is a React component mounted for this Object */\n readonly isActive: boolean;\n\n /** SceneObject parent */\n readonly parent?: SceneObject;\n\n /** This abtractions declares what variables the scene object depends on and how to handle when they change value. **/\n readonly variableDependency?: SceneVariableDependencyConfigLike;\n\n /** This abstraction declares URL sync dependencies of a scene object. **/\n readonly urlSync?: SceneObjectUrlSyncHandler;\n\n /** Subscribe to state changes */\n subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;\n\n /** Subscribe to a scene event */\n subscribeToEvent<T extends BusEvent>(typeFilter: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;\n\n /** Publish an event and optionally bubble it up the scene */\n publishEvent(event: BusEvent, bubble?: boolean): void;\n\n /** Utility hook that wraps useObservable. Used by React components to subscribes to state changes */\n useState(): TState;\n\n /** How to modify state */\n setState(state: Partial<TState>): void;\n\n /**\n * Called when the Component is mounted. This will also activate any $data, $variables or $timeRange scene object on this level.\n * Don't override this in your custom SceneObjects, instead use addActivationHandler from the constructor. The activation handler can return a deactivation handler.\n **/\n activate(): void;\n\n /** Called when component unmounts. This will also deactivate any $data, $variables or $timeRange scene object on this level.\n * Don't override this in your custom SceneObjects, instead use addActivationHandler from the constructor. The activation handler can return a deactivation handler.\n */\n deactivate(): void;\n\n /** Get the scene root */\n getRoot(): SceneObject;\n\n /** Returns a deep clone this object and all its children */\n clone(state?: Partial<TState>): this;\n\n /** A React component to use for rendering the object */\n Component(props: SceneComponentProps<SceneObject<TState>>): React.ReactElement | null;\n\n /** Force a re-render, should only be needed when variable values change */\n forceRender(): void;\n\n /**\n * Allows external code to register code that is executed on activate and deactivate. This allow you\n * to wire up scene objects that need to respond to state changes in other objects from the outside.\n **/\n addActivationHandler(handler: SceneActivationHandler): void;\n}\n\nexport type SceneActivationHandler = () => SceneDeactivationHandler | void;\nexport type SceneDeactivationHandler = () => void;\n\nexport type SceneLayoutChild = SceneObject<SceneLayoutChildState | SceneLayoutState>;\n\nexport interface SceneLayoutState extends SceneLayoutChildState {\n children: SceneObject[];\n}\n\nexport interface SceneLayout<T extends SceneLayoutState = SceneLayoutState> extends SceneObject<T> {\n isDraggable(): boolean;\n getDragClass?(): string;\n getDragClassCancel?(): string;\n}\n\nexport interface SceneTimeRangeState extends SceneObjectStatePlain {\n from: string;\n to: string;\n timeZone: TimeZone;\n fiscalYearStartMonth?: number;\n value: TimeRange;\n}\n\nexport interface SceneTimeRangeLike extends SceneObject<SceneTimeRangeState> {\n onTimeRangeChange(timeRange: TimeRange): void;\n onRefresh(): void;\n}\n\nexport interface SceneObjectRef {\n ref: SceneObject;\n}\n\nexport function isSceneObject(obj: any): obj is SceneObject {\n return obj.useState !== undefined;\n}\n\nexport interface SceneObjectWithUrlSync extends SceneObject {\n getUrlState(): SceneObjectUrlValues;\n updateFromUrl(values: SceneObjectUrlValues): void;\n}\n\nexport interface SceneObjectUrlSyncHandler {\n getKeys(): string[];\n getUrlState(): SceneObjectUrlValues;\n updateFromUrl(values: SceneObjectUrlValues): void;\n}\n\nexport type SceneObjectUrlValue = string | string[] | undefined | null;\nexport type SceneObjectUrlValues = Record<string, SceneObjectUrlValue>;\n\nexport type CustomTransformOperator = (context: DataTransformContext) => MonoTypeOperatorFunction<DataFrame[]>;\nexport type SceneStateChangedHandler<TState> = (newState: TState, prevState: TState) => void;\n\nexport type DeepPartial<T> = {\n [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];\n};\n\nexport interface SceneDataProvider extends SceneObject<SceneDataState> {\n setContainerWidth?: (width: number) => void;\n}\n"],"names":[],"mappings":"AA2JO,SAAS,cAAc,GAA8B,EAAA;AAC1D,EAAA,OAAO,IAAI,QAAa,KAAA,KAAA,CAAA,CAAA;AAC1B;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { SceneQueryRunner } from './querying/SceneQueryRunner.js';
|
|
|
8
8
|
export { SceneDataTransformer } from './querying/SceneDataTransformer.js';
|
|
9
9
|
export { SceneVariableValueChangedEvent, isCustomVariableValue } from './variables/types.js';
|
|
10
10
|
export { VariableDependencyConfig } from './variables/VariableDependencyConfig.js';
|
|
11
|
-
export {
|
|
11
|
+
export { formatRegistry } from './variables/interpolation/formatRegistry.js';
|
|
12
12
|
export { VariableValueSelectors } from './variables/components/VariableValueSelectors.js';
|
|
13
13
|
export { SceneVariableSet } from './variables/sets/SceneVariableSet.js';
|
|
14
14
|
export { ConstantVariable } from './variables/variants/ConstantVariable.js';
|
|
@@ -29,9 +29,9 @@ export { SceneTimePicker } from './components/SceneTimePicker.js';
|
|
|
29
29
|
export { SceneRefreshPicker } from './components/SceneRefreshPicker.js';
|
|
30
30
|
export { SceneByFrameRepeater } from './components/SceneByFrameRepeater.js';
|
|
31
31
|
export { SceneControlsSpacer } from './components/SceneControlsSpacer.js';
|
|
32
|
-
export { SceneFlexLayout } from './components/layout/SceneFlexLayout.js';
|
|
33
|
-
export { SceneGridLayout } from './components/layout/SceneGridLayout.js';
|
|
34
|
-
export { SceneGridRow } from './components/layout/SceneGridRow.js';
|
|
32
|
+
export { SceneFlexItem, SceneFlexLayout } from './components/layout/SceneFlexLayout.js';
|
|
33
|
+
export { SceneGridItem, SceneGridLayout } from './components/layout/grid/SceneGridLayout.js';
|
|
34
|
+
export { SceneGridRow } from './components/layout/grid/SceneGridRow.js';
|
|
35
35
|
export { SceneApp } from './components/SceneApp/SceneApp.js';
|
|
36
36
|
export { SceneAppPage } from './components/SceneApp/SceneAppPage.js';
|
|
37
37
|
export { SceneReactObject } from './components/SceneReactObject.js';
|
|
@@ -1,29 +1,11 @@
|
|
|
1
1
|
import { map, isArray, replace } from 'lodash';
|
|
2
2
|
import { Registry, escapeRegex, textUtil, dateTime } from '@grafana/data';
|
|
3
|
+
import { VariableFormatID } from '@grafana/schema';
|
|
3
4
|
|
|
4
|
-
var FormatRegistryID = /* @__PURE__ */ ((FormatRegistryID2) => {
|
|
5
|
-
FormatRegistryID2["lucene"] = "lucene";
|
|
6
|
-
FormatRegistryID2["raw"] = "raw";
|
|
7
|
-
FormatRegistryID2["regex"] = "regex";
|
|
8
|
-
FormatRegistryID2["pipe"] = "pipe";
|
|
9
|
-
FormatRegistryID2["distributed"] = "distributed";
|
|
10
|
-
FormatRegistryID2["csv"] = "csv";
|
|
11
|
-
FormatRegistryID2["html"] = "html";
|
|
12
|
-
FormatRegistryID2["json"] = "json";
|
|
13
|
-
FormatRegistryID2["percentEncode"] = "percentencode";
|
|
14
|
-
FormatRegistryID2["singleQuote"] = "singlequote";
|
|
15
|
-
FormatRegistryID2["doubleQuote"] = "doublequote";
|
|
16
|
-
FormatRegistryID2["sqlString"] = "sqlstring";
|
|
17
|
-
FormatRegistryID2["date"] = "date";
|
|
18
|
-
FormatRegistryID2["glob"] = "glob";
|
|
19
|
-
FormatRegistryID2["text"] = "text";
|
|
20
|
-
FormatRegistryID2["queryParam"] = "queryparam";
|
|
21
|
-
return FormatRegistryID2;
|
|
22
|
-
})(FormatRegistryID || {});
|
|
23
5
|
const formatRegistry = new Registry(() => {
|
|
24
6
|
const formats = [
|
|
25
7
|
{
|
|
26
|
-
id:
|
|
8
|
+
id: VariableFormatID.Lucene,
|
|
27
9
|
name: "Lucene",
|
|
28
10
|
description: "Values are lucene escaped and multi-valued variables generate an OR expression",
|
|
29
11
|
formatter: (value) => {
|
|
@@ -44,13 +26,13 @@ const formatRegistry = new Registry(() => {
|
|
|
44
26
|
}
|
|
45
27
|
},
|
|
46
28
|
{
|
|
47
|
-
id:
|
|
29
|
+
id: VariableFormatID.Raw,
|
|
48
30
|
name: "raw",
|
|
49
31
|
description: "Keep value as is",
|
|
50
32
|
formatter: (value) => String(value)
|
|
51
33
|
},
|
|
52
34
|
{
|
|
53
|
-
id:
|
|
35
|
+
id: VariableFormatID.Regex,
|
|
54
36
|
name: "Regex",
|
|
55
37
|
description: "Values are regex escaped and multi-valued variables generate a (<value>|<value>) expression",
|
|
56
38
|
formatter: (value) => {
|
|
@@ -74,7 +56,7 @@ const formatRegistry = new Registry(() => {
|
|
|
74
56
|
}
|
|
75
57
|
},
|
|
76
58
|
{
|
|
77
|
-
id:
|
|
59
|
+
id: VariableFormatID.Pipe,
|
|
78
60
|
name: "Pipe",
|
|
79
61
|
description: "Values are separated by | character",
|
|
80
62
|
formatter: (value) => {
|
|
@@ -88,7 +70,7 @@ const formatRegistry = new Registry(() => {
|
|
|
88
70
|
}
|
|
89
71
|
},
|
|
90
72
|
{
|
|
91
|
-
id:
|
|
73
|
+
id: VariableFormatID.Distributed,
|
|
92
74
|
name: "Distributed",
|
|
93
75
|
description: "Multiple values are formatted like variable=value",
|
|
94
76
|
formatter: (value, args, variable) => {
|
|
@@ -109,7 +91,7 @@ const formatRegistry = new Registry(() => {
|
|
|
109
91
|
}
|
|
110
92
|
},
|
|
111
93
|
{
|
|
112
|
-
id:
|
|
94
|
+
id: VariableFormatID.CSV,
|
|
113
95
|
name: "Csv",
|
|
114
96
|
description: "Comma-separated values",
|
|
115
97
|
formatter: (value) => {
|
|
@@ -123,7 +105,7 @@ const formatRegistry = new Registry(() => {
|
|
|
123
105
|
}
|
|
124
106
|
},
|
|
125
107
|
{
|
|
126
|
-
id:
|
|
108
|
+
id: VariableFormatID.HTML,
|
|
127
109
|
name: "HTML",
|
|
128
110
|
description: "HTML escaping of values",
|
|
129
111
|
formatter: (value) => {
|
|
@@ -137,7 +119,7 @@ const formatRegistry = new Registry(() => {
|
|
|
137
119
|
}
|
|
138
120
|
},
|
|
139
121
|
{
|
|
140
|
-
id:
|
|
122
|
+
id: VariableFormatID.JSON,
|
|
141
123
|
name: "JSON",
|
|
142
124
|
description: "JSON stringify value",
|
|
143
125
|
formatter: (value) => {
|
|
@@ -148,7 +130,7 @@ const formatRegistry = new Registry(() => {
|
|
|
148
130
|
}
|
|
149
131
|
},
|
|
150
132
|
{
|
|
151
|
-
id:
|
|
133
|
+
id: VariableFormatID.PercentEncode,
|
|
152
134
|
name: "Percent encode",
|
|
153
135
|
description: "Useful for URL escaping values",
|
|
154
136
|
formatter: (value) => {
|
|
@@ -159,7 +141,7 @@ const formatRegistry = new Registry(() => {
|
|
|
159
141
|
}
|
|
160
142
|
},
|
|
161
143
|
{
|
|
162
|
-
id:
|
|
144
|
+
id: VariableFormatID.SingleQuote,
|
|
163
145
|
name: "Single quote",
|
|
164
146
|
description: "Single quoted values",
|
|
165
147
|
formatter: (value) => {
|
|
@@ -172,7 +154,7 @@ const formatRegistry = new Registry(() => {
|
|
|
172
154
|
}
|
|
173
155
|
},
|
|
174
156
|
{
|
|
175
|
-
id:
|
|
157
|
+
id: VariableFormatID.DoubleQuote,
|
|
176
158
|
name: "Double quote",
|
|
177
159
|
description: "Double quoted values",
|
|
178
160
|
formatter: (value) => {
|
|
@@ -185,7 +167,7 @@ const formatRegistry = new Registry(() => {
|
|
|
185
167
|
}
|
|
186
168
|
},
|
|
187
169
|
{
|
|
188
|
-
id:
|
|
170
|
+
id: VariableFormatID.SQLString,
|
|
189
171
|
name: "SQL string",
|
|
190
172
|
description: "SQL string quoting and commas for use in IN statements and other scenarios",
|
|
191
173
|
formatter: (value) => {
|
|
@@ -198,7 +180,7 @@ const formatRegistry = new Registry(() => {
|
|
|
198
180
|
}
|
|
199
181
|
},
|
|
200
182
|
{
|
|
201
|
-
id:
|
|
183
|
+
id: VariableFormatID.Date,
|
|
202
184
|
name: "Date",
|
|
203
185
|
description: "Format date in different ways",
|
|
204
186
|
formatter: (value, args) => {
|
|
@@ -229,7 +211,7 @@ const formatRegistry = new Registry(() => {
|
|
|
229
211
|
}
|
|
230
212
|
},
|
|
231
213
|
{
|
|
232
|
-
id:
|
|
214
|
+
id: VariableFormatID.Glob,
|
|
233
215
|
name: "Glob",
|
|
234
216
|
description: "Format multi-valued variables using glob syntax, example {value1,value2}",
|
|
235
217
|
formatter: (value) => {
|
|
@@ -240,7 +222,7 @@ const formatRegistry = new Registry(() => {
|
|
|
240
222
|
}
|
|
241
223
|
},
|
|
242
224
|
{
|
|
243
|
-
id:
|
|
225
|
+
id: VariableFormatID.Text,
|
|
244
226
|
name: "Text",
|
|
245
227
|
description: "Format variables in their text representation. Example in multi-variable scenario A + B + C.",
|
|
246
228
|
formatter: (value, _args, variable) => {
|
|
@@ -251,7 +233,7 @@ const formatRegistry = new Registry(() => {
|
|
|
251
233
|
}
|
|
252
234
|
},
|
|
253
235
|
{
|
|
254
|
-
id:
|
|
236
|
+
id: VariableFormatID.QueryParam,
|
|
255
237
|
name: "Query parameter",
|
|
256
238
|
description: "Format variables as URL parameters. Example in multi-variable scenario A + B + C => var-foo=A&var-foo=B&var-foo=C.",
|
|
257
239
|
formatter: (value, _args, variable) => {
|
|
@@ -282,5 +264,5 @@ function formatQueryParameter(name, value) {
|
|
|
282
264
|
return `var-${name}=${encodeURIComponentStrict(value)}`;
|
|
283
265
|
}
|
|
284
266
|
|
|
285
|
-
export {
|
|
267
|
+
export { formatRegistry };
|
|
286
268
|
//# sourceMappingURL=formatRegistry.js.map
|