@grafana/scenes 4.5.5 → 4.5.7--canary.685.8631031033.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import React$1, { CSSProperties, ComponentType } from 'react';
4
4
  import * as rxjs from 'rxjs';
5
5
  import { Observable, Unsubscribable, MonoTypeOperatorFunction, Subscription, ReplaySubject } from 'rxjs';
6
6
  import * as _grafana_schema from '@grafana/schema';
7
- import { VariableType, VariableHide, TimeZone, DataTopic, DataSourceRef, VariableRefresh, DataQuery as DataQuery$1, LoadingState, DashboardCursorSync, MatcherConfig, TableFieldOptions } from '@grafana/schema';
7
+ import { VariableType, VariableHide, TimeZone, DataTopic, DataSourceRef, DataQuery as DataQuery$1, VariableRefresh, LoadingState, DashboardCursorSync, MatcherConfig, TableFieldOptions } from '@grafana/schema';
8
8
  import { PanelContext, IconName } from '@grafana/ui';
9
9
  import ReactGridLayout from 'react-grid-layout';
10
10
  import { RouteComponentProps } from 'react-router-dom';
@@ -451,6 +451,139 @@ interface MacroVariableConstructor {
451
451
  */
452
452
  declare function registerVariableMacro(name: string, macro: MacroVariableConstructor): () => void;
453
453
 
454
+ interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
455
+ /**
456
+ * State paths to scan / extract variable dependencies from. Leave empty to scan all paths.
457
+ */
458
+ statePaths?: Array<keyof TState | '*'>;
459
+ /**
460
+ * Explicit list of variable names to depend on. Leave empty to scan state for dependencies.
461
+ */
462
+ variableNames?: string[];
463
+ /**
464
+ * Optional way to customize how to handle when a dependent variable changes
465
+ * If not specified the default behavior is to trigger a re-render
466
+ */
467
+ onReferencedVariableValueChanged?: (variable: SceneVariable) => void;
468
+ /**
469
+ * Two scenarios trigger this callback to be called.
470
+ * 1. When any direct dependency changed value
471
+ * 2. In case hasDependencyInLoadingState was called and returned true we really care about any variable update. So in this scenario this callback is called
472
+ * after any variable update completes. This is to cover scenarios where an object is waiting for indirect dependencies to complete.
473
+ */
474
+ onVariableUpdateCompleted?: () => void;
475
+ /**
476
+ * Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
477
+ */
478
+ onAnyVariableChanged?: (variable: SceneVariable) => void;
479
+ }
480
+ declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
481
+ private _sceneObject;
482
+ private _options;
483
+ private _state;
484
+ private _dependencies;
485
+ private _statePaths?;
486
+ private _isWaitingForVariables;
487
+ scanCount: number;
488
+ constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
489
+ /**
490
+ * Used to check for dependency on a specific variable
491
+ */
492
+ hasDependencyOn(name: string): boolean;
493
+ /**
494
+ * This is called whenever any set of variables have new values. It is up to this implementation to check if it's relevant given the current dependencies.
495
+ */
496
+ variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void;
497
+ hasDependencyInLoadingState(): boolean;
498
+ getNames(): Set<string>;
499
+ /**
500
+ * Update variableNames
501
+ */
502
+ setVariableNames(varNames: string[]): void;
503
+ setPaths(paths: Array<keyof TState | '*'>): void;
504
+ private scanStateForDependencies;
505
+ private extractVariablesFrom;
506
+ }
507
+
508
+ interface QueryRunnerState extends SceneObjectState {
509
+ data?: PanelData;
510
+ queries: DataQueryExtended[];
511
+ datasource?: DataSourceRef;
512
+ minInterval?: string;
513
+ maxDataPoints?: number;
514
+ liveStreaming?: boolean;
515
+ maxDataPointsFromWidth?: boolean;
516
+ cacheTimeout?: DataQueryRequest['cacheTimeout'];
517
+ queryCachingTTL?: DataQueryRequest['queryCachingTTL'];
518
+ dataLayerFilter?: DataLayerFilter;
519
+ _hasFetchedData?: boolean;
520
+ }
521
+ interface DataQueryExtended extends DataQuery$1 {
522
+ [key: string]: any;
523
+ timeRangeCompare?: boolean;
524
+ }
525
+ declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> implements SceneDataProvider {
526
+ private _querySub?;
527
+ private _dataLayersSub?;
528
+ private _containerWidth?;
529
+ private _variableValueRecorder;
530
+ private _results;
531
+ private _scopedVars;
532
+ private _layerAnnotations?;
533
+ private _resultAnnotations?;
534
+ private _adhocFiltersVar?;
535
+ private _groupByVar?;
536
+ getResultsStream(): ReplaySubject<SceneDataProviderResult>;
537
+ protected _variableDependency: VariableDependencyConfig<QueryRunnerState>;
538
+ constructor(initialState: QueryRunnerState);
539
+ private _onActivate;
540
+ private _handleDataLayers;
541
+ private _onLayersReceived;
542
+ /**
543
+ * This tries to start a new query whenever a variable completes or is changed.
544
+ *
545
+ * We care about variable update completions even when the variable has not changed and even when it is not a direct dependency.
546
+ * Example: Variables A and B (B depends on A). A update depends on time range. So when time change query runner will
547
+ * find that variable A is loading which is a dependency on of variable B so will set _isWaitingForVariables to true and
548
+ * not issue any query.
549
+ *
550
+ * When A completes it's loading (with no value change, so B never updates) it will cause a call of this function letting
551
+ * the query runner know that A has completed, and in case _isWaitingForVariables we try to run the query. The query will
552
+ * only run if all variables are in a non loading state so in other scenarios where a query depends on many variables this will
553
+ * be called many times until all dependencies are in a non loading state. *
554
+ */
555
+ private onVariableUpdatesCompleted;
556
+ /**
557
+ * Check if value changed is a adhoc filter o group by variable that did not exist when we issued the last query
558
+ */
559
+ private onAnyVariableChanged;
560
+ private _isRelevantAutoVariable;
561
+ private shouldRunQueriesOnActivate;
562
+ private _isDataTimeRangeStale;
563
+ private _onDeactivate;
564
+ setContainerWidth(width: number): void;
565
+ isDataReadyToDisplay(): boolean;
566
+ runQueries(): void;
567
+ private getMaxDataPoints;
568
+ cancelQuery(): void;
569
+ private runWithTimeRange;
570
+ clone(withState?: Partial<QueryRunnerState>): this;
571
+ private prepareRequests;
572
+ private onDataReceived;
573
+ private _combineDataLayers;
574
+ private _setNoDataState;
575
+ /**
576
+ * Will walk up the scene graph and find the closest time range compare object
577
+ * It performs buttom-up search, including shallow search across object children for supporting controls/header actions
578
+ */
579
+ private getTimeCompare;
580
+ /**
581
+ * Walk up scene graph and find the closest filterset with matching data source
582
+ */
583
+ private findAndSubscribeToAdHocFilters;
584
+ private _updateExplicitVariableDependencies;
585
+ }
586
+
454
587
  declare function renderPrometheusLabelFilters(filters: AdHocVariableFilter[]): string;
455
588
 
456
589
  declare class AdHocFiltersVariableUrlSyncHandler implements SceneObjectUrlSyncHandler {
@@ -548,10 +681,6 @@ declare class AdHocFiltersVariable extends SceneObjectBase<AdHocFiltersVariableS
548
681
  _getValuesFor(filter: AdHocVariableFilter): Promise<Array<SelectableValue<string>>>;
549
682
  _addWip(): void;
550
683
  _getOperators(): SelectableValue<string>[];
551
- /**
552
- * Get all queries in the scene that have the same datasource as this AdHocFilterSet
553
- */
554
- private _getSceneQueries;
555
684
  }
556
685
  declare function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>): JSX.Element;
557
686
 
@@ -563,60 +692,6 @@ declare class ConstantVariable extends SceneObjectBase<ConstantVariableState> im
563
692
  getValue(): VariableValue;
564
693
  }
565
694
 
566
- interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
567
- /**
568
- * State paths to scan / extract variable dependencies from. Leave empty to scan all paths.
569
- */
570
- statePaths?: Array<keyof TState | '*'>;
571
- /**
572
- * Explicit list of variable names to depend on. Leave empty to scan state for dependencies.
573
- */
574
- variableNames?: string[];
575
- /**
576
- * Optional way to customize how to handle when a dependent variable changes
577
- * If not specified the default behavior is to trigger a re-render
578
- */
579
- onReferencedVariableValueChanged?: (variable: SceneVariable) => void;
580
- /**
581
- * Two scenarios trigger this callback to be called.
582
- * 1. When any direct dependency changed value
583
- * 2. In case hasDependencyInLoadingState was called and returned true we really care about any variable update. So in this scenario this callback is called
584
- * after any variable update completes. This is to cover scenarios where an object is waiting for indirect dependencies to complete.
585
- */
586
- onVariableUpdateCompleted?: () => void;
587
- /**
588
- * Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
589
- */
590
- onAnyVariableChanged?: (variable: SceneVariable) => void;
591
- }
592
- declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
593
- private _sceneObject;
594
- private _options;
595
- private _state;
596
- private _dependencies;
597
- private _statePaths?;
598
- private _isWaitingForVariables;
599
- scanCount: number;
600
- constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
601
- /**
602
- * Used to check for dependency on a specific variable
603
- */
604
- hasDependencyOn(name: string): boolean;
605
- /**
606
- * This is called whenever any set of variables have new values. It is up to this implementation to check if it's relevant given the current dependencies.
607
- */
608
- variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void;
609
- hasDependencyInLoadingState(): boolean;
610
- getNames(): Set<string>;
611
- /**
612
- * Update variableNames
613
- */
614
- setVariableNames(varNames: string[]): void;
615
- setPaths(paths: Array<keyof TState | '*'>): void;
616
- private scanStateForDependencies;
617
- private extractVariablesFrom;
618
- }
619
-
620
695
  interface MultiValueVariableState extends SceneVariableState {
621
696
  value: VariableValue;
622
697
  text: VariableValue;
@@ -752,85 +827,6 @@ declare class TextBoxVariable extends SceneObjectBase<TextBoxVariableState> impl
752
827
  static Component: ({ model }: SceneComponentProps<TextBoxVariable>) => JSX.Element;
753
828
  }
754
829
 
755
- interface QueryRunnerState extends SceneObjectState {
756
- data?: PanelData;
757
- queries: DataQueryExtended[];
758
- datasource?: DataSourceRef;
759
- minInterval?: string;
760
- maxDataPoints?: number;
761
- liveStreaming?: boolean;
762
- maxDataPointsFromWidth?: boolean;
763
- cacheTimeout?: DataQueryRequest['cacheTimeout'];
764
- queryCachingTTL?: DataQueryRequest['queryCachingTTL'];
765
- dataLayerFilter?: DataLayerFilter;
766
- _hasFetchedData?: boolean;
767
- }
768
- interface DataQueryExtended extends DataQuery$1 {
769
- [key: string]: any;
770
- timeRangeCompare?: boolean;
771
- }
772
- declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> implements SceneDataProvider {
773
- private _querySub?;
774
- private _dataLayersSub?;
775
- private _containerWidth?;
776
- private _variableValueRecorder;
777
- private _results;
778
- private _scopedVars;
779
- private _layerAnnotations?;
780
- private _resultAnnotations?;
781
- private _adhocFiltersVar?;
782
- private _groupByVar?;
783
- getResultsStream(): ReplaySubject<SceneDataProviderResult>;
784
- protected _variableDependency: VariableDependencyConfig<QueryRunnerState>;
785
- constructor(initialState: QueryRunnerState);
786
- private _onActivate;
787
- private _handleDataLayers;
788
- private _onLayersReceived;
789
- /**
790
- * This tries to start a new query whenever a variable completes or is changed.
791
- *
792
- * We care about variable update completions even when the variable has not changed and even when it is not a direct dependency.
793
- * Example: Variables A and B (B depends on A). A update depends on time range. So when time change query runner will
794
- * find that variable A is loading which is a dependency on of variable B so will set _isWaitingForVariables to true and
795
- * not issue any query.
796
- *
797
- * When A completes it's loading (with no value change, so B never updates) it will cause a call of this function letting
798
- * the query runner know that A has completed, and in case _isWaitingForVariables we try to run the query. The query will
799
- * only run if all variables are in a non loading state so in other scenarios where a query depends on many variables this will
800
- * be called many times until all dependencies are in a non loading state. *
801
- */
802
- private onVariableUpdatesCompleted;
803
- /**
804
- * Check if value changed is a adhoc filter o group by variable that did not exist when we issued the last query
805
- */
806
- private onAnyVariableChanged;
807
- private _isRelevantAutoVariable;
808
- private shouldRunQueriesOnActivate;
809
- private _isDataTimeRangeStale;
810
- private _onDeactivate;
811
- setContainerWidth(width: number): void;
812
- isDataReadyToDisplay(): boolean;
813
- runQueries(): void;
814
- private getMaxDataPoints;
815
- cancelQuery(): void;
816
- private runWithTimeRange;
817
- clone(withState?: Partial<QueryRunnerState>): this;
818
- private prepareRequests;
819
- private onDataReceived;
820
- private _combineDataLayers;
821
- private _setNoDataState;
822
- /**
823
- * Will walk up the scene graph and find the closest time range compare object
824
- * It performs buttom-up search, including shallow search across object children for supporting controls/header actions
825
- */
826
- private getTimeCompare;
827
- /**
828
- * Walk up scene graph and find the closest filterset with matching data source
829
- */
830
- private findAndSubscribeToAdHocFilters;
831
- private _updateExplicitVariableDependencies;
832
- }
833
-
834
830
  interface QueryVariableState extends MultiValueVariableState {
835
831
  type: 'query';
836
832
  datasource: DataSourceRef | null;
@@ -905,10 +901,6 @@ declare class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
905
901
  value: VariableValueSingle[];
906
902
  text: string[];
907
903
  };
908
- /**
909
- * Get all queries in the scene that have the same datasource as this AggregationsSet
910
- */
911
- private _getSceneQueries;
912
904
  }
913
905
  declare function GroupByVariableRenderer({ model }: SceneComponentProps<MultiValueVariable>): JSX.Element;
914
906
 
@@ -1560,6 +1552,10 @@ interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectSta
1560
1552
  * Only shows header on hover, absolutly positioned above the panel.
1561
1553
  */
1562
1554
  hoverHeader?: boolean;
1555
+ /**
1556
+ * Offset hoverHeader position on the y axis
1557
+ */
1558
+ hoverHeaderOffset?: number;
1563
1559
  /**
1564
1560
  * Defines a menu in the top right of the panel. The menu object is only activated when the dropdown menu itself is shown.
1565
1561
  * So the best way to add dynamic menu actions and links is by adding them in a behavior attached to the menu.