@grafana/scenes 0.0.20 → 0.0.21
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/README.md +1 -1
- package/dist/esm/components/EmbeddedScene.js +10 -9
- package/dist/esm/components/EmbeddedScene.js.map +1 -1
- package/dist/esm/components/SceneByFrameRepeater.js +8 -8
- package/dist/esm/components/SceneByFrameRepeater.js.map +1 -1
- package/dist/esm/components/SceneReactObject.js +34 -0
- package/dist/esm/components/SceneReactObject.js.map +1 -0
- package/dist/esm/components/SceneRefreshPicker.js +8 -9
- package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanelMenu.js +42 -0
- package/dist/esm/components/VizPanel/VizPanelMenu.js.map +1 -0
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +11 -3
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/core/SceneObjectBase.js +21 -9
- package/dist/esm/core/SceneObjectBase.js.map +1 -1
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/querying/SceneDataTransformer.js +10 -9
- package/dist/esm/querying/SceneDataTransformer.js.map +1 -1
- package/dist/esm/querying/SceneQueryRunner.js +34 -18
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/sets/SceneVariableSet.js +29 -29
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/esm/variables/variants/query/QueryVariable.js +10 -12
- package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
- package/dist/index.d.ts +85 -30
- package/dist/index.js +452 -350
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
|
-
import { Observable,
|
|
3
|
-
import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeZone, TimeRange, DataTransformContext, DataFrame, ScopedVars,
|
|
4
|
-
import { VariableType, VariableHide, VariableModel } from '@grafana/schema';
|
|
2
|
+
import { Observable, Unsubscribable, MonoTypeOperatorFunction, Subscription } from 'rxjs';
|
|
3
|
+
import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeZone, TimeRange, DataTransformContext, DataFrame, ScopedVars, DataTransformerConfig, Registry, RegistryItem, DataSourceRef as DataSourceRef$1, VariableRefresh, VariableSort, PanelMenuItem, FieldConfigSource, PanelPlugin, AbsoluteTimeRange, InterpolateFunction, IconName as IconName$1 } from '@grafana/data';
|
|
4
|
+
import { VariableType, VariableHide, VariableModel, DataSourceRef, DataQuery } from '@grafana/schema';
|
|
5
5
|
import { IconName } from '@grafana/ui';
|
|
6
6
|
import ReactGridLayout from 'react-grid-layout';
|
|
7
7
|
|
|
@@ -117,7 +117,7 @@ interface SceneObject<TState extends SceneObjectState = SceneObjectState> {
|
|
|
117
117
|
/** This abstraction declares URL sync dependencies of a scene object. **/
|
|
118
118
|
readonly urlSync?: SceneObjectUrlSyncHandler<TState>;
|
|
119
119
|
/** Subscribe to state changes */
|
|
120
|
-
subscribeToState(
|
|
120
|
+
subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;
|
|
121
121
|
/** Subscribe to a scene event */
|
|
122
122
|
subscribeToEvent<T extends BusEvent>(typeFilter: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;
|
|
123
123
|
/** Publish an event and optionally bubble it up the scene */
|
|
@@ -126,9 +126,14 @@ interface SceneObject<TState extends SceneObjectState = SceneObjectState> {
|
|
|
126
126
|
useState(): TState;
|
|
127
127
|
/** How to modify state */
|
|
128
128
|
setState(state: Partial<TState>): void;
|
|
129
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Called when the Component is mounted. This will also activate any $data, $variables or $timeRange scene object on this level.
|
|
131
|
+
* Don't override this in your custom SceneObjects, instead use addActivationHandler from the constructor. The activation handler can return a deactivation handler.
|
|
132
|
+
**/
|
|
130
133
|
activate(): void;
|
|
131
|
-
/** Called when component unmounts.
|
|
134
|
+
/** Called when component unmounts. This will also deactivate any $data, $variables or $timeRange scene object on this level.
|
|
135
|
+
* Don't override this in your custom SceneObjects, instead use addActivationHandler from the constructor. The activation handler can return a deactivation handler.
|
|
136
|
+
*/
|
|
132
137
|
deactivate(): void;
|
|
133
138
|
/** Get the scene root */
|
|
134
139
|
getRoot(): SceneObject;
|
|
@@ -140,7 +145,14 @@ interface SceneObject<TState extends SceneObjectState = SceneObjectState> {
|
|
|
140
145
|
Editor(props: SceneComponentProps<SceneObject<TState>>): React.ReactElement | null;
|
|
141
146
|
/** Force a re-render, should only be needed when variable values change */
|
|
142
147
|
forceRender(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Allows external code to register code that is executed on activate and deactivate. This allow you
|
|
150
|
+
* to wire up scene objects that need to respond to state changes in other objects from the outside.
|
|
151
|
+
**/
|
|
152
|
+
addActivationHandler(handler: SceneActivationHandler): void;
|
|
143
153
|
}
|
|
154
|
+
type SceneActivationHandler = () => SceneDeactivationHandler | void;
|
|
155
|
+
type SceneDeactivationHandler = () => void;
|
|
144
156
|
type SceneLayoutChild = SceneObject<SceneLayoutChildState | SceneLayoutState>;
|
|
145
157
|
interface SceneLayoutState extends SceneLayoutChildState {
|
|
146
158
|
children: SceneLayoutChild[];
|
|
@@ -192,6 +204,7 @@ interface SceneObjectUrlSyncHandler<TState> {
|
|
|
192
204
|
type SceneObjectUrlValue = string | string[] | undefined | null;
|
|
193
205
|
type SceneObjectUrlValues = Record<string, SceneObjectUrlValue>;
|
|
194
206
|
type CustomTransformOperator = (context: DataTransformContext) => MonoTypeOperatorFunction<DataFrame[]>;
|
|
207
|
+
type SceneStateChangedHandler<TState> = (newState: TState, prevState: TState) => void;
|
|
195
208
|
type DeepPartial<T> = {
|
|
196
209
|
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
197
210
|
};
|
|
@@ -257,9 +270,10 @@ declare const sceneGraph: {
|
|
|
257
270
|
|
|
258
271
|
declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
|
|
259
272
|
private _isActive;
|
|
260
|
-
private _subject;
|
|
261
273
|
private _state;
|
|
262
274
|
private _events;
|
|
275
|
+
private _activationHandlers;
|
|
276
|
+
private _deactivationHandlers;
|
|
263
277
|
protected _parent?: SceneObject;
|
|
264
278
|
protected _subs: Subscription;
|
|
265
279
|
protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
|
|
@@ -288,7 +302,7 @@ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneOb
|
|
|
288
302
|
/**
|
|
289
303
|
* Subscribe to the scene state subject
|
|
290
304
|
**/
|
|
291
|
-
subscribeToState(
|
|
305
|
+
subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;
|
|
292
306
|
/**
|
|
293
307
|
* Subscribe to the scene event
|
|
294
308
|
**/
|
|
@@ -297,11 +311,13 @@ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneOb
|
|
|
297
311
|
publishEvent(event: BusEvent, bubble?: boolean): void;
|
|
298
312
|
getRoot(): SceneObject;
|
|
299
313
|
/**
|
|
300
|
-
* Called by the SceneComponentWrapper when the react component is mounted
|
|
314
|
+
* Called by the SceneComponentWrapper when the react component is mounted.
|
|
315
|
+
* Don't override this, instead use addActivationHandler
|
|
301
316
|
*/
|
|
302
317
|
activate(): void;
|
|
303
318
|
/**
|
|
304
|
-
* Called by the SceneComponentWrapper when the react component is unmounted
|
|
319
|
+
* Called by the SceneComponentWrapper when the react component is unmounted.
|
|
320
|
+
* Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.
|
|
305
321
|
*/
|
|
306
322
|
deactivate(): void;
|
|
307
323
|
/**
|
|
@@ -314,6 +330,11 @@ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneOb
|
|
|
314
330
|
* Will create new SceneObject with shallow-cloned state, but all state items of type SceneObject are deep cloned
|
|
315
331
|
*/
|
|
316
332
|
clone(withState?: Partial<TState>): this;
|
|
333
|
+
/**
|
|
334
|
+
* Allows external code to register code that is executed on activate and deactivate. This allow you
|
|
335
|
+
* to wire up scene objects that need to respond to state changes in other objects from the outside.
|
|
336
|
+
**/
|
|
337
|
+
addActivationHandler(handler: SceneActivationHandler): void;
|
|
317
338
|
}
|
|
318
339
|
|
|
319
340
|
interface SceneDataNodeState extends SceneObjectStatePlain {
|
|
@@ -404,7 +425,8 @@ declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> impleme
|
|
|
404
425
|
private _containerWidth?;
|
|
405
426
|
private _variableValueRecorder;
|
|
406
427
|
protected _variableDependency: VariableDependencyConfig<QueryRunnerState>;
|
|
407
|
-
|
|
428
|
+
constructor(initialState: QueryRunnerState);
|
|
429
|
+
private _onActivate;
|
|
408
430
|
/**
|
|
409
431
|
* Handles some tricky cases where we need to run queries even when they have not changed in case
|
|
410
432
|
* the query execution on activate was stopped due to VariableSet still not having processed all variables.
|
|
@@ -434,9 +456,13 @@ interface SceneDataTransformerState extends SceneDataNodeState {
|
|
|
434
456
|
* transformations that depend on other scene object states.
|
|
435
457
|
*/
|
|
436
458
|
declare class SceneDataTransformer extends SceneObjectBase<SceneDataTransformerState> implements SceneDataProvider {
|
|
437
|
-
protected _variableDependency: VariableDependencyConfig<SceneDataTransformerState>;
|
|
438
459
|
private _transformSub?;
|
|
439
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Scan transformations for variable usage and re-process transforms when a variable values change
|
|
462
|
+
*/
|
|
463
|
+
protected _variableDependency: VariableDependencyConfig<SceneDataTransformerState>;
|
|
464
|
+
constructor(state: SceneDataTransformerState);
|
|
465
|
+
private activationHandler;
|
|
440
466
|
private getSourceData;
|
|
441
467
|
setContainerWidth(width: number): void;
|
|
442
468
|
reprocessTransformations(): void;
|
|
@@ -493,20 +519,20 @@ declare class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> im
|
|
|
493
519
|
private _updating;
|
|
494
520
|
private _variableValueRecorder;
|
|
495
521
|
getByName(name: string): SceneVariable | undefined;
|
|
522
|
+
constructor(state: SceneVariableSetState);
|
|
496
523
|
/**
|
|
497
|
-
* Subscribes to child variable value changes
|
|
498
|
-
* And starts the variable value validation process
|
|
524
|
+
* Subscribes to child variable value changes, and starts the variable value validation process
|
|
499
525
|
*/
|
|
500
|
-
|
|
526
|
+
private _onActivate;
|
|
527
|
+
/**
|
|
528
|
+
* Cancel all currently running updates
|
|
529
|
+
*/
|
|
530
|
+
private _onDeactivate;
|
|
501
531
|
/**
|
|
502
532
|
* If variables changed while in in-active state we don't get any change events, so we need to check for that here.
|
|
503
533
|
*/
|
|
504
534
|
private checkForVariablesThatChangedWhileInactive;
|
|
505
535
|
private variableNeedsUpdate;
|
|
506
|
-
/**
|
|
507
|
-
* Cancel all currently running updates
|
|
508
|
-
*/
|
|
509
|
-
deactivate(): void;
|
|
510
536
|
/**
|
|
511
537
|
* This loops through variablesToUpdate and update all that that can.
|
|
512
538
|
* If one has a dependency that is currently in variablesToUpdate it will be skipped for now.
|
|
@@ -616,7 +642,7 @@ declare class DataSourceVariable extends MultiValueVariable<DataSourceVariableSt
|
|
|
616
642
|
|
|
617
643
|
interface QueryVariableState extends MultiValueVariableState {
|
|
618
644
|
type: 'query';
|
|
619
|
-
datasource: DataSourceRef | null;
|
|
645
|
+
datasource: DataSourceRef$1 | null;
|
|
620
646
|
query: any;
|
|
621
647
|
regex: string;
|
|
622
648
|
refresh: VariableRefresh;
|
|
@@ -626,7 +652,7 @@ declare class QueryVariable extends MultiValueVariable<QueryVariableState> {
|
|
|
626
652
|
private updateSubscription?;
|
|
627
653
|
protected _variableDependency: VariableDependencyConfig<QueryVariableState>;
|
|
628
654
|
constructor(initialState: Partial<QueryVariableState>);
|
|
629
|
-
|
|
655
|
+
private _onActivate;
|
|
630
656
|
deactivate(): void;
|
|
631
657
|
getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]>;
|
|
632
658
|
private getRequest;
|
|
@@ -700,14 +726,13 @@ interface EmbeddedSceneState extends SceneObjectStatePlain {
|
|
|
700
726
|
declare class EmbeddedScene extends SceneObjectBase<EmbeddedSceneState> {
|
|
701
727
|
static Component: typeof EmbeddedSceneRenderer;
|
|
702
728
|
private urlSyncManager?;
|
|
729
|
+
constructor(state: EmbeddedSceneState);
|
|
703
730
|
/**
|
|
704
731
|
* initUrlSync should be called before the scene is rendered to ensure that objects are in sync
|
|
705
732
|
* before they get activated. This saves some unnecessary re-renders and makes sure variables
|
|
706
733
|
* queries are issued as needed.
|
|
707
734
|
*/
|
|
708
735
|
initUrlSync(): void;
|
|
709
|
-
activate(): void;
|
|
710
|
-
deactivate(): void;
|
|
711
736
|
}
|
|
712
737
|
declare function EmbeddedSceneRenderer({ model }: SceneComponentProps<EmbeddedScene>): JSX.Element;
|
|
713
738
|
|
|
@@ -716,6 +741,16 @@ declare namespace VizPanelRenderer {
|
|
|
716
741
|
var displayName: string;
|
|
717
742
|
}
|
|
718
743
|
|
|
744
|
+
interface VizPanelMenuState extends SceneObjectStatePlain {
|
|
745
|
+
items?: PanelMenuItem[];
|
|
746
|
+
}
|
|
747
|
+
declare class VizPanelMenu extends SceneObjectBase<VizPanelMenuState> {
|
|
748
|
+
static Component: typeof VizPanelMenuRenderer;
|
|
749
|
+
addItem(item: PanelMenuItem): void;
|
|
750
|
+
setItems(items: PanelMenuItem[]): void;
|
|
751
|
+
}
|
|
752
|
+
declare function VizPanelMenuRenderer({ model }: SceneComponentProps<VizPanelMenu>): JSX.Element | null;
|
|
753
|
+
|
|
719
754
|
interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneLayoutChildState {
|
|
720
755
|
title: string;
|
|
721
756
|
description?: string;
|
|
@@ -725,6 +760,7 @@ interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneLayoutChi
|
|
|
725
760
|
pluginVersion?: string;
|
|
726
761
|
displayMode?: 'default' | 'transparent';
|
|
727
762
|
hoverHeader?: boolean;
|
|
763
|
+
menu?: VizPanelMenu;
|
|
728
764
|
pluginLoadError?: string;
|
|
729
765
|
}
|
|
730
766
|
declare class VizPanel<TOptions = {}, TFieldConfig = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
|
|
@@ -812,8 +848,6 @@ declare class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState
|
|
|
812
848
|
protected _urlSync: SceneObjectUrlSyncConfig<SceneObjectState>;
|
|
813
849
|
private _intervalTimer;
|
|
814
850
|
constructor(state: Partial<SceneRefreshPickerState>);
|
|
815
|
-
activate(): void;
|
|
816
|
-
deactivate(): void;
|
|
817
851
|
onRefresh: () => void;
|
|
818
852
|
onIntervalChanged: (interval: string) => void;
|
|
819
853
|
getUrlState(): {
|
|
@@ -824,12 +858,12 @@ declare class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState
|
|
|
824
858
|
}
|
|
825
859
|
declare function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneRefreshPicker>): JSX.Element;
|
|
826
860
|
|
|
827
|
-
interface
|
|
861
|
+
interface SceneByFrameRepeaterState extends SceneObjectStatePlain {
|
|
828
862
|
body: SceneObject<SceneLayoutState>;
|
|
829
863
|
getLayoutChild(data: PanelData, frame: DataFrame, frameIndex: number): SceneLayoutChild;
|
|
830
864
|
}
|
|
831
|
-
declare class SceneByFrameRepeater extends SceneObjectBase<
|
|
832
|
-
|
|
865
|
+
declare class SceneByFrameRepeater extends SceneObjectBase<SceneByFrameRepeaterState> {
|
|
866
|
+
constructor(state: SceneByFrameRepeaterState);
|
|
833
867
|
private performRepeat;
|
|
834
868
|
static Component: ({ model, isEditing }: SceneComponentProps<SceneByFrameRepeater>) => JSX.Element;
|
|
835
869
|
}
|
|
@@ -966,4 +1000,25 @@ declare class SceneAppPage extends SceneObjectBase<SceneAppPageState> {
|
|
|
966
1000
|
}
|
|
967
1001
|
declare function SceneAppPageRenderer({ model }: SceneComponentProps<SceneAppPage>): JSX.Element;
|
|
968
1002
|
|
|
969
|
-
|
|
1003
|
+
interface SceneReactObjectState<TProps = {}> extends SceneLayoutChildState {
|
|
1004
|
+
/**
|
|
1005
|
+
* React component to render
|
|
1006
|
+
*/
|
|
1007
|
+
component?: React.ComponentType<TProps>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Props to pass to the component
|
|
1010
|
+
*/
|
|
1011
|
+
props?: TProps;
|
|
1012
|
+
/**
|
|
1013
|
+
* Alternative to component and props is just to pass a React node
|
|
1014
|
+
*/
|
|
1015
|
+
reactNode?: React.ReactNode;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* A utility object that can be used to render any React component or ReactNode
|
|
1019
|
+
*/
|
|
1020
|
+
declare class SceneReactObject extends SceneObjectBase<SceneReactObjectState> {
|
|
1021
|
+
static Component: ({ model }: SceneComponentProps<SceneReactObject>) => {} | null;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
export { ConstantVariable, CustomFormatterFn, CustomTransformOperator, CustomVariable, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, FormatRegistryID, FormatVariable, NestedScene, QueryRunnerState, QueryVariable, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataNode, SceneDataProvider, SceneDataState, SceneDataTransformer, SceneDeactivationHandler, SceneEditor, SceneEditorState, SceneFlexLayout, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChild, SceneLayoutChildOptions, SceneLayoutChildState, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectStatePlain, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRouteMatch, SceneStateChangedHandler, SceneTimePicker, SceneTimeRange, SceneTimeRangeLike, SceneTimeRangeState, SceneToolbarButton, SceneToolbarInput, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, TestVariable, TextBoxVariable, UrlSyncManager, ValidateAndUpdateResult, VariableDependencyConfig, VariableValue, VariableValueCustom, VariableValueOption, VariableValueSelectors, VariableValueSingle, VizPanel, VizPanelMenu, VizPanelState, formatRegistry, isSceneObject, sceneGraph };
|