@grafana/scenes 6.1.1--canary.1059.13459243901.0 → 6.1.2--canary.967.13496758912.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
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v6.1.1 (Mon Feb 24 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- SceneGridLayout: Allow to hook into `onDragStart` event [#1059](https://github.com/grafana/scenes/pull/1059) ([@bfmatei](https://github.com/bfmatei))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Bogdan Matei ([@bfmatei](https://github.com/bfmatei))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v6.1.0 (Thu Feb 20 2025)
|
|
2
14
|
|
|
3
15
|
#### 🚀 Enhancement
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SceneObjectBase } from '../SceneObjectBase.js';
|
|
2
2
|
import { SceneObjectRef } from '../SceneObjectRef.js';
|
|
3
|
+
import { cloneDeep } from 'lodash';
|
|
3
4
|
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -29,23 +30,26 @@ function cloneSceneObjectState(sceneState, withState) {
|
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
31
32
|
const propValue = clonedState[key];
|
|
32
|
-
if (propValue instanceof SceneObjectBase) {
|
|
33
|
-
clonedState[key] = propValue.clone();
|
|
34
|
-
}
|
|
35
33
|
if (propValue instanceof SceneObjectRef) {
|
|
36
34
|
console.warn("Cloning object with SceneObjectRef");
|
|
37
35
|
continue;
|
|
38
36
|
}
|
|
39
|
-
if (
|
|
37
|
+
if (propValue instanceof SceneObjectBase) {
|
|
38
|
+
clonedState[key] = propValue.clone();
|
|
39
|
+
} else if (Array.isArray(propValue)) {
|
|
40
40
|
const newArray = [];
|
|
41
41
|
for (const child of propValue) {
|
|
42
42
|
if (child instanceof SceneObjectBase) {
|
|
43
43
|
newArray.push(child.clone());
|
|
44
|
+
} else if (typeof child === "object") {
|
|
45
|
+
newArray.push(cloneDeep(child));
|
|
44
46
|
} else {
|
|
45
47
|
newArray.push(child);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
clonedState[key] = newArray;
|
|
51
|
+
} else {
|
|
52
|
+
clonedState[key] = cloneDeep(propValue);
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
return clonedState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/core/sceneGraph/utils.ts"],"sourcesContent":["import { SceneObject, SceneObjectState } from '../types';\n\nimport { SceneObjectBase } from '../SceneObjectBase';\nimport { SceneObjectRef } from '../SceneObjectRef';\n\n/**\n * Will create new SceneItem with shalled cloned state, but all states items of type SceneObject are deep cloned\n */\nexport function cloneSceneObject<T extends SceneObjectBase<TState>, TState extends SceneObjectState>(\n sceneObject: SceneObjectBase<TState>,\n withState?: Partial<TState>\n): T {\n const clonedState = cloneSceneObjectState(sceneObject.state, withState);\n return new (sceneObject.constructor as any)(clonedState);\n}\n\nexport function cloneSceneObjectState<TState extends SceneObjectState>(\n sceneState: TState,\n withState?: Partial<TState>\n): TState {\n const clonedState = { ...sceneState };\n\n Object.assign(clonedState, withState);\n\n // Clone any SceneItems in state\n for (const key in clonedState) {\n // Do not clone if was part of withState\n if (withState && withState[key] !== undefined) {\n continue;\n }\n\n const propValue = clonedState[key];\n
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/core/sceneGraph/utils.ts"],"sourcesContent":["import { SceneObject, SceneObjectState } from '../types';\n\nimport { SceneObjectBase } from '../SceneObjectBase';\nimport { SceneObjectRef } from '../SceneObjectRef';\nimport { cloneDeep } from 'lodash';\n\n/**\n * Will create new SceneItem with shalled cloned state, but all states items of type SceneObject are deep cloned\n */\nexport function cloneSceneObject<T extends SceneObjectBase<TState>, TState extends SceneObjectState>(\n sceneObject: SceneObjectBase<TState>,\n withState?: Partial<TState>\n): T {\n const clonedState = cloneSceneObjectState(sceneObject.state, withState);\n return new (sceneObject.constructor as any)(clonedState);\n}\n\nexport function cloneSceneObjectState<TState extends SceneObjectState>(\n sceneState: TState,\n withState?: Partial<TState>\n): TState {\n const clonedState = { ...sceneState };\n\n Object.assign(clonedState, withState);\n\n // Clone any SceneItems in state\n for (const key in clonedState) {\n // Do not clone if was part of withState\n if (withState && withState[key] !== undefined) {\n continue;\n }\n\n const propValue = clonedState[key];\n\n if (propValue instanceof SceneObjectRef) {\n console.warn('Cloning object with SceneObjectRef');\n continue;\n }\n\n if (propValue instanceof SceneObjectBase) {\n clonedState[key] = propValue.clone();\n } else if (Array.isArray(propValue)) {\n const newArray: typeof propValue[0] = [];\n for (const child of propValue) {\n if (child instanceof SceneObjectBase) {\n newArray.push(child.clone());\n } else if (typeof child === 'object') {\n newArray.push(cloneDeep(child));\n } else {\n newArray.push(child);\n }\n }\n clonedState[key] = newArray;\n } else {\n clonedState[key] = cloneDeep(propValue);\n }\n }\n\n return clonedState;\n}\n\n/** Walks up the scene graph, returning the first non-undefined result of `extract` */\nexport function getClosest<T>(sceneObject: SceneObject, extract: (s: SceneObject) => T | undefined): T | undefined {\n let curSceneObject: SceneObject | undefined = sceneObject;\n let extracted: T | undefined = undefined;\n\n while (curSceneObject && !extracted) {\n extracted = extract(curSceneObject);\n curSceneObject = curSceneObject.parent;\n }\n\n return extracted;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AASgB,SAAA,gBAAA,CACd,aACA,SACG,EAAA;AACH,EAAA,MAAM,WAAc,GAAA,qBAAA,CAAsB,WAAY,CAAA,KAAA,EAAO,SAAS,CAAA,CAAA;AACtE,EAAO,OAAA,IAAK,WAAY,CAAA,WAAA,CAAoB,WAAW,CAAA,CAAA;AACzD,CAAA;AAEgB,SAAA,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AO,OAAA,WAAA,CAAA;AACT,CAAA;AAGgB,SAAA,UAAA,CAAc,aAA0B,OAA2D,EAAA;AACjH,EAAA,IAAI,cAA0C,GAAA,WAAA,CAAA;AAC9C,EAAA,IAAI,SAA2B,GAAA,KAAA,CAAA,CAAA;AAE/B,EAAO,OAAA,cAAA,IAAkB,CAAC,SAAW,EAAA;AACnC,IAAA,SAAA,GAAY,QAAQ,cAAc,CAAA,CAAA;AAClC,IAAA,cAAA,GAAiB,cAAe,CAAA,MAAA,CAAA;AAAA,GAClC;AAEA,EAAO,OAAA,SAAA,CAAA;AACT;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -537,23 +537,26 @@ function cloneSceneObjectState(sceneState, withState) {
|
|
|
537
537
|
continue;
|
|
538
538
|
}
|
|
539
539
|
const propValue = clonedState[key];
|
|
540
|
-
if (propValue instanceof SceneObjectBase) {
|
|
541
|
-
clonedState[key] = propValue.clone();
|
|
542
|
-
}
|
|
543
540
|
if (propValue instanceof SceneObjectRef) {
|
|
544
541
|
console.warn("Cloning object with SceneObjectRef");
|
|
545
542
|
continue;
|
|
546
543
|
}
|
|
547
|
-
if (
|
|
544
|
+
if (propValue instanceof SceneObjectBase) {
|
|
545
|
+
clonedState[key] = propValue.clone();
|
|
546
|
+
} else if (Array.isArray(propValue)) {
|
|
548
547
|
const newArray = [];
|
|
549
548
|
for (const child of propValue) {
|
|
550
549
|
if (child instanceof SceneObjectBase) {
|
|
551
550
|
newArray.push(child.clone());
|
|
551
|
+
} else if (typeof child === "object") {
|
|
552
|
+
newArray.push(lodash.cloneDeep(child));
|
|
552
553
|
} else {
|
|
553
554
|
newArray.push(child);
|
|
554
555
|
}
|
|
555
556
|
}
|
|
556
557
|
clonedState[key] = newArray;
|
|
558
|
+
} else {
|
|
559
|
+
clonedState[key] = lodash.cloneDeep(propValue);
|
|
557
560
|
}
|
|
558
561
|
}
|
|
559
562
|
return clonedState;
|