@grafana/scenes 0.0.13 → 0.0.15
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/esm/components/EmbeddedScene.js +3 -2
- package/dist/esm/components/EmbeddedScene.js.map +1 -1
- package/dist/esm/components/SceneApp/utils.js.map +1 -1
- package/dist/esm/components/SceneRefreshPicker.js +102 -0
- package/dist/esm/components/SceneRefreshPicker.js.map +1 -0
- package/dist/esm/components/SceneTimePicker.js +3 -9
- package/dist/esm/components/SceneTimePicker.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js +3 -0
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +19 -10
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/components/layout/SceneGridRow.js +9 -6
- package/dist/esm/components/layout/SceneGridRow.js.map +1 -1
- package/dist/esm/core/SceneComponentWrapper.js +2 -2
- package/dist/esm/core/SceneComponentWrapper.js.map +1 -1
- package/dist/esm/core/SceneObjectBase.js +3 -4
- package/dist/esm/core/SceneObjectBase.js.map +1 -1
- package/dist/esm/core/sceneGraph.js +19 -2
- package/dist/esm/core/sceneGraph.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +32 -3
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/utils/writeSceneLog.js +8 -0
- package/dist/esm/utils/writeSceneLog.js.map +1 -0
- package/dist/esm/variables/VariableDependencyConfig.js +19 -8
- package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
- package/dist/esm/variables/VariableValueRecorder.js +56 -0
- package/dist/esm/variables/VariableValueRecorder.js.map +1 -0
- package/dist/esm/variables/components/VariableValueInput.js +31 -0
- package/dist/esm/variables/components/VariableValueInput.js.map +1 -0
- package/dist/esm/variables/components/VariableValueSelectors.js +34 -8
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
- package/dist/esm/variables/interpolation/defaults.js +14 -3
- package/dist/esm/variables/interpolation/defaults.js.map +1 -1
- package/dist/esm/variables/interpolation/sceneInterpolator.js +2 -18
- package/dist/esm/variables/interpolation/sceneInterpolator.js.map +1 -1
- package/dist/esm/variables/lookupVariable.js +20 -0
- package/dist/esm/variables/lookupVariable.js.map +1 -0
- package/dist/esm/variables/sets/SceneVariableSet.js +28 -29
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/esm/variables/types.js.map +1 -1
- package/dist/esm/variables/utils.js +11 -0
- package/dist/esm/variables/utils.js.map +1 -0
- package/dist/esm/variables/variants/TextBoxVariable.js +61 -0
- package/dist/esm/variables/variants/TextBoxVariable.js.map +1 -0
- package/dist/esm/variables/variants/query/QueryVariable.js +1 -3
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
- package/dist/index.d.ts +83 -12
- package/dist/index.js +758 -425
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import React, { CSSProperties } from 'react';
|
|
3
2
|
import { Observable, Observer, Subscription, Unsubscribable } from 'rxjs';
|
|
4
|
-
import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeZone, TimeRange, ScopedVars, DataTransformerConfig, DataSourceRef, DataQuery, Registry, RegistryItem, VariableRefresh, VariableSort, FieldConfigSource, PanelPlugin, AbsoluteTimeRange, DataFrame } from '@grafana/data';
|
|
3
|
+
import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeZone, TimeRange, ScopedVars, DataTransformerConfig, DataSourceRef, DataQuery, Registry, RegistryItem, VariableRefresh, VariableSort, FieldConfigSource, PanelPlugin, AbsoluteTimeRange, InterpolateFunction, DataFrame } from '@grafana/data';
|
|
5
4
|
import { VariableType, VariableHide, VariableModel } from '@grafana/schema';
|
|
6
5
|
import { IconName } from '@grafana/ui';
|
|
7
6
|
import ReactGridLayout from 'react-grid-layout';
|
|
@@ -52,7 +51,14 @@ interface SceneVariableSetState extends SceneObjectStatePlain {
|
|
|
52
51
|
variables: SceneVariable[];
|
|
53
52
|
}
|
|
54
53
|
interface SceneVariables extends SceneObject<SceneVariableSetState> {
|
|
54
|
+
/**
|
|
55
|
+
* Will look for and return variable matching name
|
|
56
|
+
*/
|
|
55
57
|
getByName(name: string): SceneVariable | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Will return true if the variable is loading or waiting for an update to complete.
|
|
60
|
+
*/
|
|
61
|
+
isVariableLoadingOrWaitingToUpdate(variable: SceneVariable): boolean;
|
|
56
62
|
}
|
|
57
63
|
declare class SceneVariableValueChangedEvent extends BusEventWithPayload<SceneVariable> {
|
|
58
64
|
static type: string;
|
|
@@ -63,9 +69,9 @@ interface SceneVariableDependencyConfigLike {
|
|
|
63
69
|
/** Used to check for dependency on a specific variable */
|
|
64
70
|
hasDependencyOn(name: string): boolean;
|
|
65
71
|
/**
|
|
66
|
-
* Will be called when
|
|
72
|
+
* Will be called when the VariableSet have completed an update process
|
|
67
73
|
**/
|
|
68
|
-
|
|
74
|
+
variableUpdatesCompleted(changedVariables: Set<SceneVariable>): void;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
interface SceneObjectStatePlain {
|
|
@@ -197,6 +203,11 @@ declare class SceneObjectStateChangedEvent extends BusEventWithPayload<SceneObje
|
|
|
197
203
|
|
|
198
204
|
type CustomFormatterFn = (value: unknown, legacyVariableModel: Partial<VariableModel>, legacyDefaultFormatter?: CustomFormatterFn) => string;
|
|
199
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Will walk the scene object graph up to the root looking for the first variable with the specified name
|
|
208
|
+
*/
|
|
209
|
+
declare function lookupVariable(name: string, sceneObject: SceneObject): SceneVariable | null | undefined;
|
|
210
|
+
|
|
200
211
|
/**
|
|
201
212
|
* Get the closest node with variables
|
|
202
213
|
*/
|
|
@@ -221,6 +232,10 @@ declare function getLayout(scene: SceneObject): SceneObject<SceneLayoutState>;
|
|
|
221
232
|
* Interpolates the given string using the current scene object as context. *
|
|
222
233
|
*/
|
|
223
234
|
declare function interpolate(sceneObject: SceneObject, value: string | undefined | null, scopedVars?: ScopedVars, format?: string | CustomFormatterFn): string;
|
|
235
|
+
/**
|
|
236
|
+
* Checks if the variable is currently loading or waiting to update
|
|
237
|
+
*/
|
|
238
|
+
declare function hasVariableDependencyInLoadingState(sceneObject: SceneObject): boolean;
|
|
224
239
|
declare const sceneGraph: {
|
|
225
240
|
getVariables: typeof getVariables;
|
|
226
241
|
getData: typeof getData;
|
|
@@ -228,6 +243,8 @@ declare const sceneGraph: {
|
|
|
228
243
|
getSceneEditor: typeof getSceneEditor;
|
|
229
244
|
getLayout: typeof getLayout;
|
|
230
245
|
interpolate: typeof interpolate;
|
|
246
|
+
lookupVariable: typeof lookupVariable;
|
|
247
|
+
hasVariableDependencyInLoadingState: typeof hasVariableDependencyInLoadingState;
|
|
231
248
|
};
|
|
232
249
|
|
|
233
250
|
declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
|
|
@@ -235,8 +252,6 @@ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneOb
|
|
|
235
252
|
private _subject;
|
|
236
253
|
private _state;
|
|
237
254
|
private _events;
|
|
238
|
-
/** Incremented in SceneComponentWrapper, useful for tests and rendering optimizations */
|
|
239
|
-
protected _renderCount: number;
|
|
240
255
|
protected _parent?: SceneObject;
|
|
241
256
|
protected _subs: Subscription;
|
|
242
257
|
protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
|
|
@@ -343,15 +358,19 @@ interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
|
|
|
343
358
|
* If not specified the default behavior is to trigger a re-render
|
|
344
359
|
*/
|
|
345
360
|
onReferencedVariableValueChanged?: () => void;
|
|
361
|
+
/**
|
|
362
|
+
* Optional way to customize how to handle when the variable system has completed an update
|
|
363
|
+
*/
|
|
364
|
+
onVariableUpdatesCompleted?: (changedVariables: Set<SceneVariable>, dependencyChanged: boolean) => void;
|
|
346
365
|
}
|
|
347
366
|
declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
|
|
348
367
|
private _sceneObject;
|
|
368
|
+
private _options;
|
|
349
369
|
private _state;
|
|
350
370
|
private _dependencies;
|
|
351
371
|
private _statePaths?;
|
|
352
|
-
private _onReferencedVariableValueChanged;
|
|
353
372
|
scanCount: number;
|
|
354
|
-
constructor(_sceneObject: SceneObject<TState>,
|
|
373
|
+
constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
|
|
355
374
|
/**
|
|
356
375
|
* Used to check for dependency on a specific variable
|
|
357
376
|
*/
|
|
@@ -359,7 +378,7 @@ declare class VariableDependencyConfig<TState extends SceneObjectState> implemen
|
|
|
359
378
|
/**
|
|
360
379
|
* This is called whenever any set of variables have new values. It up to this implementation to check if it's relevant given the current dependencies.
|
|
361
380
|
*/
|
|
362
|
-
|
|
381
|
+
variableUpdatesCompleted(changedVariables: Set<SceneVariable>): void;
|
|
363
382
|
/**
|
|
364
383
|
* Only way to force a re-render is to update state right now
|
|
365
384
|
*/
|
|
@@ -377,6 +396,7 @@ interface QueryRunnerState extends SceneObjectStatePlain {
|
|
|
377
396
|
minInterval?: string;
|
|
378
397
|
maxDataPoints?: number;
|
|
379
398
|
maxDataPointsFromWidth?: boolean;
|
|
399
|
+
isWaitingForVariables?: boolean;
|
|
380
400
|
}
|
|
381
401
|
interface DataQueryExtended extends DataQuery {
|
|
382
402
|
[key: string]: any;
|
|
@@ -384,8 +404,14 @@ interface DataQueryExtended extends DataQuery {
|
|
|
384
404
|
declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> {
|
|
385
405
|
private _querySub?;
|
|
386
406
|
private _containerWidth?;
|
|
407
|
+
private _variableValueRecorder;
|
|
387
408
|
protected _variableDependency: VariableDependencyConfig<QueryRunnerState>;
|
|
388
409
|
activate(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Handles some tricky cases where we need to run queries even when they have not changed in case
|
|
412
|
+
* the query execution on activate was stopped due to VariableSet still not having processed all variables.
|
|
413
|
+
*/
|
|
414
|
+
private onVariableUpdatesCompleted;
|
|
389
415
|
private shouldRunQueriesOnActivate;
|
|
390
416
|
deactivate(): void;
|
|
391
417
|
setContainerWidth(width: number): void;
|
|
@@ -443,7 +469,7 @@ declare class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> im
|
|
|
443
469
|
private _variablesToUpdate;
|
|
444
470
|
/** Variables currently updating */
|
|
445
471
|
private _updating;
|
|
446
|
-
private
|
|
472
|
+
private _variableValueRecorder;
|
|
447
473
|
getByName(name: string): SceneVariable | undefined;
|
|
448
474
|
/**
|
|
449
475
|
* Subscribes to child variable value changes
|
|
@@ -478,6 +504,7 @@ declare class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> im
|
|
|
478
504
|
*/
|
|
479
505
|
private hasDependendencyInUpdateQueue;
|
|
480
506
|
private handleVariableValueChanged;
|
|
507
|
+
private addDependentVariablesToUpdateQueue;
|
|
481
508
|
/**
|
|
482
509
|
* Walk scene object graph and update all objects that depend on variables that have changed
|
|
483
510
|
*/
|
|
@@ -486,6 +513,10 @@ declare class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> im
|
|
|
486
513
|
* Recursivly walk the full scene object graph and notify all objects with dependencies that include any of changed variables
|
|
487
514
|
*/
|
|
488
515
|
private traverseSceneAndNotify;
|
|
516
|
+
/**
|
|
517
|
+
* Return true if variable is waiting to update or currently updating
|
|
518
|
+
*/
|
|
519
|
+
isVariableLoadingOrWaitingToUpdate(variable: SceneVariable): boolean;
|
|
489
520
|
}
|
|
490
521
|
|
|
491
522
|
interface ConstantVariableState extends SceneVariableState {
|
|
@@ -571,7 +602,6 @@ interface QueryVariableState extends MultiValueVariableState {
|
|
|
571
602
|
}
|
|
572
603
|
declare class QueryVariable extends MultiValueVariable<QueryVariableState> {
|
|
573
604
|
private updateSubscription?;
|
|
574
|
-
private dataSourceSubject?;
|
|
575
605
|
protected _variableDependency: VariableDependencyConfig<QueryVariableState>;
|
|
576
606
|
constructor(initialState: Partial<QueryVariableState>);
|
|
577
607
|
activate(): void;
|
|
@@ -602,6 +632,22 @@ declare class TestVariable extends MultiValueVariable<TestVariableState> {
|
|
|
602
632
|
static Component: ({ model }: SceneComponentProps<MultiValueVariable>) => JSX.Element;
|
|
603
633
|
}
|
|
604
634
|
|
|
635
|
+
interface TextBoxVariableState extends SceneVariableState {
|
|
636
|
+
value: string;
|
|
637
|
+
}
|
|
638
|
+
declare class TextBoxVariable extends SceneObjectBase<TextBoxVariableState> implements SceneVariable<TextBoxVariableState> {
|
|
639
|
+
protected _urlSync: SceneObjectUrlSyncHandler<TextBoxVariableState>;
|
|
640
|
+
constructor(initialState: Partial<TextBoxVariableState>);
|
|
641
|
+
getValue(): VariableValue;
|
|
642
|
+
setValue(newValue: string): void;
|
|
643
|
+
private getKey;
|
|
644
|
+
getUrlState(state: TextBoxVariableState): {
|
|
645
|
+
[x: string]: string;
|
|
646
|
+
};
|
|
647
|
+
updateFromUrl(values: SceneObjectUrlValues): void;
|
|
648
|
+
static Component: ({ model }: SceneComponentProps<TextBoxVariable>) => JSX.Element;
|
|
649
|
+
}
|
|
650
|
+
|
|
605
651
|
declare class UrlSyncManager {
|
|
606
652
|
private sceneRoot;
|
|
607
653
|
private locationListenerUnsub;
|
|
@@ -655,6 +701,8 @@ interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneLayoutChi
|
|
|
655
701
|
options: DeepPartial<TOptions>;
|
|
656
702
|
fieldConfig: FieldConfigSource<DeepPartial<TFieldConfig>>;
|
|
657
703
|
pluginVersion?: string;
|
|
704
|
+
displayMode?: 'default' | 'transparent';
|
|
705
|
+
hoverHeader?: boolean;
|
|
658
706
|
pluginLoadError?: string;
|
|
659
707
|
}
|
|
660
708
|
declare class VizPanel<TOptions = {}, TFieldConfig = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
|
|
@@ -669,6 +717,7 @@ declare class VizPanel<TOptions = {}, TFieldConfig = {}> extends SceneObjectBase
|
|
|
669
717
|
onChangeTimeRange: (timeRange: AbsoluteTimeRange) => void;
|
|
670
718
|
onOptionsChange: (options: TOptions) => void;
|
|
671
719
|
onFieldConfigChange: (fieldConfig: FieldConfigSource<TFieldConfig>) => void;
|
|
720
|
+
interpolate: InterpolateFunction;
|
|
672
721
|
}
|
|
673
722
|
|
|
674
723
|
interface NestedSceneState extends SceneLayoutChildState {
|
|
@@ -727,6 +776,28 @@ declare class SceneTimePicker extends SceneObjectBase<SceneTimePickerState> {
|
|
|
727
776
|
}
|
|
728
777
|
declare function SceneTimePickerRenderer({ model }: SceneComponentProps<SceneTimePicker>): JSX.Element | null;
|
|
729
778
|
|
|
779
|
+
interface SceneRefreshPickerState extends SceneObjectStatePlain {
|
|
780
|
+
refresh: string;
|
|
781
|
+
intervals?: string[];
|
|
782
|
+
isOnCanvas?: boolean;
|
|
783
|
+
}
|
|
784
|
+
declare class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState> {
|
|
785
|
+
static Component: typeof SceneRefreshPickerRenderer;
|
|
786
|
+
protected _urlSync: SceneObjectUrlSyncConfig<SceneObjectState>;
|
|
787
|
+
private _intervalTimer;
|
|
788
|
+
constructor(state: Partial<SceneRefreshPickerState>);
|
|
789
|
+
activate(): void;
|
|
790
|
+
deactivate(): void;
|
|
791
|
+
onRefresh: () => void;
|
|
792
|
+
onIntervalChanged: (interval: string) => void;
|
|
793
|
+
getUrlState(): {
|
|
794
|
+
refresh: string;
|
|
795
|
+
};
|
|
796
|
+
updateFromUrl(values: SceneObjectUrlValues): void;
|
|
797
|
+
private setupIntervalTimer;
|
|
798
|
+
}
|
|
799
|
+
declare function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneRefreshPicker>): JSX.Element;
|
|
800
|
+
|
|
730
801
|
interface RepeatOptions extends SceneObjectStatePlain {
|
|
731
802
|
body: SceneObject<SceneLayoutState>;
|
|
732
803
|
getLayoutChild(data: PanelData, frame: DataFrame, frameIndex: number): SceneLayoutChild;
|
|
@@ -843,4 +914,4 @@ interface SceneAppDrilldownView {
|
|
|
843
914
|
getPage: (routeMatch: SceneRouteMatch<any>, parent: SceneAppPage) => SceneAppPage;
|
|
844
915
|
}
|
|
845
916
|
|
|
846
|
-
export { ConstantVariable, CustomFormatterFn, CustomVariable, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, FormatRegistryID, FormatVariable, NestedScene, QueryRunnerState, QueryVariable, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataNode, SceneDataState, SceneDataTransformer, SceneEditor, SceneEditorState, SceneFlexLayout, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChild, SceneLayoutChildOptions, SceneLayoutChildState, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectStatePlain, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryRunner, SceneRouteMatch, SceneTimePicker, SceneTimeRange, SceneTimeRangeLike, SceneTimeRangeState, SceneToolbarButton, SceneToolbarInput, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, TestVariable, UrlSyncManager, ValidateAndUpdateResult, VariableDependencyConfig, VariableValue, VariableValueCustom, VariableValueOption, VariableValueSelectors, VariableValueSingle, VizPanel, VizPanelState, formatRegistry, isSceneObject, sceneGraph };
|
|
917
|
+
export { ConstantVariable, CustomFormatterFn, CustomVariable, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, FormatRegistryID, FormatVariable, NestedScene, QueryRunnerState, QueryVariable, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataNode, SceneDataState, SceneDataTransformer, SceneEditor, SceneEditorState, SceneFlexLayout, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChild, SceneLayoutChildOptions, SceneLayoutChildState, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectStatePlain, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryRunner, SceneRefreshPicker, SceneRouteMatch, SceneTimePicker, SceneTimeRange, SceneTimeRangeLike, SceneTimeRangeState, SceneToolbarButton, SceneToolbarInput, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, TestVariable, TextBoxVariable, UrlSyncManager, ValidateAndUpdateResult, VariableDependencyConfig, VariableValue, VariableValueCustom, VariableValueOption, VariableValueSelectors, VariableValueSingle, VizPanel, VizPanelState, formatRegistry, isSceneObject, sceneGraph };
|