@grafana/scenes 0.0.1
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/LICENSE +661 -0
- package/README.md +26 -0
- package/dist/esm/components/NestedScene.js +119 -0
- package/dist/esm/components/NestedScene.js.map +1 -0
- package/dist/esm/components/Scene.js +39 -0
- package/dist/esm/components/Scene.js.map +1 -0
- package/dist/esm/components/SceneCanvasText.js +41 -0
- package/dist/esm/components/SceneCanvasText.js.map +1 -0
- package/dist/esm/components/SceneDragHandle.js +18 -0
- package/dist/esm/components/SceneDragHandle.js.map +1 -0
- package/dist/esm/components/ScenePanelRepeater.js +66 -0
- package/dist/esm/components/ScenePanelRepeater.js.map +1 -0
- package/dist/esm/components/SceneSubMenu.js +18 -0
- package/dist/esm/components/SceneSubMenu.js.map +1 -0
- package/dist/esm/components/SceneTimePicker.js +40 -0
- package/dist/esm/components/SceneTimePicker.js.map +1 -0
- package/dist/esm/components/SceneToolbarButton.js +28 -0
- package/dist/esm/components/SceneToolbarButton.js.map +1 -0
- package/dist/esm/components/VizPanel/VizPanel.js +105 -0
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -0
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +76 -0
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -0
- package/dist/esm/components/layout/SceneFlexLayout.js +88 -0
- package/dist/esm/components/layout/SceneFlexLayout.js.map +1 -0
- package/dist/esm/components/layout/SceneGridLayout.js +288 -0
- package/dist/esm/components/layout/SceneGridLayout.js.map +1 -0
- package/dist/esm/components/layout/SceneGridRow.js +124 -0
- package/dist/esm/components/layout/SceneGridRow.js.map +1 -0
- package/dist/esm/components/layout/constants.js +7 -0
- package/dist/esm/components/layout/constants.js.map +1 -0
- package/dist/esm/core/SceneComponentWrapper.js +84 -0
- package/dist/esm/core/SceneComponentWrapper.js.map +1 -0
- package/dist/esm/core/SceneDataNode.js +7 -0
- package/dist/esm/core/SceneDataNode.js.map +1 -0
- package/dist/esm/core/SceneDataTransformer.js +51 -0
- package/dist/esm/core/SceneDataTransformer.js.map +1 -0
- package/dist/esm/core/SceneObjectBase.js +141 -0
- package/dist/esm/core/SceneObjectBase.js.map +1 -0
- package/dist/esm/core/SceneTimeRange.js +108 -0
- package/dist/esm/core/SceneTimeRange.js.map +1 -0
- package/dist/esm/core/events.js +8 -0
- package/dist/esm/core/events.js.map +1 -0
- package/dist/esm/core/sceneGraph.js +68 -0
- package/dist/esm/core/sceneGraph.js.map +1 -0
- package/dist/esm/core/types.js +6 -0
- package/dist/esm/core/types.js.map +1 -0
- package/dist/esm/core/utils.js +57 -0
- package/dist/esm/core/utils.js.map +1 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/querying/SceneQueryRunner.js +161 -0
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -0
- package/dist/esm/services/SceneObjectUrlSyncConfig.js +18 -0
- package/dist/esm/services/SceneObjectUrlSyncConfig.js.map +1 -0
- package/dist/esm/services/UrlSyncManager.js +133 -0
- package/dist/esm/services/UrlSyncManager.js.map +1 -0
- package/dist/esm/utils/metricTree.js +53 -0
- package/dist/esm/utils/metricTree.js.map +1 -0
- package/dist/esm/variables/VariableDependencyConfig.js +86 -0
- package/dist/esm/variables/VariableDependencyConfig.js.map +1 -0
- package/dist/esm/variables/components/VariableValueSelect.js +58 -0
- package/dist/esm/variables/components/VariableValueSelect.js.map +1 -0
- package/dist/esm/variables/components/VariableValueSelectors.js +56 -0
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -0
- package/dist/esm/variables/constants.js +6 -0
- package/dist/esm/variables/constants.js.map +1 -0
- package/dist/esm/variables/interpolation/ScopedVarsVariable.js +49 -0
- package/dist/esm/variables/interpolation/ScopedVarsVariable.js.map +1 -0
- package/dist/esm/variables/interpolation/defaults.js +17 -0
- package/dist/esm/variables/interpolation/defaults.js.map +1 -0
- package/dist/esm/variables/interpolation/formatRegistry.js +280 -0
- package/dist/esm/variables/interpolation/formatRegistry.js.map +1 -0
- package/dist/esm/variables/interpolation/sceneInterpolator.js +83 -0
- package/dist/esm/variables/interpolation/sceneInterpolator.js.map +1 -0
- package/dist/esm/variables/sets/SceneVariableSet.js +123 -0
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -0
- package/dist/esm/variables/types.js +8 -0
- package/dist/esm/variables/types.js.map +1 -0
- package/dist/esm/variables/variants/ConstantVariable.js +33 -0
- package/dist/esm/variables/variants/ConstantVariable.js.map +1 -0
- package/dist/esm/variables/variants/CustomVariable.js +58 -0
- package/dist/esm/variables/variants/CustomVariable.js.map +1 -0
- package/dist/esm/variables/variants/DataSourceVariable.js +92 -0
- package/dist/esm/variables/variants/DataSourceVariable.js.map +1 -0
- package/dist/esm/variables/variants/MultiValueVariable.js +183 -0
- package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -0
- package/dist/esm/variables/variants/TestVariable.js +81 -0
- package/dist/esm/variables/variants/TestVariable.js.map +1 -0
- package/dist/esm/variables/variants/query/QueryVariable.js +137 -0
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -0
- package/dist/esm/variables/variants/query/createQueryVariableRunner.js +93 -0
- package/dist/esm/variables/variants/query/createQueryVariableRunner.js.map +1 -0
- package/dist/esm/variables/variants/query/guards.js +18 -0
- package/dist/esm/variables/variants/query/guards.js.map +1 -0
- package/dist/esm/variables/variants/query/toMetricFindValues.js +93 -0
- package/dist/esm/variables/variants/query/toMetricFindValues.js.map +1 -0
- package/dist/esm/variables/variants/query/utils.js +93 -0
- package/dist/esm/variables/variants/query/utils.js.map +1 -0
- package/dist/index.d.ts +796 -0
- package/dist/index.js +3356 -0
- package/dist/index.js.map +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useMeasure } from 'react-use';
|
|
3
|
+
import { useFieldOverrides, PluginContextProvider } from '@grafana/data';
|
|
4
|
+
import { getAppEvents } from '@grafana/runtime';
|
|
5
|
+
import { useTheme2, PanelChrome, ErrorBoundaryAlert } from '@grafana/ui';
|
|
6
|
+
import { sceneGraph } from '../../core/sceneGraph.js';
|
|
7
|
+
import { SceneQueryRunner } from '../../querying/SceneQueryRunner.js';
|
|
8
|
+
import { SceneDragHandle } from '../SceneDragHandle.js';
|
|
9
|
+
|
|
10
|
+
function VizPanelRenderer({ model }) {
|
|
11
|
+
var _a;
|
|
12
|
+
const theme = useTheme2();
|
|
13
|
+
const replace = useMemo(
|
|
14
|
+
() => (value, scoped) => sceneGraph.interpolate(model, value, scoped),
|
|
15
|
+
[model]
|
|
16
|
+
);
|
|
17
|
+
const { title, options, fieldConfig, pluginId, pluginLoadError, $data, placement } = model.useState();
|
|
18
|
+
const [ref, { width, height }] = useMeasure();
|
|
19
|
+
const plugin = model.getPlugin();
|
|
20
|
+
const { data } = sceneGraph.getData(model).useState();
|
|
21
|
+
const parentLayout = sceneGraph.getLayout(model);
|
|
22
|
+
const isDraggable = ((_a = parentLayout.state.placement) == null ? void 0 : _a.isDraggable) ? placement == null ? void 0 : placement.isDraggable : false;
|
|
23
|
+
const dragHandle = /* @__PURE__ */ React.createElement(SceneDragHandle, {
|
|
24
|
+
layoutKey: parentLayout.state.key
|
|
25
|
+
});
|
|
26
|
+
const titleInterpolated = sceneGraph.interpolate(model, title);
|
|
27
|
+
const timeZone = sceneGraph.getTimeRange(model).state.timeZone;
|
|
28
|
+
const dataWithOverrides = useFieldOverrides(plugin, fieldConfig, data, timeZone, theme, replace);
|
|
29
|
+
if (pluginLoadError) {
|
|
30
|
+
return /* @__PURE__ */ React.createElement("div", null, "Failed to load plugin: ", pluginLoadError);
|
|
31
|
+
}
|
|
32
|
+
if (!plugin || !plugin.hasPluginId(pluginId)) {
|
|
33
|
+
return /* @__PURE__ */ React.createElement("div", null, "Loading plugin panel...");
|
|
34
|
+
}
|
|
35
|
+
if (!plugin.panel) {
|
|
36
|
+
return /* @__PURE__ */ React.createElement("div", null, "Panel plugin has no panel component");
|
|
37
|
+
}
|
|
38
|
+
const PanelComponent = plugin.panel;
|
|
39
|
+
if ($data instanceof SceneQueryRunner) {
|
|
40
|
+
$data.setContainerWidth(width);
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
43
|
+
ref,
|
|
44
|
+
style: { position: "absolute", width: "100%", height: "100%" }
|
|
45
|
+
}, /* @__PURE__ */ React.createElement(PanelChrome, {
|
|
46
|
+
title: titleInterpolated,
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
leftItems: isDraggable ? [dragHandle] : void 0
|
|
50
|
+
}, (innerWidth, innerHeight) => /* @__PURE__ */ React.createElement(React.Fragment, null, !dataWithOverrides && /* @__PURE__ */ React.createElement("div", null, "No data..."), dataWithOverrides && /* @__PURE__ */ React.createElement(ErrorBoundaryAlert, {
|
|
51
|
+
dependencies: [plugin, data]
|
|
52
|
+
}, /* @__PURE__ */ React.createElement(PluginContextProvider, {
|
|
53
|
+
meta: plugin.meta
|
|
54
|
+
}, /* @__PURE__ */ React.createElement(PanelComponent, {
|
|
55
|
+
id: 1,
|
|
56
|
+
data: dataWithOverrides,
|
|
57
|
+
title,
|
|
58
|
+
timeRange: dataWithOverrides.timeRange,
|
|
59
|
+
timeZone,
|
|
60
|
+
options,
|
|
61
|
+
fieldConfig,
|
|
62
|
+
transparent: false,
|
|
63
|
+
width: innerWidth,
|
|
64
|
+
height: innerHeight,
|
|
65
|
+
renderCounter: 0,
|
|
66
|
+
replaceVariables: (str) => str,
|
|
67
|
+
onOptionsChange: model.onOptionsChange,
|
|
68
|
+
onFieldConfigChange: model.onFieldConfigChange,
|
|
69
|
+
onChangeTimeRange: model.onChangeTimeRange,
|
|
70
|
+
eventBus: getAppEvents()
|
|
71
|
+
}))))));
|
|
72
|
+
}
|
|
73
|
+
VizPanelRenderer.displayName = "ScenePanelRenderer";
|
|
74
|
+
|
|
75
|
+
export { VizPanelRenderer };
|
|
76
|
+
//# sourceMappingURL=VizPanelRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VizPanelRenderer.js","sources":["../../../../src/components/VizPanel/VizPanelRenderer.tsx"],"sourcesContent":["import React, { RefCallback, useMemo } from 'react';\nimport { useMeasure } from 'react-use';\n\nimport { PluginContextProvider, useFieldOverrides, ScopedVars } from '@grafana/data';\nimport { getAppEvents } from '@grafana/runtime';\nimport { PanelChrome, ErrorBoundaryAlert, useTheme2 } from '@grafana/ui';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { SceneComponentProps } from '../../core/types';\nimport { SceneQueryRunner } from '../../querying/SceneQueryRunner';\nimport { SceneDragHandle } from '../SceneDragHandle';\n\nimport { VizPanel } from './VizPanel';\n\nexport function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>) {\n const theme = useTheme2();\n const replace = useMemo(\n () => (value: string, scoped?: ScopedVars) => sceneGraph.interpolate(model, value, scoped),\n [model]\n );\n const { title, options, fieldConfig, pluginId, pluginLoadError, $data, placement } = model.useState();\n const [ref, { width, height }] = useMeasure();\n const plugin = model.getPlugin();\n const { data } = sceneGraph.getData(model).useState();\n const parentLayout = sceneGraph.getLayout(model);\n\n // TODO: this should probably be parentLayout.isDraggingEnabled() ? placement?.isDraggable : false\n // The current logic is not correct, just because parent layout itself is not draggable does not mean children are not\n const isDraggable = parentLayout.state.placement?.isDraggable ? placement?.isDraggable : false;\n const dragHandle = <SceneDragHandle layoutKey={parentLayout.state.key!} />;\n\n const titleInterpolated = sceneGraph.interpolate(model, title);\n\n // Not sure we need to subscribe to this state\n const timeZone = sceneGraph.getTimeRange(model).state.timeZone;\n\n const dataWithOverrides = useFieldOverrides(plugin, fieldConfig, data, timeZone, theme, replace);\n\n if (pluginLoadError) {\n return <div>Failed to load plugin: {pluginLoadError}</div>;\n }\n\n if (!plugin || !plugin.hasPluginId(pluginId)) {\n return <div>Loading plugin panel...</div>;\n }\n\n if (!plugin.panel) {\n return <div>Panel plugin has no panel component</div>;\n }\n\n const PanelComponent = plugin.panel;\n\n // Query runner needs to with for auto maxDataPoints\n if ($data instanceof SceneQueryRunner) {\n $data.setContainerWidth(width);\n }\n\n return (\n <div ref={ref as RefCallback<HTMLDivElement>} style={{ position: 'absolute', width: '100%', height: '100%' }}>\n <PanelChrome\n title={titleInterpolated}\n width={width}\n height={height}\n leftItems={isDraggable ? [dragHandle] : undefined}\n >\n {(innerWidth, innerHeight) => (\n <>\n {!dataWithOverrides && <div>No data...</div>}\n {dataWithOverrides && (\n <ErrorBoundaryAlert dependencies={[plugin, data]}>\n <PluginContextProvider meta={plugin.meta}>\n <PanelComponent\n id={1}\n data={dataWithOverrides}\n title={title}\n timeRange={dataWithOverrides.timeRange}\n timeZone={timeZone}\n options={options}\n fieldConfig={fieldConfig}\n transparent={false}\n width={innerWidth}\n height={innerHeight}\n renderCounter={0}\n replaceVariables={(str: string) => str}\n onOptionsChange={model.onOptionsChange}\n onFieldConfigChange={model.onFieldConfigChange}\n onChangeTimeRange={model.onChangeTimeRange}\n eventBus={getAppEvents()}\n />\n </PluginContextProvider>\n </ErrorBoundaryAlert>\n )}\n </>\n )}\n </PanelChrome>\n </div>\n );\n}\n\nVizPanelRenderer.displayName = 'ScenePanelRenderer';\n"],"names":[],"mappings":";;;;;;;;;AAcgB,SAAA,gBAAA,CAAiB,EAAE,KAAA,EAAwC,EAAA;AAd3E,EAAA,IAAA,EAAA,CAAA;AAeE,EAAA,MAAM,QAAQ,SAAU,EAAA,CAAA;AACxB,EAAA,MAAM,OAAU,GAAA,OAAA;AAAA,IACd,MAAM,CAAC,KAAe,EAAA,MAAA,KAAwB,WAAW,WAAY,CAAA,KAAA,EAAO,OAAO,MAAM,CAAA;AAAA,IACzF,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AACA,EAAM,MAAA,EAAE,KAAO,EAAA,OAAA,EAAS,WAAa,EAAA,QAAA,EAAU,iBAAiB,KAAO,EAAA,SAAA,EAAc,GAAA,KAAA,CAAM,QA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;AAAA,IACA,WAAa,EAAA,KAAA;AAAA,IACb,KAAO,EAAA,UAAA;AAAA,IACP,MAAQ,EAAA,WAAA;AAAA,IACR,aAAe,EAAA,CAAA;AAAA,IACf,gBAAA,EAAkB,CAAC,GAAgB,KAAA,GAAA;AAAA,IACnC,iBAAiB,KAAM,CAAA,eAAA;AAAA,IACvB,qBAAqB,KAAM,CAAA,mBAAA;AAAA,IAC3B,mBAAmB,KAAM,CAAA,iBAAA;AAAA,IACzB,UAAU,YAAa,EAAA;AAAA,GACzB,CACF,CACF,CAEJ,CAEJ,CACF,CAAA,CAAA;AAEJ,CAAA;AAEA,gBAAA,CAAiB,WAAc,GAAA,oBAAA;;;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Field, RadioButtonGroup } from '@grafana/ui';
|
|
3
|
+
import { SceneObjectBase } from '../../core/SceneObjectBase.js';
|
|
4
|
+
|
|
5
|
+
class SceneFlexLayout extends SceneObjectBase {
|
|
6
|
+
toggleDirection() {
|
|
7
|
+
this.setState({
|
|
8
|
+
direction: this.state.direction === "row" ? "column" : "row"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
SceneFlexLayout.Component = FlexLayoutRenderer;
|
|
13
|
+
SceneFlexLayout.Editor = FlexLayoutEditor;
|
|
14
|
+
function FlexLayoutRenderer({ model, isEditing }) {
|
|
15
|
+
const { direction = "row", children } = model.useState();
|
|
16
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
17
|
+
style: { flexGrow: 1, flexDirection: direction, display: "flex", gap: "8px" }
|
|
18
|
+
}, children.map((item) => /* @__PURE__ */ React.createElement(FlexLayoutChildComponent, {
|
|
19
|
+
key: item.state.key,
|
|
20
|
+
item,
|
|
21
|
+
direction,
|
|
22
|
+
isEditing
|
|
23
|
+
})));
|
|
24
|
+
}
|
|
25
|
+
function FlexLayoutChildComponent({
|
|
26
|
+
item,
|
|
27
|
+
direction,
|
|
28
|
+
isEditing
|
|
29
|
+
}) {
|
|
30
|
+
const { placement } = item.useState();
|
|
31
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
32
|
+
style: getItemStyles(direction, placement)
|
|
33
|
+
}, /* @__PURE__ */ React.createElement(item.Component, {
|
|
34
|
+
model: item,
|
|
35
|
+
isEditing
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function getItemStyles(direction, layout = {}) {
|
|
39
|
+
const { xSizing = "fill", ySizing = "fill" } = layout;
|
|
40
|
+
const style = {
|
|
41
|
+
display: "flex",
|
|
42
|
+
flexDirection: direction,
|
|
43
|
+
minWidth: layout.minWidth,
|
|
44
|
+
minHeight: layout.minHeight,
|
|
45
|
+
position: "relative"
|
|
46
|
+
};
|
|
47
|
+
if (direction === "column") {
|
|
48
|
+
if (layout.height) {
|
|
49
|
+
style.height = layout.height;
|
|
50
|
+
} else {
|
|
51
|
+
style.flexGrow = ySizing === "fill" ? 1 : 0;
|
|
52
|
+
}
|
|
53
|
+
if (layout.width) {
|
|
54
|
+
style.width = layout.width;
|
|
55
|
+
} else {
|
|
56
|
+
style.alignSelf = xSizing === "fill" ? "stretch" : "flex-start";
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
if (layout.height) {
|
|
60
|
+
style.height = layout.height;
|
|
61
|
+
} else {
|
|
62
|
+
style.alignSelf = ySizing === "fill" ? "stretch" : "flex-start";
|
|
63
|
+
}
|
|
64
|
+
if (layout.width) {
|
|
65
|
+
style.width = layout.width;
|
|
66
|
+
} else {
|
|
67
|
+
style.flexGrow = xSizing === "fill" ? 1 : 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return style;
|
|
71
|
+
}
|
|
72
|
+
function FlexLayoutEditor({ model }) {
|
|
73
|
+
const { direction = "row" } = model.useState();
|
|
74
|
+
const options = [
|
|
75
|
+
{ icon: "arrow-right", value: "row" },
|
|
76
|
+
{ icon: "arrow-down", value: "column" }
|
|
77
|
+
];
|
|
78
|
+
return /* @__PURE__ */ React.createElement(Field, {
|
|
79
|
+
label: "Direction"
|
|
80
|
+
}, /* @__PURE__ */ React.createElement(RadioButtonGroup, {
|
|
81
|
+
options,
|
|
82
|
+
value: direction,
|
|
83
|
+
onChange: (value) => model.setState({ direction: value })
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { SceneFlexLayout };
|
|
88
|
+
//# sourceMappingURL=SceneFlexLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneFlexLayout.js","sources":["../../../../src/components/layout/SceneFlexLayout.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\n\nimport { Field, RadioButtonGroup } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneLayoutChild, SceneLayoutState, SceneLayoutChildOptions } from '../../core/types';\n\nexport type FlexLayoutDirection = 'column' | 'row';\n\ninterface SceneFlexLayoutState extends SceneLayoutState {\n direction?: FlexLayoutDirection;\n}\n\nexport class SceneFlexLayout extends SceneObjectBase<SceneFlexLayoutState> {\n public static Component = FlexLayoutRenderer;\n public static Editor = FlexLayoutEditor;\n\n public toggleDirection() {\n this.setState({\n direction: this.state.direction === 'row' ? 'column' : 'row',\n });\n }\n}\n\nfunction FlexLayoutRenderer({ model, isEditing }: SceneComponentProps<SceneFlexLayout>) {\n const { direction = 'row', children } = model.useState();\n\n return (\n <div style={{ flexGrow: 1, flexDirection: direction, display: 'flex', gap: '8px' }}>\n {children.map((item) => (\n <FlexLayoutChildComponent key={item.state.key} item={item} direction={direction} isEditing={isEditing} />\n ))}\n </div>\n );\n}\n\nfunction FlexLayoutChildComponent({\n item,\n direction,\n isEditing,\n}: {\n item: SceneLayoutChild;\n direction: FlexLayoutDirection;\n isEditing?: boolean;\n}) {\n const { placement } = item.useState();\n\n return (\n <div style={getItemStyles(direction, placement)}>\n <item.Component model={item} isEditing={isEditing} />\n </div>\n );\n}\n\nfunction getItemStyles(direction: FlexLayoutDirection, layout: SceneLayoutChildOptions = {}) {\n const { xSizing = 'fill', ySizing = 'fill' } = layout;\n\n const style: CSSProperties = {\n display: 'flex',\n flexDirection: direction,\n minWidth: layout.minWidth,\n minHeight: layout.minHeight,\n position: 'relative',\n };\n\n if (direction === 'column') {\n if (layout.height) {\n style.height = layout.height;\n } else {\n style.flexGrow = ySizing === 'fill' ? 1 : 0;\n }\n\n if (layout.width) {\n style.width = layout.width;\n } else {\n style.alignSelf = xSizing === 'fill' ? 'stretch' : 'flex-start';\n }\n } else {\n if (layout.height) {\n style.height = layout.height;\n } else {\n style.alignSelf = ySizing === 'fill' ? 'stretch' : 'flex-start';\n }\n\n if (layout.width) {\n style.width = layout.width;\n } else {\n style.flexGrow = xSizing === 'fill' ? 1 : 0;\n }\n }\n\n return style;\n}\n\nfunction FlexLayoutEditor({ model }: SceneComponentProps<SceneFlexLayout>) {\n const { direction = 'row' } = model.useState();\n const options = [\n { icon: 'arrow-right', value: 'row' },\n { icon: 'arrow-down', value: 'column' },\n ];\n\n return (\n <Field label=\"Direction\">\n <RadioButtonGroup\n options={options}\n value={direction}\n onChange={(value) => model.setState({ direction: value as FlexLayoutDirection })}\n />\n </Field>\n );\n}\n"],"names":[],"mappings":";;;;AAaO,MAAM,wBAAwB,eAAsC,CAAA;AAAA,EAIlE,eAAkB,GAAA;AACvB,IAAA,IAAA,CAAK,QAAS,CAAA;AAAA,MACZ,SAAW,EAAA,IAAA,CAAK,KAAM,CAAA,SAAA,KAAc,QAAQ,QAAW,GAAA,KAAA;AAAA,KACxD,CAAA,CAAA;AAAA,GACH;AACF,CAAA;AATa,eAAA,CACG,SAAY,GAAA,kBAAA,CAAA;AADf,eAAA,CAEG,MAAS,GAAA,gBAAA,CAAA;AASzB,SAAS,kBAAmB,CAAA,EAAE,KAAO,EAAA,SAAA,EAAmD,EAAA;AACtF,EAAA,MAAM,EAAE,SAAY,GAAA,KAAA,EAAO,QAAS,EAAA,GAAI,MAA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A;AAAA,GACxC,CAAA;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAM,KAAM,EAAA,WAAA;AAAA,GAAA,kBACV,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA;AAAA,IACC,OAAA;AAAA,IACA,KAAO,EAAA,SAAA;AAAA,IACP,QAAA,EAAU,CAAC,KAAU,KAAA,KAAA,CAAM,SAAS,EAAE,SAAA,EAAW,OAA8B,CAAA;AAAA,GACjF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactGridLayout from 'react-grid-layout';
|
|
3
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
4
|
+
import { SceneObjectBase } from '../../core/SceneObjectBase.js';
|
|
5
|
+
import { DEFAULT_PANEL_SPAN, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT, GRID_CELL_HEIGHT } from './constants.js';
|
|
6
|
+
import { SceneGridRow } from './SceneGridRow.js';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __defProps = Object.defineProperties;
|
|
10
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
11
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
class SceneGridLayout extends SceneObjectBase {
|
|
28
|
+
constructor(state) {
|
|
29
|
+
super(__spreadProps(__spreadValues({}, state), {
|
|
30
|
+
placement: __spreadValues({
|
|
31
|
+
isDraggable: true
|
|
32
|
+
}, state.placement),
|
|
33
|
+
children: sortChildrenByPosition(state.children)
|
|
34
|
+
}));
|
|
35
|
+
this._skipOnLayoutChange = false;
|
|
36
|
+
this.onLayoutChange = (layout) => {
|
|
37
|
+
if (this._skipOnLayoutChange) {
|
|
38
|
+
this._skipOnLayoutChange = false;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (const item of layout) {
|
|
42
|
+
const child = this.getSceneLayoutChild(item.i);
|
|
43
|
+
const nextSize = {
|
|
44
|
+
x: item.x,
|
|
45
|
+
y: item.y,
|
|
46
|
+
width: item.w,
|
|
47
|
+
height: item.h
|
|
48
|
+
};
|
|
49
|
+
if (!isItemSizeEqual(child.state.placement, nextSize)) {
|
|
50
|
+
child.setState({
|
|
51
|
+
placement: __spreadValues(__spreadValues({}, child.state.placement), nextSize)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.setState({ children: sortChildrenByPosition(this.state.children) });
|
|
56
|
+
};
|
|
57
|
+
this.onResizeStop = (_, o, n) => {
|
|
58
|
+
const child = this.getSceneLayoutChild(n.i);
|
|
59
|
+
child.setState({
|
|
60
|
+
placement: __spreadProps(__spreadValues({}, child.state.placement), {
|
|
61
|
+
width: n.w,
|
|
62
|
+
height: n.h
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
this.onDragStop = (gridLayout, o, updatedItem) => {
|
|
67
|
+
const sceneChild = this.getSceneLayoutChild(updatedItem.i);
|
|
68
|
+
gridLayout = sortGridLayout(gridLayout);
|
|
69
|
+
for (let i = 0; i < gridLayout.length; i++) {
|
|
70
|
+
const gridItem = gridLayout[i];
|
|
71
|
+
const child = this.getSceneLayoutChild(gridItem.i);
|
|
72
|
+
const childSize = child.state.placement;
|
|
73
|
+
if ((childSize == null ? void 0 : childSize.x) !== gridItem.x || (childSize == null ? void 0 : childSize.y) !== gridItem.y) {
|
|
74
|
+
child.setState({
|
|
75
|
+
placement: __spreadProps(__spreadValues({}, child.state.placement), {
|
|
76
|
+
x: gridItem.x,
|
|
77
|
+
y: gridItem.y
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);
|
|
83
|
+
const newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);
|
|
84
|
+
let newChildren = this.state.children;
|
|
85
|
+
if (newParent !== sceneChild.parent) {
|
|
86
|
+
newChildren = this.moveChildTo(sceneChild, newParent);
|
|
87
|
+
}
|
|
88
|
+
this.setState({ children: sortChildrenByPosition(newChildren) });
|
|
89
|
+
this._skipOnLayoutChange = true;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
toggleRow(row) {
|
|
93
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
94
|
+
const isCollapsed = row.state.isCollapsed;
|
|
95
|
+
if (!isCollapsed) {
|
|
96
|
+
row.setState({ isCollapsed: true });
|
|
97
|
+
this.setState({});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const rowChildren = row.state.children;
|
|
101
|
+
if (rowChildren.length === 0) {
|
|
102
|
+
row.setState({ isCollapsed: false });
|
|
103
|
+
this.setState({});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const rowY = (_a = row.state.placement) == null ? void 0 : _a.y;
|
|
107
|
+
const firstPanelYPos = (_c = (_b = rowChildren[0].state.placement) == null ? void 0 : _b.y) != null ? _c : rowY;
|
|
108
|
+
const yDiff = firstPanelYPos - (rowY + 1);
|
|
109
|
+
let yMax = rowY;
|
|
110
|
+
for (const panel of rowChildren) {
|
|
111
|
+
const newSize = __spreadValues({}, panel.state.placement);
|
|
112
|
+
newSize.y = (_d = newSize.y) != null ? _d : rowY;
|
|
113
|
+
newSize.y -= yDiff;
|
|
114
|
+
if (newSize.y > ((_e = panel.state.placement) == null ? void 0 : _e.y)) {
|
|
115
|
+
panel.setState({ placement: newSize });
|
|
116
|
+
}
|
|
117
|
+
yMax = Math.max(yMax, Number(newSize.y) + Number(newSize.height));
|
|
118
|
+
}
|
|
119
|
+
const pushDownAmount = yMax - rowY - 1;
|
|
120
|
+
for (const child of this.state.children) {
|
|
121
|
+
if (((_f = child.state.placement) == null ? void 0 : _f.y) > rowY) {
|
|
122
|
+
this.pushChildDown(child, pushDownAmount);
|
|
123
|
+
}
|
|
124
|
+
if (child instanceof SceneGridRow && child !== row) {
|
|
125
|
+
for (const rowChild of child.state.children) {
|
|
126
|
+
if (((_g = rowChild.state.placement) == null ? void 0 : _g.y) > rowY) {
|
|
127
|
+
this.pushChildDown(rowChild, pushDownAmount);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
row.setState({ isCollapsed: false });
|
|
133
|
+
this.setState({});
|
|
134
|
+
}
|
|
135
|
+
getSceneLayoutChild(key) {
|
|
136
|
+
for (const child of this.state.children) {
|
|
137
|
+
if (child.state.key === key) {
|
|
138
|
+
return child;
|
|
139
|
+
}
|
|
140
|
+
if (child instanceof SceneGridRow) {
|
|
141
|
+
for (const rowChild of child.state.children) {
|
|
142
|
+
if (rowChild.state.key === key) {
|
|
143
|
+
return rowChild;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
throw new Error("Scene layout child not found for GridItem");
|
|
149
|
+
}
|
|
150
|
+
pushChildDown(child, amount) {
|
|
151
|
+
var _a;
|
|
152
|
+
child.setState({
|
|
153
|
+
placement: __spreadProps(__spreadValues({}, child.state.placement), {
|
|
154
|
+
y: ((_a = child.state.placement) == null ? void 0 : _a.y) + amount
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
findGridItemSceneParent(layout, startAt) {
|
|
159
|
+
for (let i = startAt; i >= 0; i--) {
|
|
160
|
+
const gridItem = layout[i];
|
|
161
|
+
const sceneChild = this.getSceneLayoutChild(gridItem.i);
|
|
162
|
+
if (sceneChild instanceof SceneGridRow) {
|
|
163
|
+
if (sceneChild.state.isCollapsed) {
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
return sceneChild;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
moveChildTo(child, target) {
|
|
172
|
+
const currentParent = child.parent;
|
|
173
|
+
let rootChildren = this.state.children;
|
|
174
|
+
const newChild = child.clone({ key: child.state.key });
|
|
175
|
+
if (currentParent instanceof SceneGridRow) {
|
|
176
|
+
const newRow = currentParent.clone({
|
|
177
|
+
children: currentParent.state.children.filter((c) => c.state.key !== child.state.key)
|
|
178
|
+
});
|
|
179
|
+
rootChildren = rootChildren.map((c) => c === currentParent ? newRow : c);
|
|
180
|
+
if (target instanceof SceneGridRow) {
|
|
181
|
+
const targetRow = target.clone({ children: [...target.state.children, newChild] });
|
|
182
|
+
rootChildren = rootChildren.map((c) => c === target ? targetRow : c);
|
|
183
|
+
} else {
|
|
184
|
+
rootChildren = [...rootChildren, newChild];
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
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
|
+
}
|
|
191
|
+
return rootChildren;
|
|
192
|
+
}
|
|
193
|
+
toGridCell(child) {
|
|
194
|
+
var _a, _b, _c, _d;
|
|
195
|
+
const size = child.state.placement;
|
|
196
|
+
let x = (_a = size.x) != null ? _a : 0;
|
|
197
|
+
let y = (_b = size.y) != null ? _b : 0;
|
|
198
|
+
const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;
|
|
199
|
+
const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;
|
|
200
|
+
let isDraggable = Boolean((_c = child.state.placement) == null ? void 0 : _c.isDraggable);
|
|
201
|
+
let isResizable = Boolean((_d = child.state.placement) == null ? void 0 : _d.isResizable);
|
|
202
|
+
if (child instanceof SceneGridRow) {
|
|
203
|
+
isDraggable = child.state.isCollapsed ? true : false;
|
|
204
|
+
isResizable = false;
|
|
205
|
+
}
|
|
206
|
+
return { i: child.state.key, x, y, h, w, isResizable, isDraggable };
|
|
207
|
+
}
|
|
208
|
+
buildGridLayout(width) {
|
|
209
|
+
let cells = [];
|
|
210
|
+
for (const child of this.state.children) {
|
|
211
|
+
cells.push(this.toGridCell(child));
|
|
212
|
+
if (child instanceof SceneGridRow && !child.state.isCollapsed) {
|
|
213
|
+
for (const rowChild of child.state.children) {
|
|
214
|
+
cells.push(this.toGridCell(rowChild));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
cells = sortGridLayout(cells);
|
|
219
|
+
if (width < 768) {
|
|
220
|
+
this._skipOnLayoutChange = true;
|
|
221
|
+
return cells.map((cell) => __spreadProps(__spreadValues({}, cell), { w: 24 }));
|
|
222
|
+
}
|
|
223
|
+
this._skipOnLayoutChange = false;
|
|
224
|
+
return cells;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
SceneGridLayout.Component = SceneGridLayoutRenderer;
|
|
228
|
+
function SceneGridLayoutRenderer({ model }) {
|
|
229
|
+
const { children } = model.useState();
|
|
230
|
+
validateChildrenSize(children);
|
|
231
|
+
return /* @__PURE__ */ React.createElement(AutoSizer, {
|
|
232
|
+
disableHeight: true
|
|
233
|
+
}, ({ width }) => {
|
|
234
|
+
if (width === 0) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const layout = model.buildGridLayout(width);
|
|
238
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
239
|
+
style: { width: `${width}px`, height: "100%" }
|
|
240
|
+
}, /* @__PURE__ */ React.createElement(ReactGridLayout, {
|
|
241
|
+
width,
|
|
242
|
+
isDraggable: width > 768,
|
|
243
|
+
isResizable: false,
|
|
244
|
+
containerPadding: [0, 0],
|
|
245
|
+
useCSSTransforms: false,
|
|
246
|
+
margin: [GRID_CELL_VMARGIN, GRID_CELL_VMARGIN],
|
|
247
|
+
cols: GRID_COLUMN_COUNT,
|
|
248
|
+
rowHeight: GRID_CELL_HEIGHT,
|
|
249
|
+
draggableHandle: `.grid-drag-handle-${model.state.key}`,
|
|
250
|
+
layout,
|
|
251
|
+
onDragStop: model.onDragStop,
|
|
252
|
+
onResizeStop: model.onResizeStop,
|
|
253
|
+
onLayoutChange: model.onLayoutChange,
|
|
254
|
+
isBounded: false
|
|
255
|
+
}, layout.map((gridItem) => {
|
|
256
|
+
const sceneChild = model.getSceneLayoutChild(gridItem.i);
|
|
257
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
258
|
+
key: sceneChild.state.key,
|
|
259
|
+
style: { display: "flex" }
|
|
260
|
+
}, /* @__PURE__ */ React.createElement(sceneChild.Component, {
|
|
261
|
+
model: sceneChild,
|
|
262
|
+
key: sceneChild.state.key
|
|
263
|
+
}));
|
|
264
|
+
})));
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function validateChildrenSize(children) {
|
|
268
|
+
if (children.find(
|
|
269
|
+
(c) => !c.state.placement || c.state.placement.height === void 0 || c.state.placement.width === void 0 || c.state.placement.x === void 0 || c.state.placement.y === void 0
|
|
270
|
+
)) {
|
|
271
|
+
throw new Error("All children must have a size specified");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function isItemSizeEqual(a, b) {
|
|
275
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
276
|
+
}
|
|
277
|
+
function sortChildrenByPosition(children) {
|
|
278
|
+
return [...children].sort((a, b) => {
|
|
279
|
+
var _a, _b, _c, _d;
|
|
280
|
+
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);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function sortGridLayout(layout) {
|
|
284
|
+
return [...layout].sort((a, b) => a.y - b.y || a.x - b.x);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { SceneGridLayout };
|
|
288
|
+
//# sourceMappingURL=SceneGridLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneGridLayout.js","sources":["../../../../src/components/layout/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 { SceneComponentProps, SceneLayoutChild, SceneLayoutState, SceneLayoutChildOptions } from '../../core/types';\nimport { DEFAULT_PANEL_SPAN, GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from './constants';\n\nimport { SceneGridRow } from './SceneGridRow';\n\ninterface SceneGridLayoutState extends SceneLayoutState {}\n\nexport class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> {\n public static Component = SceneGridLayoutRenderer;\n\n private _skipOnLayoutChange = false;\n\n public constructor(state: SceneGridLayoutState) {\n super({\n ...state,\n placement: {\n isDraggable: true,\n ...state.placement,\n },\n children: sortChildrenByPosition(state.children),\n });\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.placement?.y!;\n const firstPanelYPos = rowChildren[0].state.placement?.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.placement };\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.placement?.y!) {\n panel.setState({ placement: 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.placement?.y! > rowY) {\n this.pushChildDown(child, pushDownAmount);\n }\n\n if (child instanceof SceneGridRow && child !== row) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.placement?.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 = {\n x: item.x,\n y: item.y,\n width: item.w,\n height: item.h,\n };\n\n if (!isItemSizeEqual(child.state.placement!, nextSize)) {\n child.setState({\n placement: {\n ...child.state.placement,\n ...nextSize,\n },\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 placement: {\n ...child.state.placement,\n width: n.w,\n height: n.h,\n },\n });\n };\n\n private pushChildDown(child: SceneLayoutChild, amount: number) {\n child.setState({\n placement: {\n ...child.state.placement,\n y: child.state.placement?.y! + amount,\n },\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: SceneLayoutChild, target: SceneGridLayout | SceneGridRow) {\n const currentParent = child.parent!;\n let rootChildren = this.state.children;\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 // 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 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.placement!;\n\n if (childSize?.x !== gridItem.x || childSize?.y !== gridItem.y) {\n child.setState({\n placement: {\n ...child.state.placement,\n x: gridItem.x,\n y: gridItem.y,\n },\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: SceneLayoutChild): ReactGridLayout.Layout {\n const size = child.state.placement!;\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.placement?.isDraggable);\n let isResizable = Boolean(child.state.placement?.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 // @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\nfunction validateChildrenSize(children: SceneLayoutChild[]) {\n if (\n children.find(\n (c) =>\n !c.state.placement ||\n c.state.placement.height === undefined ||\n c.state.placement.width === undefined ||\n c.state.placement.x === undefined ||\n c.state.placement.y === undefined\n )\n ) {\n throw new Error('All children must have a size specified');\n }\n}\n\nfunction isItemSizeEqual(a: SceneLayoutChildOptions, b: SceneLayoutChildOptions) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\nfunction sortChildrenByPosition(children: SceneLayoutChild[]) {\n return [...children].sort((a, b) => {\n return a.state.placement?.y! - b.state.placement?.y! || a.state.placement?.x! - b.state.placement?.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"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAYO,MAAM,wBAAwB,eAAsC,CAAA;AAAA,EAKlE,YAAY,KAA6B,EAAA;AAC9C,IAAA,KAAA,CAAM,iCACD,KADC,CAAA,EAAA;AAAA,MAEJ,SAAW,EAAA,cAAA,CAAA;AAAA,QACT,WAAa,EAAA,IAAA;AAAA,OAAA,EACV,KAAM,CAAA,SAAA,CAAA;AAAA,MAEX,QAAA,EAAU,sBAAuB,CAAA,KAAA,CAAM,QAAQ,CAAA;AAAA,KAChD,CAAA,CAAA,CAAA;AAVH,IAAA,IAAA,CAAQ,mBAAsB,GAAA,KAAA,CAAA;AA6E9B,IAAO,IAAA,CAAA,cAAA,GAAiB,CAAC,MAAqC,KAAA;AAC5D,MAAA,IAAI,KAAK,mBAAqB,EAAA;AAE5B,QAAA,IAAA,CAAK,mBAAsB,GAAA,KAAA,CAAA;AAC3B,QAAA,OAAA;AAAA,OACF;AAEA,MAAA,KAAA,MAAW,QAAQ,MAAQ,EAAA;AACzB,QAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,mBAAoB,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,CAAA,EAAG,CAAM,KAAA,CAAA,CAAE,IAAI,CAAE,CAAA,CAAA,IAAK,CAAE,CAAA,CAAA,GAAK,EAAE,CAAC,CAAA,CAAA;AAC3D;;;;"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { cx, css } from '@emotion/css';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useStyles2, Icon } from '@grafana/ui';
|
|
4
|
+
import { SceneObjectBase } from '../../core/SceneObjectBase.js';
|
|
5
|
+
import { sceneGraph } from '../../core/sceneGraph.js';
|
|
6
|
+
import { SceneObjectUrlSyncConfig } from '../../services/SceneObjectUrlSyncConfig.js';
|
|
7
|
+
import { SceneDragHandle } from '../SceneDragHandle.js';
|
|
8
|
+
import { SceneGridLayout } from './SceneGridLayout.js';
|
|
9
|
+
import { GRID_COLUMN_COUNT } from './constants.js';
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __defProps = Object.defineProperties;
|
|
13
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
14
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
+
var __spreadValues = (a, b) => {
|
|
19
|
+
for (var prop in b || (b = {}))
|
|
20
|
+
if (__hasOwnProp.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
if (__getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
+
if (__propIsEnum.call(b, prop))
|
|
25
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
|
+
}
|
|
27
|
+
return a;
|
|
28
|
+
};
|
|
29
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
30
|
+
class SceneGridRow extends SceneObjectBase {
|
|
31
|
+
constructor(state) {
|
|
32
|
+
super(__spreadProps(__spreadValues({
|
|
33
|
+
isCollapsible: true
|
|
34
|
+
}, state), {
|
|
35
|
+
placement: __spreadProps(__spreadValues({
|
|
36
|
+
isResizable: false,
|
|
37
|
+
isDraggable: true
|
|
38
|
+
}, state.placement), {
|
|
39
|
+
x: 0,
|
|
40
|
+
height: 1,
|
|
41
|
+
width: GRID_COLUMN_COUNT
|
|
42
|
+
})
|
|
43
|
+
}));
|
|
44
|
+
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["rowc"] });
|
|
45
|
+
this.onCollapseToggle = () => {
|
|
46
|
+
if (!this.state.isCollapsible) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const layout = this.parent;
|
|
50
|
+
if (!layout || !(layout instanceof SceneGridLayout)) {
|
|
51
|
+
throw new Error("SceneGridRow must be a child of SceneGridLayout");
|
|
52
|
+
}
|
|
53
|
+
layout.toggleRow(this);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
getUrlState(state) {
|
|
57
|
+
return { rowc: state.isCollapsed ? "1" : "0" };
|
|
58
|
+
}
|
|
59
|
+
updateFromUrl(values) {
|
|
60
|
+
const isCollapsed = values.rowc === "1";
|
|
61
|
+
if (isCollapsed !== this.state.isCollapsed) {
|
|
62
|
+
this.onCollapseToggle();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
SceneGridRow.Component = SceneGridRowRenderer;
|
|
67
|
+
function SceneGridRowRenderer({ model }) {
|
|
68
|
+
const styles = useStyles2(getSceneGridRowStyles);
|
|
69
|
+
const { isCollapsible, isCollapsed, title, placement } = model.useState();
|
|
70
|
+
const layout = sceneGraph.getLayout(model);
|
|
71
|
+
const dragHandle = /* @__PURE__ */ React.createElement(SceneDragHandle, {
|
|
72
|
+
layoutKey: layout.state.key
|
|
73
|
+
});
|
|
74
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
75
|
+
className: styles.row
|
|
76
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
77
|
+
className: cx(styles.rowHeader, isCollapsed && styles.rowHeaderCollapsed)
|
|
78
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
79
|
+
onClick: model.onCollapseToggle,
|
|
80
|
+
className: styles.rowTitleWrapper
|
|
81
|
+
}, isCollapsible && /* @__PURE__ */ React.createElement(Icon, {
|
|
82
|
+
name: isCollapsed ? "angle-right" : "angle-down"
|
|
83
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
84
|
+
className: styles.rowTitle
|
|
85
|
+
}, title)), (placement == null ? void 0 : placement.isDraggable) && isCollapsed && /* @__PURE__ */ React.createElement("div", null, dragHandle)));
|
|
86
|
+
}
|
|
87
|
+
const getSceneGridRowStyles = (theme) => {
|
|
88
|
+
return {
|
|
89
|
+
row: css({
|
|
90
|
+
width: "100%",
|
|
91
|
+
height: "100%",
|
|
92
|
+
position: "relative",
|
|
93
|
+
zIndex: 0,
|
|
94
|
+
display: "flex",
|
|
95
|
+
flexDirection: "column"
|
|
96
|
+
}),
|
|
97
|
+
rowHeader: css({
|
|
98
|
+
width: "100%",
|
|
99
|
+
height: "30px",
|
|
100
|
+
display: "flex",
|
|
101
|
+
justifyContent: "space-between",
|
|
102
|
+
marginBottom: "8px",
|
|
103
|
+
border: `1px solid transparent`
|
|
104
|
+
}),
|
|
105
|
+
rowTitleWrapper: css({
|
|
106
|
+
display: "flex",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
cursor: "pointer"
|
|
109
|
+
}),
|
|
110
|
+
rowHeaderCollapsed: css({
|
|
111
|
+
marginBottom: "0px",
|
|
112
|
+
background: theme.colors.background.primary,
|
|
113
|
+
border: `1px solid ${theme.colors.border.weak}`,
|
|
114
|
+
borderRadius: theme.shape.borderRadius(1)
|
|
115
|
+
}),
|
|
116
|
+
rowTitle: css({
|
|
117
|
+
fontSize: theme.typography.h6.fontSize,
|
|
118
|
+
fontWeight: theme.typography.h6.fontWeight
|
|
119
|
+
})
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { SceneGridRow, SceneGridRowRenderer };
|
|
124
|
+
//# sourceMappingURL=SceneGridRow.js.map
|