@grafana/scenes 5.38.0--canary.1030.12908050920.0 → 5.39.0--canary.1030.12911284524.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as _grafana_data from '@grafana/data';
2
- import { BusEventWithPayload, PanelData, BusEvent, BusEventType, BusEventHandler, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, UrlQueryMap, PanelPlugin, EventBus, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, PanelMenuItem, FieldConfigSource, PanelModel, AbsoluteTimeRange, InterpolateFunction, IconName as IconName$1, PageLayoutType, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
2
+ import { BusEventWithPayload, EventBus, BusEvent, BusEventType, BusEventHandler, PanelMenuItem, FieldConfigSource, PanelModel, PanelPlugin, AbsoluteTimeRange, PanelData, InterpolateFunction, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, UrlQueryMap, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, IconName as IconName$1, PageLayoutType, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { CSSProperties, ComponentType } from 'react';
5
5
  import * as rxjs from 'rxjs';
6
- import { Observable, Unsubscribable, MonoTypeOperatorFunction, Subscription, ReplaySubject } from 'rxjs';
6
+ import { Observable, Subscription, Unsubscribable, MonoTypeOperatorFunction, ReplaySubject } from 'rxjs';
7
7
  import * as _grafana_schema from '@grafana/schema';
8
8
  import { VariableType, VariableHide, TimeZone, DataTopic, DataQuery, DataSourceRef, VariableRefresh, LoadingState, DashboardCursorSync, MatcherConfig, TableFieldOptions } from '@grafana/schema';
9
+ import { PanelContext, IconName } from '@grafana/ui';
9
10
  import { LocationService, VariableInterpolation } from '@grafana/runtime';
10
11
  import { Location } from 'history';
11
- import { PanelContext, IconName } from '@grafana/ui';
12
12
  import ReactGridLayout from 'react-grid-layout';
13
13
  import { RouteComponentProps } from 'react-router-dom';
14
14
  import { Options, FieldConfig as FieldConfig$1 } from '@grafana/schema/dist/esm/raw/composable/barchart/panelcfg/x/BarChartPanelCfg_types.gen';
@@ -134,6 +134,277 @@ declare class SceneObjectRef<T> {
134
134
  resolve(): T;
135
135
  }
136
136
 
137
+ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
138
+ private _isActive;
139
+ private _state;
140
+ private _activationHandlers;
141
+ private _deactivationHandlers;
142
+ private _ref?;
143
+ protected _events?: EventBus;
144
+ protected _parent?: SceneObject;
145
+ protected _subs: Subscription;
146
+ protected _refCount: number;
147
+ protected _renderBeforeActivation: boolean;
148
+ protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
149
+ protected _urlSync: SceneObjectUrlSyncHandler | undefined;
150
+ constructor(state: TState);
151
+ /** Current state */
152
+ get state(): TState;
153
+ /** True if currently being active (ie displayed for visual objects) */
154
+ get isActive(): boolean;
155
+ get renderBeforeActivation(): boolean;
156
+ /** Returns the parent, undefined for root object */
157
+ get parent(): SceneObject | undefined;
158
+ /** Returns variable dependency config */
159
+ get variableDependency(): SceneVariableDependencyConfigLike | undefined;
160
+ /** Returns url sync config */
161
+ get urlSync(): SceneObjectUrlSyncHandler | undefined;
162
+ /**
163
+ * Used in render functions when rendering a SceneObject.
164
+ * Wraps the component in an EditWrapper that handles edit mode
165
+ */
166
+ get Component(): SceneComponent<this>;
167
+ private _setParent;
168
+ /**
169
+ * Sometimes you want to move one instance to another parent.
170
+ * This is a way to do that without getting the console warning.
171
+ */
172
+ clearParent(): void;
173
+ /**
174
+ * Subscribe to the scene state subject
175
+ **/
176
+ subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;
177
+ /**
178
+ * Subscribe to the scene event
179
+ **/
180
+ subscribeToEvent<T extends BusEvent>(eventType: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;
181
+ setState(update: Partial<TState>): void;
182
+ /**
183
+ * This handles activation and deactivation of $data, $timeRange and $variables when they change
184
+ * during the active phase of the scene object.
185
+ */
186
+ private _handleActivationOfChangedStateProps;
187
+ private _handleChangedStateActivation;
188
+ private _handleChangedBehaviors;
189
+ publishEvent(event: BusEvent, bubble?: boolean): void;
190
+ getRoot(): SceneObject;
191
+ private _internalActivate;
192
+ private _activateBehavior;
193
+ /**
194
+ * This is primarily called from SceneComponentWrapper when the SceneObject's Component is mounted.
195
+ * But in some scenarios this can also be called directly from another scene object. When called manually from another scene object
196
+ * make sure to call the returned function when the source scene object is deactivated.
197
+ */
198
+ activate(): CancelActivationHandler;
199
+ /**
200
+ * Called by the SceneComponentWrapper when the react component is unmounted.
201
+ * Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.
202
+ */
203
+ private _internalDeactivate;
204
+ /**
205
+ * Utility hook to get and subscribe to state
206
+ */
207
+ useState(): TState;
208
+ /** Force a re-render, should only be needed when variable values change */
209
+ forceRender(): void;
210
+ /**
211
+ * Will create new SceneObject with shallow-cloned state, but all state items of type SceneObject are deep cloned
212
+ */
213
+ clone(withState?: Partial<TState>): this;
214
+ /**
215
+ * Allows external code to register code that is executed on activate and deactivate. This allow you
216
+ * to wire up scene objects that need to respond to state changes in other objects from the outside.
217
+ **/
218
+ addActivationHandler(handler: SceneActivationHandler): void;
219
+ /**
220
+ * Loop through state and call callback for each direct child scene object.
221
+ * Checks 1 level deep properties and arrays. So a scene object hidden in a nested plain object will not be detected.
222
+ */
223
+ forEachChild(callback: (child: SceneObjectBase) => void): void;
224
+ /** Returns a SceneObjectRef that will resolve to this object */
225
+ getRef(): SceneObjectRef<this>;
226
+ }
227
+ /**
228
+ * This hook is always returning model.state instead of a useState that remembers the last state emitted on the subject
229
+ * The reason for this is so that if the model instance change this function will always return the latest state.
230
+ */
231
+ declare function useSceneObjectState<TState extends SceneObjectState>(model: SceneObject<TState>, options?: UseStateHookOptions): TState;
232
+
233
+ declare function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>): React__default.JSX.Element;
234
+
235
+ interface VizPanelMenuState extends SceneObjectState {
236
+ items?: PanelMenuItem[];
237
+ }
238
+ declare class VizPanelMenu extends SceneObjectBase<VizPanelMenuState> {
239
+ static Component: typeof VizPanelMenuRenderer;
240
+ addItem(item: PanelMenuItem): void;
241
+ setItems(items: PanelMenuItem[]): void;
242
+ }
243
+ declare function VizPanelMenuRenderer({ model }: SceneComponentProps<VizPanelMenu>): React__default.JSX.Element;
244
+
245
+ interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
246
+ /**
247
+ * State paths to scan / extract variable dependencies from. Leave empty to scan all paths.
248
+ */
249
+ statePaths?: Array<keyof TState | '*'>;
250
+ /**
251
+ * Explicit list of variable names to depend on. Leave empty to scan state for dependencies.
252
+ */
253
+ variableNames?: string[];
254
+ /**
255
+ * Optional way to customize how to handle when a dependent variable changes
256
+ * If not specified the default behavior is to trigger a re-render
257
+ */
258
+ onReferencedVariableValueChanged?: (variable: SceneVariable) => void;
259
+ /**
260
+ * Two scenarios trigger this callback to be called.
261
+ * 1. When any direct dependency changed value
262
+ * 2. In case hasDependencyInLoadingState was called and returned true we really care about any variable update. So in this scenario this callback is called
263
+ * after any variable update completes. This is to cover scenarios where an object is waiting for indirect dependencies to complete.
264
+ */
265
+ onVariableUpdateCompleted?: () => void;
266
+ /**
267
+ * Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
268
+ */
269
+ onAnyVariableChanged?: (variable: SceneVariable) => void;
270
+ /**
271
+ * Handle time macros.
272
+ */
273
+ handleTimeMacros?: boolean;
274
+ }
275
+ declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
276
+ private _sceneObject;
277
+ private _options;
278
+ private _state;
279
+ private _dependencies;
280
+ private _statePaths?;
281
+ private _isWaitingForVariables;
282
+ scanCount: number;
283
+ constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
284
+ /**
285
+ * Used to check for dependency on a specific variable
286
+ */
287
+ hasDependencyOn(name: string): boolean;
288
+ /**
289
+ * 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.
290
+ */
291
+ variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void;
292
+ hasDependencyInLoadingState(): boolean;
293
+ getNames(): Set<string>;
294
+ /**
295
+ * Update variableNames
296
+ */
297
+ setVariableNames(varNames: string[]): void;
298
+ setPaths(paths: Array<keyof TState | '*'>): void;
299
+ private scanStateForDependencies;
300
+ private extractVariablesFrom;
301
+ private handleTimeMacros;
302
+ }
303
+
304
+ interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectState {
305
+ /**
306
+ * This is usually a plugin id that references a core plugin or an external plugin. But this can also reference a
307
+ * runtime registered PanelPlugin registered via function registerScenePanelPlugin.
308
+ */
309
+ pluginId: string;
310
+ title: string;
311
+ description?: string;
312
+ options: DeepPartial<TOptions>;
313
+ fieldConfig: FieldConfigSource<DeepPartial<TFieldConfig>>;
314
+ pluginVersion?: string;
315
+ displayMode?: 'default' | 'transparent';
316
+ /**
317
+ * Only shows header on hover, absolutly positioned above the panel.
318
+ */
319
+ hoverHeader?: boolean;
320
+ /**
321
+ * Offset hoverHeader position on the y axis
322
+ */
323
+ hoverHeaderOffset?: number;
324
+ /**
325
+ * Only shows vizPanelMenu on hover if false, otherwise the menu is always visible in the header
326
+ */
327
+ showMenuAlways?: boolean;
328
+ /**
329
+ * Defines a menu in the top right of the panel. The menu object is only activated when the dropdown menu itself is shown.
330
+ * So the best way to add dynamic menu actions and links is by adding them in a behavior attached to the menu.
331
+ */
332
+ menu?: VizPanelMenu;
333
+ /**
334
+ * Defines a menu that renders panel link.
335
+ **/
336
+ titleItems?: React.ReactNode | SceneObject | SceneObject[];
337
+ seriesLimit?: number;
338
+ seriesLimitShowAll?: boolean;
339
+ /**
340
+ * Add action to the top right panel header
341
+ */
342
+ headerActions?: React.ReactNode | SceneObject | SceneObject[];
343
+ /**
344
+ * Mainly for advanced use cases that need custom handling of PanelContext callbacks.
345
+ */
346
+ extendPanelContext?: (vizPanel: VizPanel, context: PanelContext) => void;
347
+ /**
348
+ * Sets panel chrome collapsed state
349
+ */
350
+ collapsible?: boolean;
351
+ collapsed?: boolean;
352
+ /**
353
+ * @internal
354
+ * Only for use from core to handle migration from old angular panels
355
+ **/
356
+ _UNSAFE_customMigrationHandler?: (panel: PanelModel, plugin: PanelPlugin) => void;
357
+ /** Internal */
358
+ _pluginLoadError?: string;
359
+ /** Internal */
360
+ _pluginInstanceState?: any;
361
+ _renderCounter?: number;
362
+ }
363
+ declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
364
+ static Component: typeof VizPanelRenderer;
365
+ protected _variableDependency: VariableDependencyConfig<VizPanelState<TOptions, TFieldConfig>>;
366
+ protected _panelContext?: PanelContext;
367
+ private _plugin?;
368
+ private _prevData?;
369
+ private _dataWithFieldConfig?;
370
+ private _structureRev;
371
+ constructor(state: Partial<VizPanelState<TOptions, TFieldConfig>>);
372
+ private _onActivate;
373
+ forceRender(): void;
374
+ private _loadPlugin;
375
+ getLegacyPanelId(): number;
376
+ private _pluginLoaded;
377
+ private _getPluginVersion;
378
+ getPlugin(): PanelPlugin | undefined;
379
+ getPanelContext(): PanelContext;
380
+ onTimeRangeChange: (timeRange: AbsoluteTimeRange) => void;
381
+ getTimeRange: (data?: PanelData) => _grafana_data.TimeRange;
382
+ changePluginType(pluginId: string, newOptions?: DeepPartial<{}>, newFieldConfig?: FieldConfigSource): Promise<void>;
383
+ onTitleChange: (title: string) => void;
384
+ onDescriptionChange: (description: string) => void;
385
+ onDisplayModeChange: (displayMode: 'default' | 'transparent') => void;
386
+ onToggleCollapse: (collapsed: boolean) => void;
387
+ onOptionsChange: (optionsUpdate: DeepPartial<TOptions>, replace?: boolean, isAfterPluginChange?: boolean) => void;
388
+ onFieldConfigChange: (fieldConfigUpdate: FieldConfigSource<DeepPartial<TFieldConfig>>, replace?: boolean) => void;
389
+ interpolate: InterpolateFunction;
390
+ getDescription: () => string;
391
+ clearFieldConfigCache(): void;
392
+ /**
393
+ * Called from the react render path to apply the field config to the data provided by the data provider
394
+ */
395
+ applyFieldConfig(rawData?: PanelData): PanelData;
396
+ onCancelQuery: () => void;
397
+ onStatusMessageClick: () => void;
398
+ /**
399
+ * Panel context functions
400
+ */
401
+ private _onSeriesColorChange;
402
+ private _onSeriesVisibilityChange;
403
+ private _onInstanceStateChange;
404
+ private _onToggleLegendSort;
405
+ private buildPanelContext;
406
+ }
407
+
137
408
  interface SceneObjectState {
138
409
  key?: string;
139
410
  $timeRange?: SceneTimeRangeLike;
@@ -231,6 +502,9 @@ interface SceneLayout<T extends SceneLayoutState = SceneLayoutState> extends Sce
231
502
  isDraggable(): boolean;
232
503
  getDragClass?(): string;
233
504
  getDragClassCancel?(): string;
505
+ getDragHooks?(): {
506
+ onDragStart?: (e: React__default.PointerEvent, panel: VizPanel) => void;
507
+ };
234
508
  }
235
509
  interface SceneTimeRangeState extends SceneObjectState {
236
510
  from: string;
@@ -303,172 +577,76 @@ interface SceneDataProvider<T extends SceneObjectState = SceneDataState> extends
303
577
  setContainerWidth?: (width: number) => void;
304
578
  isDataReadyToDisplay?: () => boolean;
305
579
  cancelQuery?: () => void;
306
- getResultsStream(): Observable<SceneDataProviderResult>;
307
- }
308
- interface SceneDataLayerProviderState extends SceneDataState {
309
- name: string;
310
- description?: string;
311
- isEnabled?: boolean;
312
- isHidden?: boolean;
313
- }
314
- interface SceneDataLayerProvider extends SceneDataProvider<SceneDataLayerProviderState> {
315
- isDataLayer: true;
316
- }
317
- declare function isDataLayer(obj: SceneObject): obj is SceneDataLayerProvider;
318
- interface DataLayerFilter {
319
- panelId: number;
320
- }
321
- interface SceneStatelessBehavior<T extends SceneObject = any> {
322
- (sceneObject: T): CancelActivationHandler | void;
323
- }
324
- type ControlsLayout = 'horizontal' | 'vertical';
325
- interface UseStateHookOptions {
326
- /**
327
- * For some edge cases other scene objects want to subscribe to scene object state for objects
328
- * that are not active, or whose main React Component can be un-mounted. Set this to true
329
- * to keep the scene object active even if the React component is unmounted.
330
- *
331
- * Normally you would not need this but this can be useful in some edge cases.
332
- *
333
- * @experimental
334
- */
335
- shouldActivateOrKeepAlive?: boolean;
336
- }
337
- interface SceneDataQuery extends DataQuery {
338
- [key: string]: any;
339
- timeRangeCompare?: boolean;
340
- }
341
- interface SceneUrlSyncOptions {
342
- /**
343
- * This will update the url to contain all scene url state
344
- * when the scene is initialized. Important for browser history "back" actions.
345
- */
346
- updateUrlOnInit?: boolean;
347
- /**
348
- * This is only supported by some objects if they implement
349
- * shouldCreateHistoryStep where they can control what changes
350
- * url changes should add a new browser history entry.
351
- */
352
- createBrowserHistorySteps?: boolean;
353
- }
354
-
355
- /**
356
- *
357
- * @param path Url to append query params to
358
- * @param searchObject Query params of the URL
359
- * @param preserveParams Query params to preserve
360
- * @returns Url with query params
361
- */
362
- declare function getUrlWithAppState(path: string, searchObject: UrlQueryMap, preserveParams?: string[]): string;
363
-
364
- interface RuntimePanelPluginOptions {
365
- /**
366
- * Please specify a pluginId that is unlikely to collide with other plugins.
367
- */
368
- pluginId: string;
369
- plugin: PanelPlugin;
370
- }
371
- /**
372
- * Provides a way to register runtime panel plugins.
373
- * Please use a pluginId that is unlikely to collide with other plugins.
374
- */
375
- declare function registerRuntimePanelPlugin({ pluginId, plugin }: RuntimePanelPluginOptions): void;
376
-
377
- declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
378
- private _isActive;
379
- private _state;
380
- private _activationHandlers;
381
- private _deactivationHandlers;
382
- private _ref?;
383
- protected _events?: EventBus;
384
- protected _parent?: SceneObject;
385
- protected _subs: Subscription;
386
- protected _refCount: number;
387
- protected _renderBeforeActivation: boolean;
388
- protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
389
- protected _urlSync: SceneObjectUrlSyncHandler | undefined;
390
- constructor(state: TState);
391
- /** Current state */
392
- get state(): TState;
393
- /** True if currently being active (ie displayed for visual objects) */
394
- get isActive(): boolean;
395
- get renderBeforeActivation(): boolean;
396
- /** Returns the parent, undefined for root object */
397
- get parent(): SceneObject | undefined;
398
- /** Returns variable dependency config */
399
- get variableDependency(): SceneVariableDependencyConfigLike | undefined;
400
- /** Returns url sync config */
401
- get urlSync(): SceneObjectUrlSyncHandler | undefined;
402
- /**
403
- * Used in render functions when rendering a SceneObject.
404
- * Wraps the component in an EditWrapper that handles edit mode
405
- */
406
- get Component(): SceneComponent<this>;
407
- private _setParent;
408
- /**
409
- * Sometimes you want to move one instance to another parent.
410
- * This is a way to do that without getting the console warning.
411
- */
412
- clearParent(): void;
413
- /**
414
- * Subscribe to the scene state subject
415
- **/
416
- subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;
417
- /**
418
- * Subscribe to the scene event
419
- **/
420
- subscribeToEvent<T extends BusEvent>(eventType: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;
421
- setState(update: Partial<TState>): void;
422
- /**
423
- * This handles activation and deactivation of $data, $timeRange and $variables when they change
424
- * during the active phase of the scene object.
425
- */
426
- private _handleActivationOfChangedStateProps;
427
- private _handleChangedStateActivation;
428
- private _handleChangedBehaviors;
429
- publishEvent(event: BusEvent, bubble?: boolean): void;
430
- getRoot(): SceneObject;
431
- private _internalActivate;
432
- private _activateBehavior;
433
- /**
434
- * This is primarily called from SceneComponentWrapper when the SceneObject's Component is mounted.
435
- * But in some scenarios this can also be called directly from another scene object. When called manually from another scene object
436
- * make sure to call the returned function when the source scene object is deactivated.
437
- */
438
- activate(): CancelActivationHandler;
580
+ getResultsStream(): Observable<SceneDataProviderResult>;
581
+ }
582
+ interface SceneDataLayerProviderState extends SceneDataState {
583
+ name: string;
584
+ description?: string;
585
+ isEnabled?: boolean;
586
+ isHidden?: boolean;
587
+ }
588
+ interface SceneDataLayerProvider extends SceneDataProvider<SceneDataLayerProviderState> {
589
+ isDataLayer: true;
590
+ }
591
+ declare function isDataLayer(obj: SceneObject): obj is SceneDataLayerProvider;
592
+ interface DataLayerFilter {
593
+ panelId: number;
594
+ }
595
+ interface SceneStatelessBehavior<T extends SceneObject = any> {
596
+ (sceneObject: T): CancelActivationHandler | void;
597
+ }
598
+ type ControlsLayout = 'horizontal' | 'vertical';
599
+ interface UseStateHookOptions {
439
600
  /**
440
- * Called by the SceneComponentWrapper when the react component is unmounted.
441
- * Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.
601
+ * For some edge cases other scene objects want to subscribe to scene object state for objects
602
+ * that are not active, or whose main React Component can be un-mounted. Set this to true
603
+ * to keep the scene object active even if the React component is unmounted.
604
+ *
605
+ * Normally you would not need this but this can be useful in some edge cases.
606
+ *
607
+ * @experimental
442
608
  */
443
- private _internalDeactivate;
609
+ shouldActivateOrKeepAlive?: boolean;
610
+ }
611
+ interface SceneDataQuery extends DataQuery {
612
+ [key: string]: any;
613
+ timeRangeCompare?: boolean;
614
+ }
615
+ interface SceneUrlSyncOptions {
444
616
  /**
445
- * Utility hook to get and subscribe to state
617
+ * This will update the url to contain all scene url state
618
+ * when the scene is initialized. Important for browser history "back" actions.
446
619
  */
447
- useState(): TState;
448
- /** Force a re-render, should only be needed when variable values change */
449
- forceRender(): void;
620
+ updateUrlOnInit?: boolean;
450
621
  /**
451
- * Will create new SceneObject with shallow-cloned state, but all state items of type SceneObject are deep cloned
622
+ * This is only supported by some objects if they implement
623
+ * shouldCreateHistoryStep where they can control what changes
624
+ * url changes should add a new browser history entry.
452
625
  */
453
- clone(withState?: Partial<TState>): this;
454
- /**
455
- * Allows external code to register code that is executed on activate and deactivate. This allow you
456
- * to wire up scene objects that need to respond to state changes in other objects from the outside.
457
- **/
458
- addActivationHandler(handler: SceneActivationHandler): void;
626
+ createBrowserHistorySteps?: boolean;
627
+ }
628
+
629
+ /**
630
+ *
631
+ * @param path Url to append query params to
632
+ * @param searchObject Query params of the URL
633
+ * @param preserveParams Query params to preserve
634
+ * @returns Url with query params
635
+ */
636
+ declare function getUrlWithAppState(path: string, searchObject: UrlQueryMap, preserveParams?: string[]): string;
637
+
638
+ interface RuntimePanelPluginOptions {
459
639
  /**
460
- * Loop through state and call callback for each direct child scene object.
461
- * Checks 1 level deep properties and arrays. So a scene object hidden in a nested plain object will not be detected.
640
+ * Please specify a pluginId that is unlikely to collide with other plugins.
462
641
  */
463
- forEachChild(callback: (child: SceneObjectBase) => void): void;
464
- /** Returns a SceneObjectRef that will resolve to this object */
465
- getRef(): SceneObjectRef<this>;
642
+ pluginId: string;
643
+ plugin: PanelPlugin;
466
644
  }
467
645
  /**
468
- * This hook is always returning model.state instead of a useState that remembers the last state emitted on the subject
469
- * The reason for this is so that if the model instance change this function will always return the latest state.
646
+ * Provides a way to register runtime panel plugins.
647
+ * Please use a pluginId that is unlikely to collide with other plugins.
470
648
  */
471
- declare function useSceneObjectState<TState extends SceneObjectState>(model: SceneObject<TState>, options?: UseStateHookOptions): TState;
649
+ declare function registerRuntimePanelPlugin({ pluginId, plugin }: RuntimePanelPluginOptions): void;
472
650
 
473
651
  declare function cloneSceneObjectState<TState extends SceneObjectState>(sceneState: TState, withState?: Partial<TState>): TState;
474
652
 
@@ -671,65 +849,6 @@ declare class ConstantVariable extends SceneObjectBase<ConstantVariableState> im
671
849
  getValue(): VariableValue;
672
850
  }
673
851
 
674
- interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
675
- /**
676
- * State paths to scan / extract variable dependencies from. Leave empty to scan all paths.
677
- */
678
- statePaths?: Array<keyof TState | '*'>;
679
- /**
680
- * Explicit list of variable names to depend on. Leave empty to scan state for dependencies.
681
- */
682
- variableNames?: string[];
683
- /**
684
- * Optional way to customize how to handle when a dependent variable changes
685
- * If not specified the default behavior is to trigger a re-render
686
- */
687
- onReferencedVariableValueChanged?: (variable: SceneVariable) => void;
688
- /**
689
- * Two scenarios trigger this callback to be called.
690
- * 1. When any direct dependency changed value
691
- * 2. In case hasDependencyInLoadingState was called and returned true we really care about any variable update. So in this scenario this callback is called
692
- * after any variable update completes. This is to cover scenarios where an object is waiting for indirect dependencies to complete.
693
- */
694
- onVariableUpdateCompleted?: () => void;
695
- /**
696
- * Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
697
- */
698
- onAnyVariableChanged?: (variable: SceneVariable) => void;
699
- /**
700
- * Handle time macros.
701
- */
702
- handleTimeMacros?: boolean;
703
- }
704
- declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
705
- private _sceneObject;
706
- private _options;
707
- private _state;
708
- private _dependencies;
709
- private _statePaths?;
710
- private _isWaitingForVariables;
711
- scanCount: number;
712
- constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
713
- /**
714
- * Used to check for dependency on a specific variable
715
- */
716
- hasDependencyOn(name: string): boolean;
717
- /**
718
- * 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.
719
- */
720
- variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void;
721
- hasDependencyInLoadingState(): boolean;
722
- getNames(): Set<string>;
723
- /**
724
- * Update variableNames
725
- */
726
- setVariableNames(varNames: string[]): void;
727
- setPaths(paths: Array<keyof TState | '*'>): void;
728
- private scanStateForDependencies;
729
- private extractVariablesFrom;
730
- private handleTimeMacros;
731
- }
732
-
733
852
  interface MultiValueVariableState extends SceneVariableState {
734
853
  value: VariableValue;
735
854
  text: VariableValue;
@@ -1755,122 +1874,6 @@ declare class EmbeddedScene extends SceneObjectBase<EmbeddedSceneState> {
1755
1874
  }
1756
1875
  declare function EmbeddedSceneRenderer({ model }: SceneComponentProps<EmbeddedScene>): React__default.JSX.Element;
1757
1876
 
1758
- declare function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>): React__default.JSX.Element;
1759
-
1760
- interface VizPanelMenuState extends SceneObjectState {
1761
- items?: PanelMenuItem[];
1762
- }
1763
- declare class VizPanelMenu extends SceneObjectBase<VizPanelMenuState> {
1764
- static Component: typeof VizPanelMenuRenderer;
1765
- addItem(item: PanelMenuItem): void;
1766
- setItems(items: PanelMenuItem[]): void;
1767
- }
1768
- declare function VizPanelMenuRenderer({ model }: SceneComponentProps<VizPanelMenu>): React__default.JSX.Element;
1769
-
1770
- interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectState {
1771
- /**
1772
- * This is usually a plugin id that references a core plugin or an external plugin. But this can also reference a
1773
- * runtime registered PanelPlugin registered via function registerScenePanelPlugin.
1774
- */
1775
- pluginId: string;
1776
- title: string;
1777
- description?: string;
1778
- options: DeepPartial<TOptions>;
1779
- fieldConfig: FieldConfigSource<DeepPartial<TFieldConfig>>;
1780
- pluginVersion?: string;
1781
- displayMode?: 'default' | 'transparent';
1782
- /**
1783
- * Only shows header on hover, absolutly positioned above the panel.
1784
- */
1785
- hoverHeader?: boolean;
1786
- /**
1787
- * Offset hoverHeader position on the y axis
1788
- */
1789
- hoverHeaderOffset?: number;
1790
- /**
1791
- * Only shows vizPanelMenu on hover if false, otherwise the menu is always visible in the header
1792
- */
1793
- showMenuAlways?: boolean;
1794
- /**
1795
- * Defines a menu in the top right of the panel. The menu object is only activated when the dropdown menu itself is shown.
1796
- * So the best way to add dynamic menu actions and links is by adding them in a behavior attached to the menu.
1797
- */
1798
- menu?: VizPanelMenu;
1799
- /**
1800
- * Defines a menu that renders panel link.
1801
- **/
1802
- titleItems?: React.ReactNode | SceneObject | SceneObject[];
1803
- seriesLimit?: number;
1804
- seriesLimitShowAll?: boolean;
1805
- /**
1806
- * Add action to the top right panel header
1807
- */
1808
- headerActions?: React.ReactNode | SceneObject | SceneObject[];
1809
- /**
1810
- * Mainly for advanced use cases that need custom handling of PanelContext callbacks.
1811
- */
1812
- extendPanelContext?: (vizPanel: VizPanel, context: PanelContext) => void;
1813
- /**
1814
- * Sets panel chrome collapsed state
1815
- */
1816
- collapsible?: boolean;
1817
- collapsed?: boolean;
1818
- /**
1819
- * @internal
1820
- * Only for use from core to handle migration from old angular panels
1821
- **/
1822
- _UNSAFE_customMigrationHandler?: (panel: PanelModel, plugin: PanelPlugin) => void;
1823
- /** Internal */
1824
- _pluginLoadError?: string;
1825
- /** Internal */
1826
- _pluginInstanceState?: any;
1827
- _renderCounter?: number;
1828
- }
1829
- declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
1830
- static Component: typeof VizPanelRenderer;
1831
- protected _variableDependency: VariableDependencyConfig<VizPanelState<TOptions, TFieldConfig>>;
1832
- protected _panelContext?: PanelContext;
1833
- private _plugin?;
1834
- private _prevData?;
1835
- private _dataWithFieldConfig?;
1836
- private _structureRev;
1837
- constructor(state: Partial<VizPanelState<TOptions, TFieldConfig>>);
1838
- private _onActivate;
1839
- forceRender(): void;
1840
- private _loadPlugin;
1841
- getLegacyPanelId(): number;
1842
- private _pluginLoaded;
1843
- private _getPluginVersion;
1844
- getPlugin(): PanelPlugin | undefined;
1845
- getPanelContext(): PanelContext;
1846
- onTimeRangeChange: (timeRange: AbsoluteTimeRange) => void;
1847
- getTimeRange: (data?: PanelData) => _grafana_data.TimeRange;
1848
- changePluginType(pluginId: string, newOptions?: DeepPartial<{}>, newFieldConfig?: FieldConfigSource): Promise<void>;
1849
- onTitleChange: (title: string) => void;
1850
- onDescriptionChange: (description: string) => void;
1851
- onDisplayModeChange: (displayMode: 'default' | 'transparent') => void;
1852
- onToggleCollapse: (collapsed: boolean) => void;
1853
- onOptionsChange: (optionsUpdate: DeepPartial<TOptions>, replace?: boolean, isAfterPluginChange?: boolean) => void;
1854
- onFieldConfigChange: (fieldConfigUpdate: FieldConfigSource<DeepPartial<TFieldConfig>>, replace?: boolean) => void;
1855
- interpolate: InterpolateFunction;
1856
- getDescription: () => string;
1857
- clearFieldConfigCache(): void;
1858
- /**
1859
- * Called from the react render path to apply the field config to the data provided by the data provider
1860
- */
1861
- applyFieldConfig(rawData?: PanelData): PanelData;
1862
- onCancelQuery: () => void;
1863
- onStatusMessageClick: () => void;
1864
- /**
1865
- * Panel context functions
1866
- */
1867
- private _onSeriesColorChange;
1868
- private _onSeriesVisibilityChange;
1869
- private _onInstanceStateChange;
1870
- private _onToggleLegendSort;
1871
- private buildPanelContext;
1872
- }
1873
-
1874
1877
  interface ExploreButtonOptions {
1875
1878
  onClick?: () => void;
1876
1879
  transform?: (query: DataQuery) => DataQuery;
@@ -2406,7 +2409,7 @@ interface SceneReactObjectState<TProps = {}> extends SceneObjectState {
2406
2409
  * A utility object that can be used to render any React component or ReactNode
2407
2410
  */
2408
2411
  declare class SceneReactObject<TProps = {}> extends SceneObjectBase<SceneReactObjectState<TProps>> {
2409
- static Component: ({ model }: SceneComponentProps<SceneReactObject>) => string | number | true | Iterable<React__default.ReactNode> | React__default.JSX.Element | null;
2412
+ static Component: ({ model }: SceneComponentProps<SceneReactObject>) => string | number | true | React__default.JSX.Element | Iterable<React__default.ReactNode> | null;
2410
2413
  }
2411
2414
 
2412
2415
  type StandardFieldConfigInterface<T, C, Prefix extends string> = {