@grafana/scenes 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ var reactUse = require('react-use');
15
15
  var experimental = require('@grafana/experimental');
16
16
  var ReactGridLayout = require('react-grid-layout');
17
17
  var AutoSizer = require('react-virtualized-auto-sizer');
18
+ var reactRouterDom = require('react-router-dom');
18
19
 
19
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
21
 
@@ -30,21 +31,21 @@ class SceneObjectStateChangedEvent extends data.BusEventWithPayload {
30
31
  }
31
32
  SceneObjectStateChangedEvent.type = "scene-object-state-change";
32
33
 
33
- var __defProp$e = Object.defineProperty;
34
+ var __defProp$f = Object.defineProperty;
34
35
  var __defProps$5 = Object.defineProperties;
35
36
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
36
- var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
37
- var __hasOwnProp$e = Object.prototype.hasOwnProperty;
38
- var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
39
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
40
- var __spreadValues$e = (a, b) => {
37
+ var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
38
+ var __hasOwnProp$f = Object.prototype.hasOwnProperty;
39
+ var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
40
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
41
+ var __spreadValues$f = (a, b) => {
41
42
  for (var prop in b || (b = {}))
42
- if (__hasOwnProp$e.call(b, prop))
43
- __defNormalProp$e(a, prop, b[prop]);
44
- if (__getOwnPropSymbols$e)
45
- for (var prop of __getOwnPropSymbols$e(b)) {
46
- if (__propIsEnum$e.call(b, prop))
47
- __defNormalProp$e(a, prop, b[prop]);
43
+ if (__hasOwnProp$f.call(b, prop))
44
+ __defNormalProp$f(a, prop, b[prop]);
45
+ if (__getOwnPropSymbols$f)
46
+ for (var prop of __getOwnPropSymbols$f(b)) {
47
+ if (__propIsEnum$f.call(b, prop))
48
+ __defNormalProp$f(a, prop, b[prop]);
48
49
  }
49
50
  return a;
50
51
  };
@@ -52,11 +53,11 @@ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
52
53
  var __objRest = (source, exclude) => {
53
54
  var target = {};
54
55
  for (var prop in source)
55
- if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
56
+ if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
56
57
  target[prop] = source[prop];
57
- if (source != null && __getOwnPropSymbols$e)
58
- for (var prop of __getOwnPropSymbols$e(source)) {
59
- if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
58
+ if (source != null && __getOwnPropSymbols$f)
59
+ for (var prop of __getOwnPropSymbols$f(source)) {
60
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
60
61
  target[prop] = source[prop];
61
62
  }
62
63
  return target;
@@ -71,7 +72,7 @@ function SceneComponentWrapper(_a) {
71
72
  ]);
72
73
  var _a2;
73
74
  const Component = (_a2 = model.constructor["Component"]) != null ? _a2 : EmptyRenderer;
74
- const inner = /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$5(__spreadValues$e({}, otherProps), {
75
+ const inner = /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$5(__spreadValues$f({}, otherProps), {
75
76
  model,
76
77
  isEditing
77
78
  }));
@@ -110,19 +111,19 @@ function getSceneEditor$1(sceneObject) {
110
111
  throw new Error("No editor found in scene tree");
111
112
  }
112
113
 
113
- var __defProp$d = Object.defineProperty;
114
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
115
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
116
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
117
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
118
- var __spreadValues$d = (a, b) => {
114
+ var __defProp$e = Object.defineProperty;
115
+ var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
116
+ var __hasOwnProp$e = Object.prototype.hasOwnProperty;
117
+ var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
118
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
119
+ var __spreadValues$e = (a, b) => {
119
120
  for (var prop in b || (b = {}))
120
- if (__hasOwnProp$d.call(b, prop))
121
- __defNormalProp$d(a, prop, b[prop]);
122
- if (__getOwnPropSymbols$d)
123
- for (var prop of __getOwnPropSymbols$d(b)) {
124
- if (__propIsEnum$d.call(b, prop))
125
- __defNormalProp$d(a, prop, b[prop]);
121
+ if (__hasOwnProp$e.call(b, prop))
122
+ __defNormalProp$e(a, prop, b[prop]);
123
+ if (__getOwnPropSymbols$e)
124
+ for (var prop of __getOwnPropSymbols$e(b)) {
125
+ if (__propIsEnum$e.call(b, prop))
126
+ __defNormalProp$e(a, prop, b[prop]);
126
127
  }
127
128
  return a;
128
129
  };
@@ -141,7 +142,7 @@ function forEachSceneObjectInState(state, callback) {
141
142
  }
142
143
  }
143
144
  function cloneSceneObject(sceneObject, withState) {
144
- const clonedState = __spreadValues$d({}, sceneObject.state);
145
+ const clonedState = __spreadValues$e({}, sceneObject.state);
145
146
  for (const key in clonedState) {
146
147
  const propValue = clonedState[key];
147
148
  if (propValue instanceof SceneObjectBase) {
@@ -163,19 +164,19 @@ function cloneSceneObject(sceneObject, withState) {
163
164
  return new sceneObject.constructor(clonedState);
164
165
  }
165
166
 
166
- var __defProp$c = Object.defineProperty;
167
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
168
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
169
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
170
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
171
- var __spreadValues$c = (a, b) => {
167
+ var __defProp$d = Object.defineProperty;
168
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
169
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
170
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
171
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
172
+ var __spreadValues$d = (a, b) => {
172
173
  for (var prop in b || (b = {}))
173
- if (__hasOwnProp$c.call(b, prop))
174
- __defNormalProp$c(a, prop, b[prop]);
175
- if (__getOwnPropSymbols$c)
176
- for (var prop of __getOwnPropSymbols$c(b)) {
177
- if (__propIsEnum$c.call(b, prop))
178
- __defNormalProp$c(a, prop, b[prop]);
174
+ if (__hasOwnProp$d.call(b, prop))
175
+ __defNormalProp$d(a, prop, b[prop]);
176
+ if (__getOwnPropSymbols$d)
177
+ for (var prop of __getOwnPropSymbols$d(b)) {
178
+ if (__propIsEnum$d.call(b, prop))
179
+ __defNormalProp$d(a, prop, b[prop]);
179
180
  }
180
181
  return a;
181
182
  };
@@ -226,7 +227,7 @@ class SceneObjectBase {
226
227
  }
227
228
  setState(update) {
228
229
  const prevState = this._state;
229
- const newState = __spreadValues$c(__spreadValues$c({}, this._state), update);
230
+ const newState = __spreadValues$d(__spreadValues$d({}, this._state), update);
230
231
  this._state = Object.freeze(newState);
231
232
  this.setParent();
232
233
  this._subject.next(newState);
@@ -251,7 +252,10 @@ class SceneObjectBase {
251
252
  }
252
253
  activate() {
253
254
  this._isActive = true;
254
- const { $data, $variables } = this.state;
255
+ const { $data, $variables, $timeRange } = this.state;
256
+ if ($timeRange && !$timeRange.isActive) {
257
+ $timeRange.activate();
258
+ }
255
259
  if ($data && !$data.isActive) {
256
260
  $data.activate();
257
261
  }
@@ -261,7 +265,10 @@ class SceneObjectBase {
261
265
  }
262
266
  deactivate() {
263
267
  this._isActive = false;
264
- const { $data, $variables } = this.state;
268
+ const { $data, $variables, $timeRange } = this.state;
269
+ if ($timeRange && $timeRange.isActive) {
270
+ $timeRange.deactivate();
271
+ }
265
272
  if ($data && $data.isActive) {
266
273
  $data.deactivate();
267
274
  }
@@ -312,19 +319,19 @@ class SceneObjectUrlSyncConfig {
312
319
  }
313
320
  }
314
321
 
315
- var __defProp$b = Object.defineProperty;
316
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
317
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
318
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
319
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
320
- var __spreadValues$b = (a, b) => {
322
+ var __defProp$c = Object.defineProperty;
323
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
324
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
325
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
326
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
327
+ var __spreadValues$c = (a, b) => {
321
328
  for (var prop in b || (b = {}))
322
- if (__hasOwnProp$b.call(b, prop))
323
- __defNormalProp$b(a, prop, b[prop]);
324
- if (__getOwnPropSymbols$b)
325
- for (var prop of __getOwnPropSymbols$b(b)) {
326
- if (__propIsEnum$b.call(b, prop))
327
- __defNormalProp$b(a, prop, b[prop]);
329
+ if (__hasOwnProp$c.call(b, prop))
330
+ __defNormalProp$c(a, prop, b[prop]);
331
+ if (__getOwnPropSymbols$c)
332
+ for (var prop of __getOwnPropSymbols$c(b)) {
333
+ if (__propIsEnum$c.call(b, prop))
334
+ __defNormalProp$c(a, prop, b[prop]);
328
335
  }
329
336
  return a;
330
337
  };
@@ -335,7 +342,7 @@ class SceneTimeRange extends SceneObjectBase {
335
342
  const to = (_b = state.to) != null ? _b : "now";
336
343
  const timeZone = (_c = state.timeZone) != null ? _c : data.getTimeZone();
337
344
  const value = evaluateTimeRange(from, to, timeZone);
338
- super(__spreadValues$b({ from, to, timeZone, value }, state));
345
+ super(__spreadValues$c({ from, to, timeZone, value }, state));
339
346
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to"] });
340
347
  this.onTimeRangeChange = (timeRange) => {
341
348
  const update = {};
@@ -355,8 +362,6 @@ class SceneTimeRange extends SceneObjectBase {
355
362
  this.onRefresh = () => {
356
363
  this.setState({ value: evaluateTimeRange(this.state.from, this.state.to, this.state.timeZone) });
357
364
  };
358
- this.onIntervalChanged = (_) => {
359
- };
360
365
  }
361
366
  getUrlState(state) {
362
367
  return { from: state.from, to: state.to };
@@ -421,53 +426,78 @@ SceneVariableValueChangedEvent.type = "scene-variable-changed-value";
421
426
  class SceneVariableSet extends SceneObjectBase {
422
427
  constructor() {
423
428
  super(...arguments);
424
- this.variablesThatHaveChanged = /* @__PURE__ */ new Set();
425
- this.variablesToUpdate = /* @__PURE__ */ new Set();
426
- this.updating = /* @__PURE__ */ new Map();
427
- this.onVariableValueChanged = (event) => {
428
- const variableThatChanged = event.payload;
429
- this.variablesThatHaveChanged.add(variableThatChanged);
430
- if (this.updating.has(variableThatChanged)) {
431
- return;
432
- }
433
- for (const otherVariable of this.state.variables) {
434
- if (otherVariable.variableDependency) {
435
- if (otherVariable.variableDependency.hasDependencyOn(variableThatChanged.state.name)) {
436
- this.variablesToUpdate.add(otherVariable);
437
- }
438
- }
439
- }
440
- this.updateNextBatch();
441
- };
429
+ this._variablesThatHaveChanged = /* @__PURE__ */ new Set();
430
+ this._variablesToUpdate = /* @__PURE__ */ new Set();
431
+ this._updating = /* @__PURE__ */ new Map();
442
432
  }
443
433
  getByName(name) {
444
434
  return this.state.variables.find((x) => x.state.name === name);
445
435
  }
446
436
  activate() {
447
437
  super.activate();
448
- this._subs.add(this.subscribeToEvent(SceneVariableValueChangedEvent, this.onVariableValueChanged));
449
- this.validateAndUpdateAll();
438
+ this._subs.add(
439
+ this.subscribeToEvent(SceneVariableValueChangedEvent, (event) => this.handleVariableValueChanged(event.payload))
440
+ );
441
+ this.checkForVariablesThatChangedWhileInactive();
442
+ for (const variable of this.state.variables) {
443
+ if (this.variableNeedsUpdate(variable)) {
444
+ this._variablesToUpdate.add(variable);
445
+ }
446
+ }
447
+ this.updateNextBatch();
448
+ }
449
+ checkForVariablesThatChangedWhileInactive() {
450
+ if (!this._validValuesWhenDeactivated) {
451
+ return;
452
+ }
453
+ for (const variable of this.state.variables) {
454
+ if (this._validValuesWhenDeactivated.has(variable)) {
455
+ const value = this._validValuesWhenDeactivated.get(variable);
456
+ if (!isVariableValueEqual(value, variable.getValue())) {
457
+ writeVariableTraceLog(variable, "Changed while in-active");
458
+ this.handleVariableValueChanged(variable);
459
+ }
460
+ }
461
+ }
462
+ }
463
+ variableNeedsUpdate(variable) {
464
+ if (!variable.validateAndUpdate) {
465
+ return false;
466
+ }
467
+ if (this._validValuesWhenDeactivated && this._validValuesWhenDeactivated.has(variable)) {
468
+ const value = this._validValuesWhenDeactivated.get(variable);
469
+ if (isVariableValueEqual(value, variable.getValue())) {
470
+ writeVariableTraceLog(variable, "Skipping updateAndValidate current value valid");
471
+ return false;
472
+ }
473
+ }
474
+ return true;
450
475
  }
451
476
  deactivate() {
452
477
  var _a;
453
478
  super.deactivate();
454
- for (const update of this.updating.values()) {
479
+ for (const update of this._updating.values()) {
455
480
  (_a = update.subscription) == null ? void 0 : _a.unsubscribe();
456
481
  }
457
- this.variablesToUpdate.clear();
458
- this.updating.clear();
459
- this.variablesThatHaveChanged.clear();
482
+ this._validValuesWhenDeactivated = /* @__PURE__ */ new Map();
483
+ for (const variable of this.state.variables) {
484
+ if (!this._variablesToUpdate.has(variable) || !this._updating.has(variable)) {
485
+ this._validValuesWhenDeactivated.set(variable, variable.getValue());
486
+ }
487
+ }
488
+ this._variablesToUpdate.clear();
489
+ this._updating.clear();
460
490
  }
461
491
  updateNextBatch() {
462
- if (this.variablesToUpdate.size === 0 && this.variablesThatHaveChanged.size > 0) {
492
+ if (this._variablesToUpdate.size === 0 && this._variablesThatHaveChanged.size > 0) {
463
493
  this.notifyDependentSceneObjects();
464
494
  return;
465
495
  }
466
- for (const variable of this.variablesToUpdate) {
496
+ for (const variable of this._variablesToUpdate) {
467
497
  if (!variable.validateAndUpdate) {
468
498
  throw new Error("Variable added to variablesToUpdate but does not have validateAndUpdate");
469
499
  }
470
- if (this.updating.has(variable)) {
500
+ if (this._updating.has(variable)) {
471
501
  continue;
472
502
  }
473
503
  if (this.hasDependendencyInUpdateQueue(variable)) {
@@ -476,7 +506,8 @@ class SceneVariableSet extends SceneObjectBase {
476
506
  const variableToUpdate = {
477
507
  variable
478
508
  };
479
- this.updating.set(variable, variableToUpdate);
509
+ this._updating.set(variable, variableToUpdate);
510
+ writeVariableTraceLog(variable, "updateAndValidate started");
480
511
  variableToUpdate.subscription = variable.validateAndUpdate().subscribe({
481
512
  next: () => this.validateAndUpdateCompleted(variable),
482
513
  error: (err) => this.handleVariableError(variable, err)
@@ -485,36 +516,45 @@ class SceneVariableSet extends SceneObjectBase {
485
516
  }
486
517
  validateAndUpdateCompleted(variable) {
487
518
  var _a;
488
- const update = this.updating.get(variable);
519
+ const update = this._updating.get(variable);
489
520
  (_a = update == null ? void 0 : update.subscription) == null ? void 0 : _a.unsubscribe();
490
- this.updating.delete(variable);
491
- this.variablesToUpdate.delete(variable);
521
+ this._updating.delete(variable);
522
+ this._variablesToUpdate.delete(variable);
523
+ writeVariableTraceLog(variable, "updateAndValidate completed");
492
524
  this.updateNextBatch();
493
525
  }
494
526
  handleVariableError(variable, err) {
495
527
  var _a;
496
- const update = this.updating.get(variable);
528
+ const update = this._updating.get(variable);
497
529
  (_a = update == null ? void 0 : update.subscription) == null ? void 0 : _a.unsubscribe();
498
- this.updating.delete(variable);
499
- this.variablesToUpdate.delete(variable);
530
+ this._updating.delete(variable);
531
+ this._variablesToUpdate.delete(variable);
500
532
  variable.setState({ loading: false, error: err });
533
+ writeVariableTraceLog(variable, "updateAndValidate error", err);
501
534
  }
502
535
  hasDependendencyInUpdateQueue(variable) {
503
536
  var _a;
504
537
  if (!variable.variableDependency) {
505
538
  return false;
506
539
  }
507
- for (const otherVariable of this.variablesToUpdate.values()) {
540
+ for (const otherVariable of this._variablesToUpdate.values()) {
508
541
  if ((_a = variable.variableDependency) == null ? void 0 : _a.hasDependencyOn(otherVariable.state.name)) {
509
542
  return true;
510
543
  }
511
544
  }
512
545
  return false;
513
546
  }
514
- validateAndUpdateAll() {
515
- for (const variable of this.state.variables) {
516
- if (variable.validateAndUpdate) {
517
- this.variablesToUpdate.add(variable);
547
+ handleVariableValueChanged(variableThatChanged) {
548
+ this._variablesThatHaveChanged.add(variableThatChanged);
549
+ if (this._updating.has(variableThatChanged)) {
550
+ return;
551
+ }
552
+ for (const otherVariable of this.state.variables) {
553
+ if (otherVariable.variableDependency) {
554
+ if (otherVariable.variableDependency.hasDependencyOn(variableThatChanged.state.name)) {
555
+ writeVariableTraceLog(otherVariable, "Added to update quee, dependant variable value changed");
556
+ this._variablesToUpdate.add(otherVariable);
557
+ }
518
558
  }
519
559
  }
520
560
  this.updateNextBatch();
@@ -524,18 +564,29 @@ class SceneVariableSet extends SceneObjectBase {
524
564
  return;
525
565
  }
526
566
  this.traverseSceneAndNotify(this.parent);
527
- this.variablesThatHaveChanged.clear();
567
+ this._variablesThatHaveChanged.clear();
528
568
  }
529
569
  traverseSceneAndNotify(sceneObject) {
530
570
  if (this === sceneObject) {
531
571
  return;
532
572
  }
533
573
  if (sceneObject.variableDependency) {
534
- sceneObject.variableDependency.variableValuesChanged(this.variablesThatHaveChanged);
574
+ sceneObject.variableDependency.variableValuesChanged(this._variablesThatHaveChanged);
535
575
  }
536
576
  forEachSceneObjectInState(sceneObject.state, (child) => this.traverseSceneAndNotify(child));
537
577
  }
538
578
  }
579
+ function writeVariableTraceLog(variable, message, err) {
580
+ if (window.grafanaLoggingSceneVariables) {
581
+ console.log(`Variable[${variable.state.name}]: ${message}`, err);
582
+ }
583
+ }
584
+ function isVariableValueEqual(a, b) {
585
+ if (a === b) {
586
+ return true;
587
+ }
588
+ return lodash.isEqual(a, b);
589
+ }
539
590
 
540
591
  const EmptyVariableSet = new SceneVariableSet({ variables: [] });
541
592
  const EmptyDataNode = new SceneDataNode({
@@ -1099,21 +1150,21 @@ const safeStringifyValue = (value) => {
1099
1150
  return "";
1100
1151
  };
1101
1152
 
1102
- var __defProp$a = Object.defineProperty;
1153
+ var __defProp$b = Object.defineProperty;
1103
1154
  var __defProps$4 = Object.defineProperties;
1104
1155
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1105
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
1106
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
1107
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
1108
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1109
- var __spreadValues$a = (a, b) => {
1156
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
1157
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
1158
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
1159
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1160
+ var __spreadValues$b = (a, b) => {
1110
1161
  for (var prop in b || (b = {}))
1111
- if (__hasOwnProp$a.call(b, prop))
1112
- __defNormalProp$a(a, prop, b[prop]);
1113
- if (__getOwnPropSymbols$a)
1114
- for (var prop of __getOwnPropSymbols$a(b)) {
1115
- if (__propIsEnum$a.call(b, prop))
1116
- __defNormalProp$a(a, prop, b[prop]);
1162
+ if (__hasOwnProp$b.call(b, prop))
1163
+ __defNormalProp$b(a, prop, b[prop]);
1164
+ if (__getOwnPropSymbols$b)
1165
+ for (var prop of __getOwnPropSymbols$b(b)) {
1166
+ if (__propIsEnum$b.call(b, prop))
1167
+ __defNormalProp$b(a, prop, b[prop]);
1117
1168
  }
1118
1169
  return a;
1119
1170
  };
@@ -1174,7 +1225,9 @@ class SceneQueryRunner extends SceneObjectBase {
1174
1225
  }, 0);
1175
1226
  }
1176
1227
  } else {
1177
- this._containerWidth = width;
1228
+ if (width > 0) {
1229
+ this._containerWidth = width;
1230
+ }
1178
1231
  }
1179
1232
  }
1180
1233
  runQueries() {
@@ -1241,7 +1294,7 @@ const getTransformationsStream = (sceneObject, transformations) => (inputStream)
1241
1294
  return sceneGraph.interpolate(sceneObject, value, (_a = data$1 == null ? void 0 : data$1.request) == null ? void 0 : _a.scopedVars);
1242
1295
  }
1243
1296
  };
1244
- return data.transformDataFrame(transformations, data$1.series, ctx).pipe(rxjs.map((series) => __spreadProps$4(__spreadValues$a({}, data$1), { series })));
1297
+ return data.transformDataFrame(transformations, data$1.series, ctx).pipe(rxjs.map((series) => __spreadProps$4(__spreadValues$b({}, data$1), { series })));
1245
1298
  })
1246
1299
  );
1247
1300
  };
@@ -1336,25 +1389,25 @@ function VariableLabel({ state }) {
1336
1389
  }, labelOrName);
1337
1390
  }
1338
1391
 
1339
- var __defProp$9 = Object.defineProperty;
1340
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1341
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1342
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1343
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1344
- var __spreadValues$9 = (a, b) => {
1392
+ var __defProp$a = Object.defineProperty;
1393
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
1394
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
1395
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
1396
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1397
+ var __spreadValues$a = (a, b) => {
1345
1398
  for (var prop in b || (b = {}))
1346
- if (__hasOwnProp$9.call(b, prop))
1347
- __defNormalProp$9(a, prop, b[prop]);
1348
- if (__getOwnPropSymbols$9)
1349
- for (var prop of __getOwnPropSymbols$9(b)) {
1350
- if (__propIsEnum$9.call(b, prop))
1351
- __defNormalProp$9(a, prop, b[prop]);
1399
+ if (__hasOwnProp$a.call(b, prop))
1400
+ __defNormalProp$a(a, prop, b[prop]);
1401
+ if (__getOwnPropSymbols$a)
1402
+ for (var prop of __getOwnPropSymbols$a(b)) {
1403
+ if (__propIsEnum$a.call(b, prop))
1404
+ __defNormalProp$a(a, prop, b[prop]);
1352
1405
  }
1353
1406
  return a;
1354
1407
  };
1355
1408
  class ConstantVariable extends SceneObjectBase {
1356
1409
  constructor(initialState) {
1357
- super(__spreadValues$9({
1410
+ super(__spreadValues$a({
1358
1411
  type: "constant",
1359
1412
  value: "",
1360
1413
  name: ""
@@ -1592,25 +1645,25 @@ class MultiValueUrlSyncHandler {
1592
1645
  }
1593
1646
  }
1594
1647
 
1595
- var __defProp$8 = Object.defineProperty;
1596
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1597
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1598
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1599
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1600
- var __spreadValues$8 = (a, b) => {
1648
+ var __defProp$9 = Object.defineProperty;
1649
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
1650
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
1651
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
1652
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1653
+ var __spreadValues$9 = (a, b) => {
1601
1654
  for (var prop in b || (b = {}))
1602
- if (__hasOwnProp$8.call(b, prop))
1603
- __defNormalProp$8(a, prop, b[prop]);
1604
- if (__getOwnPropSymbols$8)
1605
- for (var prop of __getOwnPropSymbols$8(b)) {
1606
- if (__propIsEnum$8.call(b, prop))
1607
- __defNormalProp$8(a, prop, b[prop]);
1655
+ if (__hasOwnProp$9.call(b, prop))
1656
+ __defNormalProp$9(a, prop, b[prop]);
1657
+ if (__getOwnPropSymbols$9)
1658
+ for (var prop of __getOwnPropSymbols$9(b)) {
1659
+ if (__propIsEnum$9.call(b, prop))
1660
+ __defNormalProp$9(a, prop, b[prop]);
1608
1661
  }
1609
1662
  return a;
1610
1663
  };
1611
1664
  class CustomVariable extends MultiValueVariable {
1612
1665
  constructor(initialState) {
1613
- super(__spreadValues$8({
1666
+ super(__spreadValues$9({
1614
1667
  type: "custom",
1615
1668
  query: "",
1616
1669
  value: "",
@@ -1643,25 +1696,25 @@ CustomVariable.Component = ({ model }) => {
1643
1696
  return renderSelectForVariable(model);
1644
1697
  };
1645
1698
 
1646
- var __defProp$7 = Object.defineProperty;
1647
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1648
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1649
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1650
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1651
- var __spreadValues$7 = (a, b) => {
1699
+ var __defProp$8 = Object.defineProperty;
1700
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
1701
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
1702
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
1703
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1704
+ var __spreadValues$8 = (a, b) => {
1652
1705
  for (var prop in b || (b = {}))
1653
- if (__hasOwnProp$7.call(b, prop))
1654
- __defNormalProp$7(a, prop, b[prop]);
1655
- if (__getOwnPropSymbols$7)
1656
- for (var prop of __getOwnPropSymbols$7(b)) {
1657
- if (__propIsEnum$7.call(b, prop))
1658
- __defNormalProp$7(a, prop, b[prop]);
1706
+ if (__hasOwnProp$8.call(b, prop))
1707
+ __defNormalProp$8(a, prop, b[prop]);
1708
+ if (__getOwnPropSymbols$8)
1709
+ for (var prop of __getOwnPropSymbols$8(b)) {
1710
+ if (__propIsEnum$8.call(b, prop))
1711
+ __defNormalProp$8(a, prop, b[prop]);
1659
1712
  }
1660
1713
  return a;
1661
1714
  };
1662
1715
  class DataSourceVariable extends MultiValueVariable {
1663
1716
  constructor(initialState) {
1664
- super(__spreadValues$7({
1717
+ super(__spreadValues$8({
1665
1718
  type: "datasource",
1666
1719
  value: "",
1667
1720
  text: "",
@@ -1739,21 +1792,21 @@ const hasStandardVariableSupport = (datasource) => {
1739
1792
  return "toDataQuery" in variableSupport && Boolean(variableSupport.toDataQuery);
1740
1793
  };
1741
1794
 
1742
- var __defProp$6 = Object.defineProperty;
1795
+ var __defProp$7 = Object.defineProperty;
1743
1796
  var __defProps$3 = Object.defineProperties;
1744
1797
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1745
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1746
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1747
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1748
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1749
- var __spreadValues$6 = (a, b) => {
1798
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1799
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1800
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1801
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1802
+ var __spreadValues$7 = (a, b) => {
1750
1803
  for (var prop in b || (b = {}))
1751
- if (__hasOwnProp$6.call(b, prop))
1752
- __defNormalProp$6(a, prop, b[prop]);
1753
- if (__getOwnPropSymbols$6)
1754
- for (var prop of __getOwnPropSymbols$6(b)) {
1755
- if (__propIsEnum$6.call(b, prop))
1756
- __defNormalProp$6(a, prop, b[prop]);
1804
+ if (__hasOwnProp$7.call(b, prop))
1805
+ __defNormalProp$7(a, prop, b[prop]);
1806
+ if (__getOwnPropSymbols$7)
1807
+ for (var prop of __getOwnPropSymbols$7(b)) {
1808
+ if (__propIsEnum$7.call(b, prop))
1809
+ __defNormalProp$7(a, prop, b[prop]);
1757
1810
  }
1758
1811
  return a;
1759
1812
  };
@@ -1794,7 +1847,7 @@ class LegacyQueryRunner {
1794
1847
  return getEmptyMetricFindValueObservable();
1795
1848
  }
1796
1849
  return rxjs.from(
1797
- this.datasource.metricFindQuery(variable.state.query, __spreadProps$3(__spreadValues$6({}, request), {
1850
+ this.datasource.metricFindQuery(variable.state.query, __spreadProps$3(__spreadValues$7({}, request), {
1798
1851
  variable: {
1799
1852
  name: variable.state.name,
1800
1853
  type: variable.state.type
@@ -2001,25 +2054,25 @@ function areMetricFindValues(data$1) {
2001
2054
  return false;
2002
2055
  }
2003
2056
 
2004
- var __defProp$5 = Object.defineProperty;
2005
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
2006
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
2007
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
2008
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2009
- var __spreadValues$5 = (a, b) => {
2057
+ var __defProp$6 = Object.defineProperty;
2058
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
2059
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
2060
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
2061
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2062
+ var __spreadValues$6 = (a, b) => {
2010
2063
  for (var prop in b || (b = {}))
2011
- if (__hasOwnProp$5.call(b, prop))
2012
- __defNormalProp$5(a, prop, b[prop]);
2013
- if (__getOwnPropSymbols$5)
2014
- for (var prop of __getOwnPropSymbols$5(b)) {
2015
- if (__propIsEnum$5.call(b, prop))
2016
- __defNormalProp$5(a, prop, b[prop]);
2064
+ if (__hasOwnProp$6.call(b, prop))
2065
+ __defNormalProp$6(a, prop, b[prop]);
2066
+ if (__getOwnPropSymbols$6)
2067
+ for (var prop of __getOwnPropSymbols$6(b)) {
2068
+ if (__propIsEnum$6.call(b, prop))
2069
+ __defNormalProp$6(a, prop, b[prop]);
2017
2070
  }
2018
2071
  return a;
2019
2072
  };
2020
2073
  class QueryVariable extends MultiValueVariable {
2021
2074
  constructor(initialState) {
2022
- super(__spreadValues$5({
2075
+ super(__spreadValues$6({
2023
2076
  type: "query",
2024
2077
  name: "",
2025
2078
  value: "",
@@ -2173,25 +2226,25 @@ function queryMetricTree(query) {
2173
2226
  return queryTree(children, query.split("."), 0);
2174
2227
  }
2175
2228
 
2176
- var __defProp$4 = Object.defineProperty;
2177
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
2178
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
2179
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
2180
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2181
- var __spreadValues$4 = (a, b) => {
2229
+ var __defProp$5 = Object.defineProperty;
2230
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
2231
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
2232
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
2233
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2234
+ var __spreadValues$5 = (a, b) => {
2182
2235
  for (var prop in b || (b = {}))
2183
- if (__hasOwnProp$4.call(b, prop))
2184
- __defNormalProp$4(a, prop, b[prop]);
2185
- if (__getOwnPropSymbols$4)
2186
- for (var prop of __getOwnPropSymbols$4(b)) {
2187
- if (__propIsEnum$4.call(b, prop))
2188
- __defNormalProp$4(a, prop, b[prop]);
2236
+ if (__hasOwnProp$5.call(b, prop))
2237
+ __defNormalProp$5(a, prop, b[prop]);
2238
+ if (__getOwnPropSymbols$5)
2239
+ for (var prop of __getOwnPropSymbols$5(b)) {
2240
+ if (__propIsEnum$5.call(b, prop))
2241
+ __defNormalProp$5(a, prop, b[prop]);
2189
2242
  }
2190
2243
  return a;
2191
2244
  };
2192
2245
  class TestVariable extends MultiValueVariable {
2193
2246
  constructor(initialState) {
2194
- super(__spreadValues$4({
2247
+ super(__spreadValues$5({
2195
2248
  type: "custom",
2196
2249
  name: "Test",
2197
2250
  value: "Value",
@@ -2442,10 +2495,10 @@ function VizPanelRenderer({ model }) {
2442
2495
  var _a;
2443
2496
  const theme = ui.useTheme2();
2444
2497
  const replace = React.useMemo(
2445
- () => (value, scoped) => sceneGraph.interpolate(model, value, scoped),
2498
+ () => (value, scoped, format) => sceneGraph.interpolate(model, value, scoped, format),
2446
2499
  [model]
2447
2500
  );
2448
- const { title, options, fieldConfig, pluginId, pluginLoadError, $data, placement } = model.useState();
2501
+ const { title, description, options, fieldConfig, pluginId, pluginLoadError, $data, placement } = model.useState();
2449
2502
  const [ref, { width, height }] = reactUse.useMeasure();
2450
2503
  const plugin = model.getPlugin();
2451
2504
  const { data: data$1 } = sceneGraph.getData(model).useState();
@@ -2454,7 +2507,7 @@ function VizPanelRenderer({ model }) {
2454
2507
  const dragHandle = /* @__PURE__ */ React__default["default"].createElement(SceneDragHandle, {
2455
2508
  layoutKey: parentLayout.state.key
2456
2509
  });
2457
- const titleInterpolated = sceneGraph.interpolate(model, title);
2510
+ const titleInterpolated = replace(title, void 0, "text");
2458
2511
  const timeZone = sceneGraph.getTimeRange(model).state.timeZone;
2459
2512
  const dataWithOverrides = data.useFieldOverrides(plugin, fieldConfig, data$1, timeZone, theme, replace);
2460
2513
  if (pluginLoadError) {
@@ -2470,14 +2523,23 @@ function VizPanelRenderer({ model }) {
2470
2523
  if ($data instanceof SceneQueryRunner) {
2471
2524
  $data.setContainerWidth(width);
2472
2525
  }
2526
+ const titleItems = isDraggable ? [dragHandle] : [];
2527
+ if (model.state.$timeRange) {
2528
+ titleItems.push(/* @__PURE__ */ React__default["default"].createElement(model.state.$timeRange.Component, {
2529
+ model: model.state.$timeRange
2530
+ }));
2531
+ }
2473
2532
  return /* @__PURE__ */ React__default["default"].createElement("div", {
2474
2533
  ref,
2475
2534
  style: { position: "absolute", width: "100%", height: "100%" }
2476
2535
  }, /* @__PURE__ */ React__default["default"].createElement(ui.PanelChrome, {
2477
2536
  title: titleInterpolated,
2537
+ description: description ? () => replace(description) : "",
2538
+ loadingState: dataWithOverrides == null ? void 0 : dataWithOverrides.state,
2539
+ statusMessage: (dataWithOverrides == null ? void 0 : dataWithOverrides.error) ? dataWithOverrides.error.message : "",
2478
2540
  width,
2479
2541
  height,
2480
- leftItems: isDraggable ? [dragHandle] : void 0
2542
+ titleItems: isDraggable ? [dragHandle] : []
2481
2543
  }, (innerWidth, innerHeight) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, !dataWithOverrides && /* @__PURE__ */ React__default["default"].createElement("div", null, "No data..."), dataWithOverrides && /* @__PURE__ */ React__default["default"].createElement(ui.ErrorBoundaryAlert, {
2482
2544
  dependencies: [plugin, data$1]
2483
2545
  }, /* @__PURE__ */ React__default["default"].createElement(data.PluginContextProvider, {
@@ -2494,7 +2556,7 @@ function VizPanelRenderer({ model }) {
2494
2556
  width: innerWidth,
2495
2557
  height: innerHeight,
2496
2558
  renderCounter: 0,
2497
- replaceVariables: (str) => str,
2559
+ replaceVariables: replace,
2498
2560
  onOptionsChange: model.onOptionsChange,
2499
2561
  onFieldConfigChange: model.onFieldConfigChange,
2500
2562
  onChangeTimeRange: model.onChangeTimeRange,
@@ -2503,25 +2565,25 @@ function VizPanelRenderer({ model }) {
2503
2565
  }
2504
2566
  VizPanelRenderer.displayName = "ScenePanelRenderer";
2505
2567
 
2506
- var __defProp$3 = Object.defineProperty;
2507
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2508
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2509
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2510
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2511
- var __spreadValues$3 = (a, b) => {
2568
+ var __defProp$4 = Object.defineProperty;
2569
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
2570
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
2571
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
2572
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2573
+ var __spreadValues$4 = (a, b) => {
2512
2574
  for (var prop in b || (b = {}))
2513
- if (__hasOwnProp$3.call(b, prop))
2514
- __defNormalProp$3(a, prop, b[prop]);
2515
- if (__getOwnPropSymbols$3)
2516
- for (var prop of __getOwnPropSymbols$3(b)) {
2517
- if (__propIsEnum$3.call(b, prop))
2518
- __defNormalProp$3(a, prop, b[prop]);
2575
+ if (__hasOwnProp$4.call(b, prop))
2576
+ __defNormalProp$4(a, prop, b[prop]);
2577
+ if (__getOwnPropSymbols$4)
2578
+ for (var prop of __getOwnPropSymbols$4(b)) {
2579
+ if (__propIsEnum$4.call(b, prop))
2580
+ __defNormalProp$4(a, prop, b[prop]);
2519
2581
  }
2520
2582
  return a;
2521
2583
  };
2522
2584
  class VizPanel extends SceneObjectBase {
2523
2585
  constructor(state) {
2524
- super(__spreadValues$3({
2586
+ super(__spreadValues$4({
2525
2587
  options: {},
2526
2588
  fieldConfig: { defaults: {}, overrides: [] },
2527
2589
  title: "Title",
@@ -2591,21 +2653,21 @@ class VizPanel extends SceneObjectBase {
2591
2653
  }
2592
2654
  VizPanel.Component = VizPanelRenderer;
2593
2655
 
2594
- var __defProp$2 = Object.defineProperty;
2656
+ var __defProp$3 = Object.defineProperty;
2595
2657
  var __defProps$2 = Object.defineProperties;
2596
2658
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2597
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
2598
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
2599
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
2600
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2601
- var __spreadValues$2 = (a, b) => {
2659
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2660
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2661
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2662
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2663
+ var __spreadValues$3 = (a, b) => {
2602
2664
  for (var prop in b || (b = {}))
2603
- if (__hasOwnProp$2.call(b, prop))
2604
- __defNormalProp$2(a, prop, b[prop]);
2605
- if (__getOwnPropSymbols$2)
2606
- for (var prop of __getOwnPropSymbols$2(b)) {
2607
- if (__propIsEnum$2.call(b, prop))
2608
- __defNormalProp$2(a, prop, b[prop]);
2665
+ if (__hasOwnProp$3.call(b, prop))
2666
+ __defNormalProp$3(a, prop, b[prop]);
2667
+ if (__getOwnPropSymbols$3)
2668
+ for (var prop of __getOwnPropSymbols$3(b)) {
2669
+ if (__propIsEnum$3.call(b, prop))
2670
+ __defNormalProp$3(a, prop, b[prop]);
2609
2671
  }
2610
2672
  return a;
2611
2673
  };
@@ -2616,7 +2678,7 @@ class NestedScene extends SceneObjectBase {
2616
2678
  this.onToggle = () => {
2617
2679
  this.setState({
2618
2680
  isCollapsed: !this.state.isCollapsed,
2619
- placement: __spreadProps$2(__spreadValues$2({}, this.state.placement), {
2681
+ placement: __spreadProps$2(__spreadValues$3({}, this.state.placement), {
2620
2682
  ySizing: this.state.isCollapsed ? "fill" : "content"
2621
2683
  })
2622
2684
  });
@@ -2787,7 +2849,8 @@ function SceneTimePickerRenderer({ model }) {
2787
2849
  }
2788
2850
  }), /* @__PURE__ */ React__default["default"].createElement(ui.RefreshPicker, {
2789
2851
  onRefresh: timeRange.onRefresh,
2790
- onIntervalChanged: timeRange.onIntervalChanged
2852
+ onIntervalChanged: () => {
2853
+ }
2791
2854
  }));
2792
2855
  }
2793
2856
 
@@ -2928,31 +2991,31 @@ const GRID_CELL_HEIGHT = 30;
2928
2991
  const GRID_CELL_VMARGIN = 8;
2929
2992
  const GRID_COLUMN_COUNT = 24;
2930
2993
 
2931
- var __defProp$1 = Object.defineProperty;
2994
+ var __defProp$2 = Object.defineProperty;
2932
2995
  var __defProps$1 = Object.defineProperties;
2933
2996
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
2934
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
2935
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
2936
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
2937
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2938
- var __spreadValues$1 = (a, b) => {
2997
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
2998
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
2999
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
3000
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3001
+ var __spreadValues$2 = (a, b) => {
2939
3002
  for (var prop in b || (b = {}))
2940
- if (__hasOwnProp$1.call(b, prop))
2941
- __defNormalProp$1(a, prop, b[prop]);
2942
- if (__getOwnPropSymbols$1)
2943
- for (var prop of __getOwnPropSymbols$1(b)) {
2944
- if (__propIsEnum$1.call(b, prop))
2945
- __defNormalProp$1(a, prop, b[prop]);
3003
+ if (__hasOwnProp$2.call(b, prop))
3004
+ __defNormalProp$2(a, prop, b[prop]);
3005
+ if (__getOwnPropSymbols$2)
3006
+ for (var prop of __getOwnPropSymbols$2(b)) {
3007
+ if (__propIsEnum$2.call(b, prop))
3008
+ __defNormalProp$2(a, prop, b[prop]);
2946
3009
  }
2947
3010
  return a;
2948
3011
  };
2949
3012
  var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2950
3013
  class SceneGridRow extends SceneObjectBase {
2951
3014
  constructor(state) {
2952
- super(__spreadProps$1(__spreadValues$1({
3015
+ super(__spreadProps$1(__spreadValues$2({
2953
3016
  isCollapsible: true
2954
3017
  }, state), {
2955
- placement: __spreadProps$1(__spreadValues$1({
3018
+ placement: __spreadProps$1(__spreadValues$2({
2956
3019
  isResizable: false,
2957
3020
  isDraggable: true
2958
3021
  }, state.placement), {
@@ -3040,29 +3103,29 @@ const getSceneGridRowStyles = (theme) => {
3040
3103
  };
3041
3104
  };
3042
3105
 
3043
- var __defProp = Object.defineProperty;
3106
+ var __defProp$1 = Object.defineProperty;
3044
3107
  var __defProps = Object.defineProperties;
3045
3108
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3046
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3047
- var __hasOwnProp = Object.prototype.hasOwnProperty;
3048
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
3049
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3050
- var __spreadValues = (a, b) => {
3109
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
3110
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
3111
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
3112
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3113
+ var __spreadValues$1 = (a, b) => {
3051
3114
  for (var prop in b || (b = {}))
3052
- if (__hasOwnProp.call(b, prop))
3053
- __defNormalProp(a, prop, b[prop]);
3054
- if (__getOwnPropSymbols)
3055
- for (var prop of __getOwnPropSymbols(b)) {
3056
- if (__propIsEnum.call(b, prop))
3057
- __defNormalProp(a, prop, b[prop]);
3115
+ if (__hasOwnProp$1.call(b, prop))
3116
+ __defNormalProp$1(a, prop, b[prop]);
3117
+ if (__getOwnPropSymbols$1)
3118
+ for (var prop of __getOwnPropSymbols$1(b)) {
3119
+ if (__propIsEnum$1.call(b, prop))
3120
+ __defNormalProp$1(a, prop, b[prop]);
3058
3121
  }
3059
3122
  return a;
3060
3123
  };
3061
3124
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3062
3125
  class SceneGridLayout extends SceneObjectBase {
3063
3126
  constructor(state) {
3064
- super(__spreadProps(__spreadValues({}, state), {
3065
- placement: __spreadValues({
3127
+ super(__spreadProps(__spreadValues$1({}, state), {
3128
+ placement: __spreadValues$1({
3066
3129
  isDraggable: true
3067
3130
  }, state.placement),
3068
3131
  children: sortChildrenByPosition(state.children)
@@ -3083,7 +3146,7 @@ class SceneGridLayout extends SceneObjectBase {
3083
3146
  };
3084
3147
  if (!isItemSizeEqual(child.state.placement, nextSize)) {
3085
3148
  child.setState({
3086
- placement: __spreadValues(__spreadValues({}, child.state.placement), nextSize)
3149
+ placement: __spreadValues$1(__spreadValues$1({}, child.state.placement), nextSize)
3087
3150
  });
3088
3151
  }
3089
3152
  }
@@ -3092,7 +3155,7 @@ class SceneGridLayout extends SceneObjectBase {
3092
3155
  this.onResizeStop = (_, o, n) => {
3093
3156
  const child = this.getSceneLayoutChild(n.i);
3094
3157
  child.setState({
3095
- placement: __spreadProps(__spreadValues({}, child.state.placement), {
3158
+ placement: __spreadProps(__spreadValues$1({}, child.state.placement), {
3096
3159
  width: n.w,
3097
3160
  height: n.h
3098
3161
  })
@@ -3107,7 +3170,7 @@ class SceneGridLayout extends SceneObjectBase {
3107
3170
  const childSize = child.state.placement;
3108
3171
  if ((childSize == null ? void 0 : childSize.x) !== gridItem.x || (childSize == null ? void 0 : childSize.y) !== gridItem.y) {
3109
3172
  child.setState({
3110
- placement: __spreadProps(__spreadValues({}, child.state.placement), {
3173
+ placement: __spreadProps(__spreadValues$1({}, child.state.placement), {
3111
3174
  x: gridItem.x,
3112
3175
  y: gridItem.y
3113
3176
  })
@@ -3143,7 +3206,7 @@ class SceneGridLayout extends SceneObjectBase {
3143
3206
  const yDiff = firstPanelYPos - (rowY + 1);
3144
3207
  let yMax = rowY;
3145
3208
  for (const panel of rowChildren) {
3146
- const newSize = __spreadValues({}, panel.state.placement);
3209
+ const newSize = __spreadValues$1({}, panel.state.placement);
3147
3210
  newSize.y = (_d = newSize.y) != null ? _d : rowY;
3148
3211
  newSize.y -= yDiff;
3149
3212
  if (newSize.y > ((_e = panel.state.placement) == null ? void 0 : _e.y)) {
@@ -3185,7 +3248,7 @@ class SceneGridLayout extends SceneObjectBase {
3185
3248
  pushChildDown(child, amount) {
3186
3249
  var _a;
3187
3250
  child.setState({
3188
- placement: __spreadProps(__spreadValues({}, child.state.placement), {
3251
+ placement: __spreadProps(__spreadValues$1({}, child.state.placement), {
3189
3252
  y: ((_a = child.state.placement) == null ? void 0 : _a.y) + amount
3190
3253
  })
3191
3254
  });
@@ -3253,7 +3316,7 @@ class SceneGridLayout extends SceneObjectBase {
3253
3316
  cells = sortGridLayout(cells);
3254
3317
  if (width < 768) {
3255
3318
  this._skipOnLayoutChange = true;
3256
- return cells.map((cell) => __spreadProps(__spreadValues({}, cell), { w: 24 }));
3319
+ return cells.map((cell) => __spreadProps(__spreadValues$1({}, cell), { w: 24 }));
3257
3320
  }
3258
3321
  this._skipOnLayoutChange = false;
3259
3322
  return cells;
@@ -3319,6 +3382,194 @@ function sortGridLayout(layout) {
3319
3382
  return [...layout].sort((a, b) => a.y - b.y || a.x - b.x);
3320
3383
  }
3321
3384
 
3385
+ var __defProp = Object.defineProperty;
3386
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3387
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3388
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
3389
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3390
+ var __spreadValues = (a, b) => {
3391
+ for (var prop in b || (b = {}))
3392
+ if (__hasOwnProp.call(b, prop))
3393
+ __defNormalProp(a, prop, b[prop]);
3394
+ if (__getOwnPropSymbols)
3395
+ for (var prop of __getOwnPropSymbols(b)) {
3396
+ if (__propIsEnum.call(b, prop))
3397
+ __defNormalProp(a, prop, b[prop]);
3398
+ }
3399
+ return a;
3400
+ };
3401
+ function useAppQueryParams() {
3402
+ const location = reactRouterDom.useLocation();
3403
+ return runtime.locationSearchToObject(location.search || "");
3404
+ }
3405
+ function getLinkUrlWithAppUrlState(path, params, preserveParams) {
3406
+ const paramsCopy = __spreadValues({}, params);
3407
+ if (preserveParams) {
3408
+ for (const key of Object.keys(paramsCopy)) {
3409
+ if (!preserveParams.includes(key)) {
3410
+ delete paramsCopy[key];
3411
+ }
3412
+ }
3413
+ }
3414
+ return data.urlUtil.renderUrl(path, paramsCopy);
3415
+ }
3416
+
3417
+ const sceneCache = /* @__PURE__ */ new Map();
3418
+ class SceneApp extends SceneObjectBase {
3419
+ }
3420
+ SceneApp.Component = ({ model }) => {
3421
+ const { pages } = model.useState();
3422
+ return /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, pages.map((page) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
3423
+ key: page.state.url,
3424
+ exact: false,
3425
+ path: page.state.url,
3426
+ render: () => {
3427
+ return page && /* @__PURE__ */ React__default["default"].createElement(page.Component, {
3428
+ model: page
3429
+ });
3430
+ }
3431
+ })));
3432
+ };
3433
+ class SceneAppPage extends SceneObjectBase {
3434
+ }
3435
+ SceneAppPage.Component = SceneAppPageRenderer;
3436
+ function SceneAppPageRenderer({ model }) {
3437
+ var _a;
3438
+ const { tabs, drilldowns, url, routePath } = model.state;
3439
+ const routes = [];
3440
+ if (tabs) {
3441
+ for (const page2 of tabs) {
3442
+ routes.push(
3443
+ /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
3444
+ exact: true,
3445
+ key: page2.state.url,
3446
+ path: (_a = page2.state.routePath) != null ? _a : page2.state.url,
3447
+ render: () => {
3448
+ return /* @__PURE__ */ React__default["default"].createElement(page2.Component, {
3449
+ model: page2
3450
+ });
3451
+ }
3452
+ })
3453
+ );
3454
+ if (page2.state.drilldowns) {
3455
+ for (const drilldown of page2.state.drilldowns) {
3456
+ routes.push(
3457
+ /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
3458
+ exact: false,
3459
+ key: drilldown.routePath,
3460
+ path: drilldown.routePath,
3461
+ render: () => {
3462
+ return /* @__PURE__ */ React__default["default"].createElement(SceneAppDrilldownViewRender, {
3463
+ drilldown,
3464
+ parent: page2
3465
+ });
3466
+ }
3467
+ })
3468
+ );
3469
+ }
3470
+ }
3471
+ }
3472
+ return /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, routes);
3473
+ }
3474
+ if (drilldowns) {
3475
+ for (const drilldown of drilldowns) {
3476
+ routes.push(
3477
+ /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
3478
+ key: drilldown.routePath,
3479
+ exact: false,
3480
+ path: drilldown.routePath,
3481
+ render: () => {
3482
+ return /* @__PURE__ */ React__default["default"].createElement(SceneAppDrilldownViewRender, {
3483
+ drilldown,
3484
+ parent: model
3485
+ });
3486
+ }
3487
+ })
3488
+ );
3489
+ }
3490
+ }
3491
+ let page = /* @__PURE__ */ React__default["default"].createElement(ScenePageRenderer, {
3492
+ page: model
3493
+ });
3494
+ if (model.parent instanceof SceneAppPage) {
3495
+ page = /* @__PURE__ */ React__default["default"].createElement(ScenePageRenderer, {
3496
+ page: model.parent,
3497
+ activeTab: model,
3498
+ tabs: model.parent.state.tabs
3499
+ });
3500
+ }
3501
+ return /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
3502
+ key: url,
3503
+ exact: true,
3504
+ path: routePath != null ? routePath : url,
3505
+ render: () => {
3506
+ return page;
3507
+ }
3508
+ }), routes);
3509
+ }
3510
+ function ScenePageRenderer({ page, tabs, activeTab }) {
3511
+ const [isInitialized, setIsInitialized] = React.useState(false);
3512
+ const params = useAppQueryParams();
3513
+ const routeMatch = reactRouterDom.useRouteMatch();
3514
+ let scene = sceneCache.get(routeMatch.url);
3515
+ if (!scene) {
3516
+ scene = activeTab ? activeTab.state.getScene(routeMatch) : page.state.getScene(routeMatch);
3517
+ sceneCache.set(routeMatch.url, scene);
3518
+ }
3519
+ React.useEffect(() => {
3520
+ if (!isInitialized && scene) {
3521
+ scene.initUrlSync();
3522
+ setIsInitialized(true);
3523
+ }
3524
+ }, [isInitialized, scene]);
3525
+ if (!isInitialized) {
3526
+ return null;
3527
+ }
3528
+ const pageNav = {
3529
+ text: page.state.title,
3530
+ subTitle: page.state.subTitle,
3531
+ url: getLinkUrlWithAppUrlState(page.state.url, params, page.state.preserveUrlKeys),
3532
+ hideFromBreadcrumbs: page.state.hideFromBreadcrumbs,
3533
+ parentItem: getParentBreadcrumbs(page.state.getParentPage ? page.state.getParentPage() : page.parent, params)
3534
+ };
3535
+ if (tabs) {
3536
+ pageNav.children = tabs.map((tab) => {
3537
+ return {
3538
+ text: tab.state.title,
3539
+ active: activeTab === tab,
3540
+ url: getLinkUrlWithAppUrlState(tab.state.url, params, tab.state.preserveUrlKeys),
3541
+ parentItem: pageNav
3542
+ };
3543
+ });
3544
+ }
3545
+ return /* @__PURE__ */ React__default["default"].createElement(runtime.PluginPage, {
3546
+ pageNav
3547
+ }, /* @__PURE__ */ React__default["default"].createElement(scene.Component, {
3548
+ model: scene
3549
+ }));
3550
+ }
3551
+ function SceneAppDrilldownViewRender(props) {
3552
+ const routeMatch = reactRouterDom.useRouteMatch();
3553
+ const scene = props.drilldown.getPage(routeMatch, props.parent);
3554
+ return /* @__PURE__ */ React__default["default"].createElement(scene.Component, {
3555
+ model: scene
3556
+ });
3557
+ }
3558
+ function getParentBreadcrumbs(parent, params) {
3559
+ if (parent instanceof SceneAppPage) {
3560
+ return {
3561
+ text: parent.state.title,
3562
+ url: getLinkUrlWithAppUrlState(parent.state.url, params, parent.state.preserveUrlKeys),
3563
+ hideFromBreadcrumbs: parent.state.hideFromBreadcrumbs,
3564
+ parentItem: getParentBreadcrumbs(
3565
+ parent.state.getParentPage ? parent.state.getParentPage() : parent.parent,
3566
+ params
3567
+ )
3568
+ };
3569
+ }
3570
+ return void 0;
3571
+ }
3572
+
3322
3573
  exports.ConstantVariable = ConstantVariable;
3323
3574
  exports.CustomVariable = CustomVariable;
3324
3575
  exports.DataSourceVariable = DataSourceVariable;
@@ -3326,6 +3577,8 @@ exports.EmbeddedScene = EmbeddedScene;
3326
3577
  exports.FormatRegistryID = FormatRegistryID;
3327
3578
  exports.NestedScene = NestedScene;
3328
3579
  exports.QueryVariable = QueryVariable;
3580
+ exports.SceneApp = SceneApp;
3581
+ exports.SceneAppPage = SceneAppPage;
3329
3582
  exports.SceneByFrameRepeater = SceneByFrameRepeater;
3330
3583
  exports.SceneCanvasText = SceneCanvasText;
3331
3584
  exports.SceneControlsSpacer = SceneControlsSpacer;