@grafana/scenes 6.0.0--canary.979.12746556745.0 → 6.0.0--canary.979.12990094152.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +36 -0
- package/dist/esm/components/SceneApp/SceneAppPage.js +1 -0
- package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +11 -1
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +15 -5
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/utils.js +4 -1
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/index.d.ts +343 -334
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import * as _grafana_data from '@grafana/data';
|
2
|
-
import { BusEventWithPayload,
|
2
|
+
import { BusEventWithPayload, EventBus, BusEvent, BusEventType, BusEventHandler, PanelMenuItem, FieldConfigSource, PanelModel, PanelPlugin, AbsoluteTimeRange, PanelData, InterpolateFunction, TimeRange, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, DataTransformContext, DataFrame, IconName, PageLayoutType, UrlQueryMap, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, SelectableValue, MetricFindValue, GetTagResponse, VariableRefresh as VariableRefresh$1, VariableSort, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
|
3
3
|
import * as React$1 from 'react';
|
4
4
|
import React__default, { ComponentType, CSSProperties } from 'react';
|
5
5
|
import * as rxjs from 'rxjs';
|
6
|
-
import { Observable, Unsubscribable, MonoTypeOperatorFunction,
|
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 as IconName$1 } from '@grafana/ui';
|
9
10
|
import { LocationService, VariableInterpolation } from '@grafana/runtime';
|
10
11
|
import { Location } from 'history';
|
11
|
-
import { PanelContext, IconName as IconName$1 } from '@grafana/ui';
|
12
12
|
import ReactGridLayout from 'react-grid-layout';
|
13
13
|
import { Options, FieldConfig as FieldConfig$1 } from '@grafana/schema/dist/esm/raw/composable/barchart/panelcfg/x/BarChartPanelCfg_types.gen';
|
14
14
|
import { Options as Options$1 } from '@grafana/schema/dist/esm/raw/composable/bargauge/panelcfg/x/BarGaugePanelCfg_types.gen';
|
@@ -133,6 +133,277 @@ declare class SceneObjectRef<T> {
|
|
133
133
|
resolve(): T;
|
134
134
|
}
|
135
135
|
|
136
|
+
declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
|
137
|
+
private _isActive;
|
138
|
+
private _state;
|
139
|
+
private _activationHandlers;
|
140
|
+
private _deactivationHandlers;
|
141
|
+
private _ref?;
|
142
|
+
protected _events?: EventBus;
|
143
|
+
protected _parent?: SceneObject;
|
144
|
+
protected _subs: Subscription;
|
145
|
+
protected _refCount: number;
|
146
|
+
protected _renderBeforeActivation: boolean;
|
147
|
+
protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
|
148
|
+
protected _urlSync: SceneObjectUrlSyncHandler | undefined;
|
149
|
+
constructor(state: TState);
|
150
|
+
/** Current state */
|
151
|
+
get state(): TState;
|
152
|
+
/** True if currently being active (ie displayed for visual objects) */
|
153
|
+
get isActive(): boolean;
|
154
|
+
get renderBeforeActivation(): boolean;
|
155
|
+
/** Returns the parent, undefined for root object */
|
156
|
+
get parent(): SceneObject | undefined;
|
157
|
+
/** Returns variable dependency config */
|
158
|
+
get variableDependency(): SceneVariableDependencyConfigLike | undefined;
|
159
|
+
/** Returns url sync config */
|
160
|
+
get urlSync(): SceneObjectUrlSyncHandler | undefined;
|
161
|
+
/**
|
162
|
+
* Used in render functions when rendering a SceneObject.
|
163
|
+
* Wraps the component in an EditWrapper that handles edit mode
|
164
|
+
*/
|
165
|
+
get Component(): SceneComponent<this>;
|
166
|
+
private _setParent;
|
167
|
+
/**
|
168
|
+
* Sometimes you want to move one instance to another parent.
|
169
|
+
* This is a way to do that without getting the console warning.
|
170
|
+
*/
|
171
|
+
clearParent(): void;
|
172
|
+
/**
|
173
|
+
* Subscribe to the scene state subject
|
174
|
+
**/
|
175
|
+
subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;
|
176
|
+
/**
|
177
|
+
* Subscribe to the scene event
|
178
|
+
**/
|
179
|
+
subscribeToEvent<T extends BusEvent>(eventType: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;
|
180
|
+
setState(update: Partial<TState>): void;
|
181
|
+
/**
|
182
|
+
* This handles activation and deactivation of $data, $timeRange and $variables when they change
|
183
|
+
* during the active phase of the scene object.
|
184
|
+
*/
|
185
|
+
private _handleActivationOfChangedStateProps;
|
186
|
+
private _handleChangedStateActivation;
|
187
|
+
private _handleChangedBehaviors;
|
188
|
+
publishEvent(event: BusEvent, bubble?: boolean): void;
|
189
|
+
getRoot(): SceneObject;
|
190
|
+
private _internalActivate;
|
191
|
+
private _activateBehavior;
|
192
|
+
/**
|
193
|
+
* This is primarily called from SceneComponentWrapper when the SceneObject's Component is mounted.
|
194
|
+
* But in some scenarios this can also be called directly from another scene object. When called manually from another scene object
|
195
|
+
* make sure to call the returned function when the source scene object is deactivated.
|
196
|
+
*/
|
197
|
+
activate(): CancelActivationHandler;
|
198
|
+
/**
|
199
|
+
* Called by the SceneComponentWrapper when the react component is unmounted.
|
200
|
+
* Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.
|
201
|
+
*/
|
202
|
+
private _internalDeactivate;
|
203
|
+
/**
|
204
|
+
* Utility hook to get and subscribe to state
|
205
|
+
*/
|
206
|
+
useState(): TState;
|
207
|
+
/** Force a re-render, should only be needed when variable values change */
|
208
|
+
forceRender(): void;
|
209
|
+
/**
|
210
|
+
* Will create new SceneObject with shallow-cloned state, but all state items of type SceneObject are deep cloned
|
211
|
+
*/
|
212
|
+
clone(withState?: Partial<TState>): this;
|
213
|
+
/**
|
214
|
+
* Allows external code to register code that is executed on activate and deactivate. This allow you
|
215
|
+
* to wire up scene objects that need to respond to state changes in other objects from the outside.
|
216
|
+
**/
|
217
|
+
addActivationHandler(handler: SceneActivationHandler): void;
|
218
|
+
/**
|
219
|
+
* Loop through state and call callback for each direct child scene object.
|
220
|
+
* Checks 1 level deep properties and arrays. So a scene object hidden in a nested plain object will not be detected.
|
221
|
+
*/
|
222
|
+
forEachChild(callback: (child: SceneObjectBase) => void): void;
|
223
|
+
/** Returns a SceneObjectRef that will resolve to this object */
|
224
|
+
getRef(): SceneObjectRef<this>;
|
225
|
+
}
|
226
|
+
/**
|
227
|
+
* This hook is always returning model.state instead of a useState that remembers the last state emitted on the subject
|
228
|
+
* The reason for this is so that if the model instance change this function will always return the latest state.
|
229
|
+
*/
|
230
|
+
declare function useSceneObjectState<TState extends SceneObjectState>(model: SceneObject<TState>, options?: UseStateHookOptions): TState;
|
231
|
+
|
232
|
+
declare function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>): React__default.JSX.Element;
|
233
|
+
|
234
|
+
interface VizPanelMenuState extends SceneObjectState {
|
235
|
+
items?: PanelMenuItem[];
|
236
|
+
}
|
237
|
+
declare class VizPanelMenu extends SceneObjectBase<VizPanelMenuState> {
|
238
|
+
static Component: typeof VizPanelMenuRenderer;
|
239
|
+
addItem(item: PanelMenuItem): void;
|
240
|
+
setItems(items: PanelMenuItem[]): void;
|
241
|
+
}
|
242
|
+
declare function VizPanelMenuRenderer({ model }: SceneComponentProps<VizPanelMenu>): React__default.JSX.Element;
|
243
|
+
|
244
|
+
interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
|
245
|
+
/**
|
246
|
+
* State paths to scan / extract variable dependencies from. Leave empty to scan all paths.
|
247
|
+
*/
|
248
|
+
statePaths?: Array<keyof TState | '*'>;
|
249
|
+
/**
|
250
|
+
* Explicit list of variable names to depend on. Leave empty to scan state for dependencies.
|
251
|
+
*/
|
252
|
+
variableNames?: string[];
|
253
|
+
/**
|
254
|
+
* Optional way to customize how to handle when a dependent variable changes
|
255
|
+
* If not specified the default behavior is to trigger a re-render
|
256
|
+
*/
|
257
|
+
onReferencedVariableValueChanged?: (variable: SceneVariable) => void;
|
258
|
+
/**
|
259
|
+
* Two scenarios trigger this callback to be called.
|
260
|
+
* 1. When any direct dependency changed value
|
261
|
+
* 2. In case hasDependencyInLoadingState was called and returned true we really care about any variable update. So in this scenario this callback is called
|
262
|
+
* after any variable update completes. This is to cover scenarios where an object is waiting for indirect dependencies to complete.
|
263
|
+
*/
|
264
|
+
onVariableUpdateCompleted?: () => void;
|
265
|
+
/**
|
266
|
+
* Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
|
267
|
+
*/
|
268
|
+
onAnyVariableChanged?: (variable: SceneVariable) => void;
|
269
|
+
/**
|
270
|
+
* Handle time macros.
|
271
|
+
*/
|
272
|
+
handleTimeMacros?: boolean;
|
273
|
+
}
|
274
|
+
declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
|
275
|
+
private _sceneObject;
|
276
|
+
private _options;
|
277
|
+
private _state;
|
278
|
+
private _dependencies;
|
279
|
+
private _statePaths?;
|
280
|
+
private _isWaitingForVariables;
|
281
|
+
scanCount: number;
|
282
|
+
constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
|
283
|
+
/**
|
284
|
+
* Used to check for dependency on a specific variable
|
285
|
+
*/
|
286
|
+
hasDependencyOn(name: string): boolean;
|
287
|
+
/**
|
288
|
+
* 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.
|
289
|
+
*/
|
290
|
+
variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void;
|
291
|
+
hasDependencyInLoadingState(): boolean;
|
292
|
+
getNames(): Set<string>;
|
293
|
+
/**
|
294
|
+
* Update variableNames
|
295
|
+
*/
|
296
|
+
setVariableNames(varNames: string[]): void;
|
297
|
+
setPaths(paths: Array<keyof TState | '*'>): void;
|
298
|
+
private scanStateForDependencies;
|
299
|
+
private extractVariablesFrom;
|
300
|
+
private handleTimeMacros;
|
301
|
+
}
|
302
|
+
|
303
|
+
interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectState {
|
304
|
+
/**
|
305
|
+
* This is usually a plugin id that references a core plugin or an external plugin. But this can also reference a
|
306
|
+
* runtime registered PanelPlugin registered via function registerScenePanelPlugin.
|
307
|
+
*/
|
308
|
+
pluginId: string;
|
309
|
+
title: string;
|
310
|
+
description?: string;
|
311
|
+
options: DeepPartial<TOptions>;
|
312
|
+
fieldConfig: FieldConfigSource<DeepPartial<TFieldConfig>>;
|
313
|
+
pluginVersion?: string;
|
314
|
+
displayMode?: 'default' | 'transparent';
|
315
|
+
/**
|
316
|
+
* Only shows header on hover, absolutly positioned above the panel.
|
317
|
+
*/
|
318
|
+
hoverHeader?: boolean;
|
319
|
+
/**
|
320
|
+
* Offset hoverHeader position on the y axis
|
321
|
+
*/
|
322
|
+
hoverHeaderOffset?: number;
|
323
|
+
/**
|
324
|
+
* Only shows vizPanelMenu on hover if false, otherwise the menu is always visible in the header
|
325
|
+
*/
|
326
|
+
showMenuAlways?: boolean;
|
327
|
+
/**
|
328
|
+
* Defines a menu in the top right of the panel. The menu object is only activated when the dropdown menu itself is shown.
|
329
|
+
* So the best way to add dynamic menu actions and links is by adding them in a behavior attached to the menu.
|
330
|
+
*/
|
331
|
+
menu?: VizPanelMenu;
|
332
|
+
/**
|
333
|
+
* Defines a menu that renders panel link.
|
334
|
+
**/
|
335
|
+
titleItems?: React.ReactNode | SceneObject | SceneObject[];
|
336
|
+
seriesLimit?: number;
|
337
|
+
seriesLimitShowAll?: boolean;
|
338
|
+
/**
|
339
|
+
* Add action to the top right panel header
|
340
|
+
*/
|
341
|
+
headerActions?: React.ReactNode | SceneObject | SceneObject[];
|
342
|
+
/**
|
343
|
+
* Mainly for advanced use cases that need custom handling of PanelContext callbacks.
|
344
|
+
*/
|
345
|
+
extendPanelContext?: (vizPanel: VizPanel, context: PanelContext) => void;
|
346
|
+
/**
|
347
|
+
* Sets panel chrome collapsed state
|
348
|
+
*/
|
349
|
+
collapsible?: boolean;
|
350
|
+
collapsed?: boolean;
|
351
|
+
/**
|
352
|
+
* @internal
|
353
|
+
* Only for use from core to handle migration from old angular panels
|
354
|
+
**/
|
355
|
+
_UNSAFE_customMigrationHandler?: (panel: PanelModel, plugin: PanelPlugin) => void;
|
356
|
+
/** Internal */
|
357
|
+
_pluginLoadError?: string;
|
358
|
+
/** Internal */
|
359
|
+
_pluginInstanceState?: any;
|
360
|
+
_renderCounter?: number;
|
361
|
+
}
|
362
|
+
declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
|
363
|
+
static Component: typeof VizPanelRenderer;
|
364
|
+
protected _variableDependency: VariableDependencyConfig<VizPanelState<TOptions, TFieldConfig>>;
|
365
|
+
protected _panelContext?: PanelContext;
|
366
|
+
private _plugin?;
|
367
|
+
private _prevData?;
|
368
|
+
private _dataWithFieldConfig?;
|
369
|
+
private _structureRev;
|
370
|
+
constructor(state: Partial<VizPanelState<TOptions, TFieldConfig>>);
|
371
|
+
private _onActivate;
|
372
|
+
forceRender(): void;
|
373
|
+
private _loadPlugin;
|
374
|
+
getLegacyPanelId(): number;
|
375
|
+
private _pluginLoaded;
|
376
|
+
private _getPluginVersion;
|
377
|
+
getPlugin(): PanelPlugin | undefined;
|
378
|
+
getPanelContext(): PanelContext;
|
379
|
+
onTimeRangeChange: (timeRange: AbsoluteTimeRange) => void;
|
380
|
+
getTimeRange: (data?: PanelData) => _grafana_data.TimeRange;
|
381
|
+
changePluginType(pluginId: string, newOptions?: DeepPartial<{}>, newFieldConfig?: FieldConfigSource): Promise<void>;
|
382
|
+
onTitleChange: (title: string) => void;
|
383
|
+
onDescriptionChange: (description: string) => void;
|
384
|
+
onDisplayModeChange: (displayMode: 'default' | 'transparent') => void;
|
385
|
+
onToggleCollapse: (collapsed: boolean) => void;
|
386
|
+
onOptionsChange: (optionsUpdate: DeepPartial<TOptions>, replace?: boolean, isAfterPluginChange?: boolean) => void;
|
387
|
+
onFieldConfigChange: (fieldConfigUpdate: FieldConfigSource<DeepPartial<TFieldConfig>>, replace?: boolean) => void;
|
388
|
+
interpolate: InterpolateFunction;
|
389
|
+
getDescription: () => string;
|
390
|
+
clearFieldConfigCache(): void;
|
391
|
+
/**
|
392
|
+
* Called from the react render path to apply the field config to the data provided by the data provider
|
393
|
+
*/
|
394
|
+
applyFieldConfig(rawData?: PanelData): PanelData;
|
395
|
+
onCancelQuery: () => void;
|
396
|
+
onStatusMessageClick: () => void;
|
397
|
+
/**
|
398
|
+
* Panel context functions
|
399
|
+
*/
|
400
|
+
private _onSeriesColorChange;
|
401
|
+
private _onSeriesVisibilityChange;
|
402
|
+
private _onInstanceStateChange;
|
403
|
+
private _onToggleLegendSort;
|
404
|
+
private buildPanelContext;
|
405
|
+
}
|
406
|
+
|
136
407
|
interface SceneObjectState {
|
137
408
|
key?: string;
|
138
409
|
$timeRange?: SceneTimeRangeLike;
|
@@ -230,6 +501,9 @@ interface SceneLayout<T extends SceneLayoutState = SceneLayoutState> extends Sce
|
|
230
501
|
isDraggable(): boolean;
|
231
502
|
getDragClass?(): string;
|
232
503
|
getDragClassCancel?(): string;
|
504
|
+
getDragHooks?(): {
|
505
|
+
onDragStart?: (e: React__default.PointerEvent, panel: VizPanel) => void;
|
506
|
+
};
|
233
507
|
}
|
234
508
|
interface SceneTimeRangeState extends SceneObjectState {
|
235
509
|
from: string;
|
@@ -284,168 +558,72 @@ interface FiltersRequestEnricher {
|
|
284
558
|
declare function isDataRequestEnricher(obj: any): obj is DataRequestEnricher;
|
285
559
|
declare function isFiltersRequestEnricher(obj: any): obj is FiltersRequestEnricher;
|
286
560
|
type SceneObjectUrlValue = string | string[] | undefined | null;
|
287
|
-
type SceneObjectUrlValues = Record<string, SceneObjectUrlValue>;
|
288
|
-
type CustomTransformOperator = (context: DataTransformContext) => MonoTypeOperatorFunction<DataFrame[]>;
|
289
|
-
type CustomTransformerDefinition = {
|
290
|
-
operator: CustomTransformOperator;
|
291
|
-
topic: DataTopic;
|
292
|
-
} | CustomTransformOperator;
|
293
|
-
type SceneStateChangedHandler<TState> = (newState: TState, prevState: TState) => void;
|
294
|
-
type DeepPartial<T> = {
|
295
|
-
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
296
|
-
};
|
297
|
-
interface SceneDataProviderResult {
|
298
|
-
data: PanelData;
|
299
|
-
origin: SceneDataProvider;
|
300
|
-
}
|
301
|
-
interface SceneDataProvider<T extends SceneObjectState = SceneDataState> extends SceneObject<T> {
|
302
|
-
setContainerWidth?: (width: number) => void;
|
303
|
-
isDataReadyToDisplay?: () => boolean;
|
304
|
-
cancelQuery?: () => void;
|
305
|
-
getResultsStream(): Observable<SceneDataProviderResult>;
|
306
|
-
}
|
307
|
-
interface SceneDataLayerProviderState extends SceneDataState {
|
308
|
-
name: string;
|
309
|
-
description?: string;
|
310
|
-
isEnabled?: boolean;
|
311
|
-
isHidden?: boolean;
|
312
|
-
}
|
313
|
-
interface SceneDataLayerProvider extends SceneDataProvider<SceneDataLayerProviderState> {
|
314
|
-
isDataLayer: true;
|
315
|
-
}
|
316
|
-
declare function isDataLayer(obj: SceneObject): obj is SceneDataLayerProvider;
|
317
|
-
interface DataLayerFilter {
|
318
|
-
panelId: number;
|
319
|
-
}
|
320
|
-
interface SceneStatelessBehavior<T extends SceneObject = any> {
|
321
|
-
(sceneObject: T): CancelActivationHandler | void;
|
322
|
-
}
|
323
|
-
type ControlsLayout = 'horizontal' | 'vertical';
|
324
|
-
interface UseStateHookOptions {
|
325
|
-
/**
|
326
|
-
* For some edge cases other scene objects want to subscribe to scene object state for objects
|
327
|
-
* that are not active, or whose main React Component can be un-mounted. Set this to true
|
328
|
-
* to keep the scene object active even if the React component is unmounted.
|
329
|
-
*
|
330
|
-
* Normally you would not need this but this can be useful in some edge cases.
|
331
|
-
*
|
332
|
-
* @experimental
|
333
|
-
*/
|
334
|
-
shouldActivateOrKeepAlive?: boolean;
|
335
|
-
}
|
336
|
-
interface SceneDataQuery extends DataQuery {
|
337
|
-
[key: string]: any;
|
338
|
-
timeRangeCompare?: boolean;
|
339
|
-
}
|
340
|
-
interface SceneUrlSyncOptions {
|
341
|
-
/**
|
342
|
-
* This will update the url to contain all scene url state
|
343
|
-
* when the scene is initialized. Important for browser history "back" actions.
|
344
|
-
*/
|
345
|
-
updateUrlOnInit?: boolean;
|
346
|
-
/**
|
347
|
-
* This is only supported by some objects if they implement
|
348
|
-
* shouldCreateHistoryStep where they can control what changes
|
349
|
-
* url changes should add a new browser history entry.
|
350
|
-
*/
|
351
|
-
createBrowserHistorySteps?: boolean;
|
352
|
-
}
|
353
|
-
|
354
|
-
declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState> implements SceneObject<TState> {
|
355
|
-
private _isActive;
|
356
|
-
private _state;
|
357
|
-
private _activationHandlers;
|
358
|
-
private _deactivationHandlers;
|
359
|
-
private _ref?;
|
360
|
-
protected _events?: EventBus;
|
361
|
-
protected _parent?: SceneObject;
|
362
|
-
protected _subs: Subscription;
|
363
|
-
protected _refCount: number;
|
364
|
-
protected _renderBeforeActivation: boolean;
|
365
|
-
protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
|
366
|
-
protected _urlSync: SceneObjectUrlSyncHandler | undefined;
|
367
|
-
constructor(state: TState);
|
368
|
-
/** Current state */
|
369
|
-
get state(): TState;
|
370
|
-
/** True if currently being active (ie displayed for visual objects) */
|
371
|
-
get isActive(): boolean;
|
372
|
-
get renderBeforeActivation(): boolean;
|
373
|
-
/** Returns the parent, undefined for root object */
|
374
|
-
get parent(): SceneObject | undefined;
|
375
|
-
/** Returns variable dependency config */
|
376
|
-
get variableDependency(): SceneVariableDependencyConfigLike | undefined;
|
377
|
-
/** Returns url sync config */
|
378
|
-
get urlSync(): SceneObjectUrlSyncHandler | undefined;
|
379
|
-
/**
|
380
|
-
* Used in render functions when rendering a SceneObject.
|
381
|
-
* Wraps the component in an EditWrapper that handles edit mode
|
382
|
-
*/
|
383
|
-
get Component(): SceneComponent<this>;
|
384
|
-
private _setParent;
|
385
|
-
/**
|
386
|
-
* Sometimes you want to move one instance to another parent.
|
387
|
-
* This is a way to do that without getting the console warning.
|
388
|
-
*/
|
389
|
-
clearParent(): void;
|
390
|
-
/**
|
391
|
-
* Subscribe to the scene state subject
|
392
|
-
**/
|
393
|
-
subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable;
|
394
|
-
/**
|
395
|
-
* Subscribe to the scene event
|
396
|
-
**/
|
397
|
-
subscribeToEvent<T extends BusEvent>(eventType: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable;
|
398
|
-
setState(update: Partial<TState>): void;
|
399
|
-
/**
|
400
|
-
* This handles activation and deactivation of $data, $timeRange and $variables when they change
|
401
|
-
* during the active phase of the scene object.
|
402
|
-
*/
|
403
|
-
private _handleActivationOfChangedStateProps;
|
404
|
-
private _handleChangedStateActivation;
|
405
|
-
private _handleChangedBehaviors;
|
406
|
-
publishEvent(event: BusEvent, bubble?: boolean): void;
|
407
|
-
getRoot(): SceneObject;
|
408
|
-
private _internalActivate;
|
409
|
-
private _activateBehavior;
|
410
|
-
/**
|
411
|
-
* This is primarily called from SceneComponentWrapper when the SceneObject's Component is mounted.
|
412
|
-
* But in some scenarios this can also be called directly from another scene object. When called manually from another scene object
|
413
|
-
* make sure to call the returned function when the source scene object is deactivated.
|
414
|
-
*/
|
415
|
-
activate(): CancelActivationHandler;
|
416
|
-
/**
|
417
|
-
* Called by the SceneComponentWrapper when the react component is unmounted.
|
418
|
-
* Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.
|
419
|
-
*/
|
420
|
-
private _internalDeactivate;
|
561
|
+
type SceneObjectUrlValues = Record<string, SceneObjectUrlValue>;
|
562
|
+
type CustomTransformOperator = (context: DataTransformContext) => MonoTypeOperatorFunction<DataFrame[]>;
|
563
|
+
type CustomTransformerDefinition = {
|
564
|
+
operator: CustomTransformOperator;
|
565
|
+
topic: DataTopic;
|
566
|
+
} | CustomTransformOperator;
|
567
|
+
type SceneStateChangedHandler<TState> = (newState: TState, prevState: TState) => void;
|
568
|
+
type DeepPartial<T> = {
|
569
|
+
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
570
|
+
};
|
571
|
+
interface SceneDataProviderResult {
|
572
|
+
data: PanelData;
|
573
|
+
origin: SceneDataProvider;
|
574
|
+
}
|
575
|
+
interface SceneDataProvider<T extends SceneObjectState = SceneDataState> extends SceneObject<T> {
|
576
|
+
setContainerWidth?: (width: number) => void;
|
577
|
+
isDataReadyToDisplay?: () => boolean;
|
578
|
+
cancelQuery?: () => void;
|
579
|
+
getResultsStream(): Observable<SceneDataProviderResult>;
|
580
|
+
}
|
581
|
+
interface SceneDataLayerProviderState extends SceneDataState {
|
582
|
+
name: string;
|
583
|
+
description?: string;
|
584
|
+
isEnabled?: boolean;
|
585
|
+
isHidden?: boolean;
|
586
|
+
}
|
587
|
+
interface SceneDataLayerProvider extends SceneDataProvider<SceneDataLayerProviderState> {
|
588
|
+
isDataLayer: true;
|
589
|
+
}
|
590
|
+
declare function isDataLayer(obj: SceneObject): obj is SceneDataLayerProvider;
|
591
|
+
interface DataLayerFilter {
|
592
|
+
panelId: number;
|
593
|
+
}
|
594
|
+
interface SceneStatelessBehavior<T extends SceneObject = any> {
|
595
|
+
(sceneObject: T): CancelActivationHandler | void;
|
596
|
+
}
|
597
|
+
type ControlsLayout = 'horizontal' | 'vertical';
|
598
|
+
interface UseStateHookOptions {
|
421
599
|
/**
|
422
|
-
*
|
600
|
+
* For some edge cases other scene objects want to subscribe to scene object state for objects
|
601
|
+
* that are not active, or whose main React Component can be un-mounted. Set this to true
|
602
|
+
* to keep the scene object active even if the React component is unmounted.
|
603
|
+
*
|
604
|
+
* Normally you would not need this but this can be useful in some edge cases.
|
605
|
+
*
|
606
|
+
* @experimental
|
423
607
|
*/
|
424
|
-
|
425
|
-
|
426
|
-
|
608
|
+
shouldActivateOrKeepAlive?: boolean;
|
609
|
+
}
|
610
|
+
interface SceneDataQuery extends DataQuery {
|
611
|
+
[key: string]: any;
|
612
|
+
timeRangeCompare?: boolean;
|
613
|
+
}
|
614
|
+
interface SceneUrlSyncOptions {
|
427
615
|
/**
|
428
|
-
*
|
616
|
+
* This will update the url to contain all scene url state
|
617
|
+
* when the scene is initialized. Important for browser history "back" actions.
|
429
618
|
*/
|
430
|
-
|
431
|
-
/**
|
432
|
-
* Allows external code to register code that is executed on activate and deactivate. This allow you
|
433
|
-
* to wire up scene objects that need to respond to state changes in other objects from the outside.
|
434
|
-
**/
|
435
|
-
addActivationHandler(handler: SceneActivationHandler): void;
|
619
|
+
updateUrlOnInit?: boolean;
|
436
620
|
/**
|
437
|
-
*
|
438
|
-
*
|
621
|
+
* This is only supported by some objects if they implement
|
622
|
+
* shouldCreateHistoryStep where they can control what changes
|
623
|
+
* url changes should add a new browser history entry.
|
439
624
|
*/
|
440
|
-
|
441
|
-
/** Returns a SceneObjectRef that will resolve to this object */
|
442
|
-
getRef(): SceneObjectRef<this>;
|
625
|
+
createBrowserHistorySteps?: boolean;
|
443
626
|
}
|
444
|
-
/**
|
445
|
-
* This hook is always returning model.state instead of a useState that remembers the last state emitted on the subject
|
446
|
-
* The reason for this is so that if the model instance change this function will always return the latest state.
|
447
|
-
*/
|
448
|
-
declare function useSceneObjectState<TState extends SceneObjectState>(model: SceneObject<TState>, options?: UseStateHookOptions): TState;
|
449
627
|
|
450
628
|
interface EmbeddedSceneState extends SceneObjectState {
|
451
629
|
/**
|
@@ -504,7 +682,7 @@ interface SceneAppPageState extends SceneObjectState {
|
|
504
682
|
className?: string;
|
505
683
|
}>;
|
506
684
|
url: string;
|
507
|
-
routePath
|
685
|
+
routePath: string;
|
508
686
|
/** Array of scene object to be rendered at the top right of the page, inline with the page title */
|
509
687
|
controls?: SceneObject[];
|
510
688
|
hideFromBreadcrumbs?: boolean;
|
@@ -624,6 +802,9 @@ interface MacroVariableConstructor {
|
|
624
802
|
declare function registerVariableMacro(name: string, macro: MacroVariableConstructor): () => void;
|
625
803
|
|
626
804
|
declare function renderPrometheusLabelFilters(filters: AdHocVariableFilter[]): string;
|
805
|
+
declare function escapeLabelValueInExactSelector(labelValue: string): string;
|
806
|
+
declare function escapeLabelValueInRegexSelector(labelValue: string): string;
|
807
|
+
declare function escapeURLDelimiters(value: string | undefined): string;
|
627
808
|
|
628
809
|
declare class AdHocFiltersVariableUrlSyncHandler implements SceneObjectUrlSyncHandler {
|
629
810
|
private _variable;
|
@@ -763,65 +944,6 @@ declare class ConstantVariable extends SceneObjectBase<ConstantVariableState> im
|
|
763
944
|
getValue(): VariableValue;
|
764
945
|
}
|
765
946
|
|
766
|
-
interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
|
767
|
-
/**
|
768
|
-
* State paths to scan / extract variable dependencies from. Leave empty to scan all paths.
|
769
|
-
*/
|
770
|
-
statePaths?: Array<keyof TState | '*'>;
|
771
|
-
/**
|
772
|
-
* Explicit list of variable names to depend on. Leave empty to scan state for dependencies.
|
773
|
-
*/
|
774
|
-
variableNames?: string[];
|
775
|
-
/**
|
776
|
-
* Optional way to customize how to handle when a dependent variable changes
|
777
|
-
* If not specified the default behavior is to trigger a re-render
|
778
|
-
*/
|
779
|
-
onReferencedVariableValueChanged?: (variable: SceneVariable) => void;
|
780
|
-
/**
|
781
|
-
* Two scenarios trigger this callback to be called.
|
782
|
-
* 1. When any direct dependency changed value
|
783
|
-
* 2. In case hasDependencyInLoadingState was called and returned true we really care about any variable update. So in this scenario this callback is called
|
784
|
-
* after any variable update completes. This is to cover scenarios where an object is waiting for indirect dependencies to complete.
|
785
|
-
*/
|
786
|
-
onVariableUpdateCompleted?: () => void;
|
787
|
-
/**
|
788
|
-
* Optional way to subscribe to all variable value changes, even to variables that are not dependencies.
|
789
|
-
*/
|
790
|
-
onAnyVariableChanged?: (variable: SceneVariable) => void;
|
791
|
-
/**
|
792
|
-
* Handle time macros.
|
793
|
-
*/
|
794
|
-
handleTimeMacros?: boolean;
|
795
|
-
}
|
796
|
-
declare class VariableDependencyConfig<TState extends SceneObjectState> implements SceneVariableDependencyConfigLike {
|
797
|
-
private _sceneObject;
|
798
|
-
private _options;
|
799
|
-
private _state;
|
800
|
-
private _dependencies;
|
801
|
-
private _statePaths?;
|
802
|
-
private _isWaitingForVariables;
|
803
|
-
scanCount: number;
|
804
|
-
constructor(_sceneObject: SceneObject<TState>, _options: VariableDependencyConfigOptions<TState>);
|
805
|
-
/**
|
806
|
-
* Used to check for dependency on a specific variable
|
807
|
-
*/
|
808
|
-
hasDependencyOn(name: string): boolean;
|
809
|
-
/**
|
810
|
-
* 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.
|
811
|
-
*/
|
812
|
-
variableUpdateCompleted(variable: SceneVariable, hasChanged: boolean): void;
|
813
|
-
hasDependencyInLoadingState(): boolean;
|
814
|
-
getNames(): Set<string>;
|
815
|
-
/**
|
816
|
-
* Update variableNames
|
817
|
-
*/
|
818
|
-
setVariableNames(varNames: string[]): void;
|
819
|
-
setPaths(paths: Array<keyof TState | '*'>): void;
|
820
|
-
private scanStateForDependencies;
|
821
|
-
private extractVariablesFrom;
|
822
|
-
private handleTimeMacros;
|
823
|
-
}
|
824
|
-
|
825
947
|
interface MultiValueVariableState extends SceneVariableState {
|
826
948
|
value: VariableValue;
|
827
949
|
text: VariableValue;
|
@@ -1827,122 +1949,6 @@ interface UrlSyncContextProviderProps extends SceneUrlSyncOptions {
|
|
1827
1949
|
*/
|
1828
1950
|
declare function UrlSyncContextProvider({ children, scene, updateUrlOnInit, createBrowserHistorySteps, }: UrlSyncContextProviderProps): React$1.ReactNode;
|
1829
1951
|
|
1830
|
-
declare function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>): React__default.JSX.Element;
|
1831
|
-
|
1832
|
-
interface VizPanelMenuState extends SceneObjectState {
|
1833
|
-
items?: PanelMenuItem[];
|
1834
|
-
}
|
1835
|
-
declare class VizPanelMenu extends SceneObjectBase<VizPanelMenuState> {
|
1836
|
-
static Component: typeof VizPanelMenuRenderer;
|
1837
|
-
addItem(item: PanelMenuItem): void;
|
1838
|
-
setItems(items: PanelMenuItem[]): void;
|
1839
|
-
}
|
1840
|
-
declare function VizPanelMenuRenderer({ model }: SceneComponentProps<VizPanelMenu>): React__default.JSX.Element;
|
1841
|
-
|
1842
|
-
interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectState {
|
1843
|
-
/**
|
1844
|
-
* This is usually a plugin id that references a core plugin or an external plugin. But this can also reference a
|
1845
|
-
* runtime registered PanelPlugin registered via function registerScenePanelPlugin.
|
1846
|
-
*/
|
1847
|
-
pluginId: string;
|
1848
|
-
title: string;
|
1849
|
-
description?: string;
|
1850
|
-
options: DeepPartial<TOptions>;
|
1851
|
-
fieldConfig: FieldConfigSource<DeepPartial<TFieldConfig>>;
|
1852
|
-
pluginVersion?: string;
|
1853
|
-
displayMode?: 'default' | 'transparent';
|
1854
|
-
/**
|
1855
|
-
* Only shows header on hover, absolutly positioned above the panel.
|
1856
|
-
*/
|
1857
|
-
hoverHeader?: boolean;
|
1858
|
-
/**
|
1859
|
-
* Offset hoverHeader position on the y axis
|
1860
|
-
*/
|
1861
|
-
hoverHeaderOffset?: number;
|
1862
|
-
/**
|
1863
|
-
* Only shows vizPanelMenu on hover if false, otherwise the menu is always visible in the header
|
1864
|
-
*/
|
1865
|
-
showMenuAlways?: boolean;
|
1866
|
-
/**
|
1867
|
-
* Defines a menu in the top right of the panel. The menu object is only activated when the dropdown menu itself is shown.
|
1868
|
-
* So the best way to add dynamic menu actions and links is by adding them in a behavior attached to the menu.
|
1869
|
-
*/
|
1870
|
-
menu?: VizPanelMenu;
|
1871
|
-
/**
|
1872
|
-
* Defines a menu that renders panel link.
|
1873
|
-
**/
|
1874
|
-
titleItems?: React.ReactNode | SceneObject | SceneObject[];
|
1875
|
-
seriesLimit?: number;
|
1876
|
-
seriesLimitShowAll?: boolean;
|
1877
|
-
/**
|
1878
|
-
* Add action to the top right panel header
|
1879
|
-
*/
|
1880
|
-
headerActions?: React.ReactNode | SceneObject | SceneObject[];
|
1881
|
-
/**
|
1882
|
-
* Mainly for advanced use cases that need custom handling of PanelContext callbacks.
|
1883
|
-
*/
|
1884
|
-
extendPanelContext?: (vizPanel: VizPanel, context: PanelContext) => void;
|
1885
|
-
/**
|
1886
|
-
* Sets panel chrome collapsed state
|
1887
|
-
*/
|
1888
|
-
collapsible?: boolean;
|
1889
|
-
collapsed?: boolean;
|
1890
|
-
/**
|
1891
|
-
* @internal
|
1892
|
-
* Only for use from core to handle migration from old angular panels
|
1893
|
-
**/
|
1894
|
-
_UNSAFE_customMigrationHandler?: (panel: PanelModel, plugin: PanelPlugin) => void;
|
1895
|
-
/** Internal */
|
1896
|
-
_pluginLoadError?: string;
|
1897
|
-
/** Internal */
|
1898
|
-
_pluginInstanceState?: any;
|
1899
|
-
_renderCounter?: number;
|
1900
|
-
}
|
1901
|
-
declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
|
1902
|
-
static Component: typeof VizPanelRenderer;
|
1903
|
-
protected _variableDependency: VariableDependencyConfig<VizPanelState<TOptions, TFieldConfig>>;
|
1904
|
-
protected _panelContext?: PanelContext;
|
1905
|
-
private _plugin?;
|
1906
|
-
private _prevData?;
|
1907
|
-
private _dataWithFieldConfig?;
|
1908
|
-
private _structureRev;
|
1909
|
-
constructor(state: Partial<VizPanelState<TOptions, TFieldConfig>>);
|
1910
|
-
private _onActivate;
|
1911
|
-
forceRender(): void;
|
1912
|
-
private _loadPlugin;
|
1913
|
-
getLegacyPanelId(): number;
|
1914
|
-
private _pluginLoaded;
|
1915
|
-
private _getPluginVersion;
|
1916
|
-
getPlugin(): PanelPlugin | undefined;
|
1917
|
-
getPanelContext(): PanelContext;
|
1918
|
-
onTimeRangeChange: (timeRange: AbsoluteTimeRange) => void;
|
1919
|
-
getTimeRange: (data?: PanelData) => _grafana_data.TimeRange;
|
1920
|
-
changePluginType(pluginId: string, newOptions?: DeepPartial<{}>, newFieldConfig?: FieldConfigSource): Promise<void>;
|
1921
|
-
onTitleChange: (title: string) => void;
|
1922
|
-
onDescriptionChange: (description: string) => void;
|
1923
|
-
onDisplayModeChange: (displayMode: 'default' | 'transparent') => void;
|
1924
|
-
onToggleCollapse: (collapsed: boolean) => void;
|
1925
|
-
onOptionsChange: (optionsUpdate: DeepPartial<TOptions>, replace?: boolean, isAfterPluginChange?: boolean) => void;
|
1926
|
-
onFieldConfigChange: (fieldConfigUpdate: FieldConfigSource<DeepPartial<TFieldConfig>>, replace?: boolean) => void;
|
1927
|
-
interpolate: InterpolateFunction;
|
1928
|
-
getDescription: () => string;
|
1929
|
-
clearFieldConfigCache(): void;
|
1930
|
-
/**
|
1931
|
-
* Called from the react render path to apply the field config to the data provided by the data provider
|
1932
|
-
*/
|
1933
|
-
applyFieldConfig(rawData?: PanelData): PanelData;
|
1934
|
-
onCancelQuery: () => void;
|
1935
|
-
onStatusMessageClick: () => void;
|
1936
|
-
/**
|
1937
|
-
* Panel context functions
|
1938
|
-
*/
|
1939
|
-
private _onSeriesColorChange;
|
1940
|
-
private _onSeriesVisibilityChange;
|
1941
|
-
private _onInstanceStateChange;
|
1942
|
-
private _onToggleLegendSort;
|
1943
|
-
private buildPanelContext;
|
1944
|
-
}
|
1945
|
-
|
1946
1952
|
interface ExploreButtonOptions {
|
1947
1953
|
onClick?: () => void;
|
1948
1954
|
transform?: (query: DataQuery) => DataQuery;
|
@@ -2861,6 +2867,9 @@ declare const sceneUtils: {
|
|
2861
2867
|
syncStateFromSearchParams: typeof syncStateFromSearchParams;
|
2862
2868
|
getUrlState: typeof getUrlState;
|
2863
2869
|
renderPrometheusLabelFilters: typeof renderPrometheusLabelFilters;
|
2870
|
+
escapeLabelValueInRegexSelector: typeof escapeLabelValueInRegexSelector;
|
2871
|
+
escapeLabelValueInExactSelector: typeof escapeLabelValueInExactSelector;
|
2872
|
+
escapeURLDelimiters: typeof escapeURLDelimiters;
|
2864
2873
|
isAdHocVariable: typeof isAdHocVariable;
|
2865
2874
|
isConstantVariable: typeof isConstantVariable;
|
2866
2875
|
isCustomVariable: typeof isCustomVariable;
|