@grafana/scenes 5.26.0 → 5.27.0--canary.912.12014950388.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,98 @@
1
+ import { useStyles2, Icon, Tooltip, Button } from '@grafana/ui';
2
+ import React from 'react';
3
+ import { css } from '@emotion/css';
4
+ import { SceneObjectBase } from '../core/SceneObjectBase.js';
5
+ import { map } from 'rxjs';
6
+ import { sceneGraph } from '../core/sceneGraph/index.js';
7
+ import { SceneDataTransformer } from '../querying/SceneDataTransformer.js';
8
+ import { VizPanel } from './VizPanel/VizPanel.js';
9
+ import { SceneQueryRunner } from '../querying/SceneQueryRunner.js';
10
+
11
+ const LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY = "limit_frames_title_item_transformation";
12
+ class LimitFramesTitleItemScene extends SceneObjectBase {
13
+ constructor(state) {
14
+ super(state);
15
+ this.addActivationHandler(this.onActivate.bind(this));
16
+ }
17
+ onActivate() {
18
+ var _a;
19
+ const panel = sceneGraph.getAncestor(this, VizPanel);
20
+ const $transformedDataArray = sceneGraph.findAllObjects(panel, (scene) => scene.state.key === LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY);
21
+ const $transformedData = $transformedDataArray[0];
22
+ if ($transformedData) {
23
+ const $untransformedDataProvider = (_a = sceneGraph.findDescendent($transformedData, SceneDataTransformer)) != null ? _a : sceneGraph.findDescendent(panel, SceneQueryRunner);
24
+ this._subs.add(
25
+ $transformedData.subscribeToState((transformedDataState) => {
26
+ var _a2, _b, _c;
27
+ if ($untransformedDataProvider && ((_a2 = $untransformedDataProvider.state.data) == null ? void 0 : _a2.series.length) !== this.state.currentFrameCount) {
28
+ this.setState({
29
+ currentFrameCount: (_b = transformedDataState.data) == null ? void 0 : _b.series.length,
30
+ totalFrameCount: (_c = $untransformedDataProvider.state.data) == null ? void 0 : _c.series.length
31
+ });
32
+ }
33
+ })
34
+ );
35
+ }
36
+ }
37
+ showAllSeries() {
38
+ const $data = sceneGraph.getData(this);
39
+ if ($data instanceof SceneDataTransformer) {
40
+ $data.setState({
41
+ transformations: []
42
+ });
43
+ this.setState({
44
+ showAllFrames: true
45
+ });
46
+ $data.reprocessTransformations();
47
+ }
48
+ }
49
+ }
50
+ LimitFramesTitleItemScene.Component = ({ model }) => {
51
+ const { showAllFrames, currentFrameCount, frameLimit, totalFrameCount } = model.useState();
52
+ const styles = useStyles2(getStyles);
53
+ if (totalFrameCount === void 0 || showAllFrames || !currentFrameCount || totalFrameCount < frameLimit) {
54
+ return null;
55
+ }
56
+ return /* @__PURE__ */ React.createElement("div", {
57
+ className: styles.timeSeriesDisclaimer
58
+ }, /* @__PURE__ */ React.createElement("span", {
59
+ className: styles.warningMessage
60
+ }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Icon, {
61
+ title: `Showing only ${model.state.frameLimit} series`,
62
+ name: "exclamation-triangle",
63
+ "aria-hidden": "true"
64
+ }))), /* @__PURE__ */ React.createElement(Tooltip, {
65
+ content: "Rendering too many series in a single panel may impact performance and make data harder to read."
66
+ }, /* @__PURE__ */ React.createElement(Button, {
67
+ variant: "secondary",
68
+ size: "sm",
69
+ onClick: () => model.showAllSeries()
70
+ }, /* @__PURE__ */ React.createElement(React.Fragment, null, "Show all ", totalFrameCount))));
71
+ };
72
+ function limitFramesTransformation(limit) {
73
+ return (source) => {
74
+ return source.pipe(
75
+ map((frames) => {
76
+ return frames.slice(0, limit);
77
+ })
78
+ );
79
+ };
80
+ }
81
+ const getStyles = (theme) => ({
82
+ timeSeriesDisclaimer: css({
83
+ label: "time-series-disclaimer",
84
+ display: "flex",
85
+ alignItems: "center",
86
+ gap: theme.spacing(1)
87
+ }),
88
+ warningMessage: css({
89
+ display: "flex",
90
+ alignItems: "center",
91
+ gap: theme.spacing(0.5),
92
+ color: theme.colors.warning.main,
93
+ fontSize: theme.typography.bodySmall.fontSize
94
+ })
95
+ });
96
+
97
+ export { LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY, LimitFramesTitleItemScene, limitFramesTransformation };
98
+ //# sourceMappingURL=LimitFramesTitleItemScene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitFramesTitleItemScene.js","sources":["../../../src/components/LimitFramesTitleItemScene.tsx"],"sourcesContent":["import { Button, Icon, Tooltip, useStyles2 } from '@grafana/ui';\nimport React from 'react';\nimport { DataFrame, GrafanaTheme2 } from '@grafana/data';\nimport { css } from '@emotion/css';\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { map, Observable } from 'rxjs';\nimport { SceneComponentProps, SceneDataProvider, SceneObjectState } from '../core/types';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneDataTransformer } from '../querying/SceneDataTransformer';\nimport { VizPanel } from './VizPanel/VizPanel';\nimport { SceneQueryRunner } from '../querying/SceneQueryRunner';\n\nexport interface LimitFramesTitleItemSceneState extends SceneObjectState {\n showAllFrames?: boolean;\n currentFrameCount?: number;\n totalFrameCount?: number\n frameLimit: number\n}\n\nexport const LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY = 'limit_frames_title_item_transformation'\n\n/**\n * PanelBuilder titleItems component that will limit the default number of series rendered\n *\n * Usage:\n * PanelBuilders.timeseries()\n * .setData($data)\n * .setTitleItems([new LimitFramesTitleItemScene({\n * frameLimit: 20, // limits the default number of series that are rendered in the viz\n * })])\n */\nexport class LimitFramesTitleItemScene extends SceneObjectBase<LimitFramesTitleItemSceneState> {\n public constructor(state: LimitFramesTitleItemSceneState) {\n super(state);\n this.addActivationHandler(this.onActivate.bind(this));\n }\n\n private onActivate() {\n const panel = sceneGraph.getAncestor(this, VizPanel);\n\n const $transformedDataArray = sceneGraph.findAllObjects(panel, (scene) => scene.state.key === LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY)\n const $transformedData = $transformedDataArray[0] as SceneDataTransformer | undefined;\n\n if($transformedData){\n const $untransformedDataProvider: SceneDataProvider | undefined = sceneGraph.findDescendent($transformedData, SceneDataTransformer) ?? sceneGraph.findDescendent(panel, SceneQueryRunner)\n\n // Subscribe to data changes and update the frame counts\n this._subs.add(\n $transformedData.subscribeToState((transformedDataState) => {\n if ($untransformedDataProvider && $untransformedDataProvider.state.data?.series.length !== this.state.currentFrameCount) {\n this.setState({\n currentFrameCount: transformedDataState.data?.series.length,\n totalFrameCount: $untransformedDataProvider.state.data?.series.length\n });\n }\n })\n );\n }\n }\n\n /**\n * Removes the default series limit and renders all series in the viz\n */\n public showAllSeries () {\n const $data = sceneGraph.getData(this);\n if($data instanceof SceneDataTransformer){\n $data.setState({\n transformations: [],\n });\n this.setState({\n showAllFrames: true,\n });\n $data.reprocessTransformations();\n }\n }\n public static Component = ({ model }: SceneComponentProps<LimitFramesTitleItemScene>) => {\n const { showAllFrames, currentFrameCount, frameLimit, totalFrameCount, } = model.useState();\n const styles = useStyles2(getStyles);\n\n if (\n totalFrameCount === undefined ||\n showAllFrames ||\n !currentFrameCount ||\n totalFrameCount < frameLimit\n ) {\n return null;\n }\n\n return (\n <div className={styles.timeSeriesDisclaimer}>\n <span className={styles.warningMessage}>\n <>\n <Icon\n title={`Showing only ${model.state.frameLimit} series`}\n name=\"exclamation-triangle\"\n aria-hidden=\"true\"\n />\n </>\n </span>\n <Tooltip content={'Rendering too many series in a single panel may impact performance and make data harder to read.'}>\n <Button variant=\"secondary\" size=\"sm\" onClick={() => model.showAllSeries()}>\n <>Show all {totalFrameCount}</>\n </Button>\n </Tooltip>\n </div>\n );\n };\n}\n\nexport function limitFramesTransformation(limit: number) {\n return (source: Observable<DataFrame[]>) => {\n return source.pipe(\n map((frames) => {\n return frames.slice(0, limit);\n })\n );\n };\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n timeSeriesDisclaimer: css({\n label: 'time-series-disclaimer',\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(1),\n }),\n warningMessage: css({\n display: 'flex',\n alignItems: 'center',\n gap: theme.spacing(0.5),\n color: theme.colors.warning.main,\n fontSize: theme.typography.bodySmall.fontSize,\n }),\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,GAAI,CAAA;AAAA,IAClB,OAAS,EAAA,MAAA;AAAA,IACT,UAAY,EAAA,QAAA;AAAA,IACZ,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,IACtB,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,IAAA;AAAA,IAC5B,QAAA,EAAU,KAAM,CAAA,UAAA,CAAW,SAAU,CAAA,QAAA;AAAA,GACtC,CAAA;AACH,CAAA,CAAA;;;;"}
@@ -1,6 +1,8 @@
1
1
  import { VizPanel } from '../../components/VizPanel/VizPanel.js';
2
2
  import { FieldConfigBuilder } from './FieldConfigBuilder.js';
3
3
  import { PanelOptionsBuilder } from './PanelOptionsBuilder.js';
4
+ import { LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY, limitFramesTransformation, LimitFramesTitleItemScene } from '../../components/LimitFramesTitleItemScene.js';
5
+ import { SceneDataTransformer } from '../../querying/SceneDataTransformer.js';
4
6
 
5
7
  var __defProp = Object.defineProperty;
6
8
  var __defProps = Object.defineProperties;
@@ -37,6 +39,10 @@ class VizPanelBuilder {
37
39
  this._state.title = title;
38
40
  return this;
39
41
  }
42
+ setTitleItems(titleItems) {
43
+ this._state.titleItems = titleItems;
44
+ return this;
45
+ }
40
46
  setDescription(description) {
41
47
  this._state.description = description;
42
48
  return this;
@@ -134,12 +140,39 @@ class VizPanelBuilder {
134
140
  return this;
135
141
  }
136
142
  build() {
143
+ this.limitFrames();
137
144
  const panel = new VizPanel(__spreadProps(__spreadValues({}, this._state), {
138
145
  options: this._panelOptionsBuilder.build(),
139
146
  fieldConfig: this._fieldConfigBuilder.build()
140
147
  }));
141
148
  return panel;
142
149
  }
150
+ limitFrames() {
151
+ if (this._state.$data) {
152
+ const limitSeriesTitleItem = this.getLimitSeriesTitleItem();
153
+ if (limitSeriesTitleItem && limitSeriesTitleItem.state.frameLimit) {
154
+ this.setData(new SceneDataTransformer({
155
+ key: LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY,
156
+ $data: this._state.$data,
157
+ transformations: [() => limitFramesTransformation(limitSeriesTitleItem.state.frameLimit)]
158
+ }));
159
+ }
160
+ }
161
+ }
162
+ getLimitSeriesTitleItem() {
163
+ if (this._state.titleItems) {
164
+ if (Array.isArray(this._state.titleItems)) {
165
+ for (const titleItem of this._state.titleItems) {
166
+ if (titleItem instanceof LimitFramesTitleItemScene) {
167
+ return titleItem;
168
+ }
169
+ }
170
+ } else if (this._state.titleItems instanceof LimitFramesTitleItemScene) {
171
+ return this._state.titleItems;
172
+ }
173
+ }
174
+ return void 0;
175
+ }
143
176
  }
144
177
 
145
178
  export { VizPanelBuilder };
@@ -1 +1 @@
1
- {"version":3,"file":"VizPanelBuilder.js","sources":["../../../../src/core/PanelBuilders/VizPanelBuilder.ts"],"sourcesContent":["import { VizPanel, VizPanelState } from '../../components/VizPanel/VizPanel';\nimport { DeepPartial } from '../types';\nimport { FieldConfigBuilder } from './FieldConfigBuilder';\nimport { FieldConfigOverridesBuilder } from './FieldConfigOverridesBuilder';\nimport { PanelOptionsBuilder } from './PanelOptionsBuilder';\nimport { StandardFieldConfig, StandardFieldConfigInterface } from './types';\n\nexport class VizPanelBuilder<TOptions extends {}, TFieldConfig extends {}>\n implements StandardFieldConfigInterface<StandardFieldConfig, VizPanelBuilder<TOptions, TFieldConfig>, 'set'>\n{\n private _state: VizPanelState<TOptions, TFieldConfig> = {} as VizPanelState<TOptions, TFieldConfig>;\n private _fieldConfigBuilder: FieldConfigBuilder<TFieldConfig>;\n private _panelOptionsBuilder: PanelOptionsBuilder<TOptions>;\n\n public constructor(\n pluginId: string,\n pluginVersion: string,\n defaultOptions?: () => Partial<TOptions>,\n defaultFieldConfig?: () => TFieldConfig\n ) {\n this._state.title = '';\n this._state.description = '';\n this._state.displayMode = 'default';\n this._state.hoverHeader = false;\n this._state.pluginId = pluginId;\n this._state.pluginVersion = pluginVersion;\n\n this._fieldConfigBuilder = new FieldConfigBuilder(defaultFieldConfig);\n this._panelOptionsBuilder = new PanelOptionsBuilder(defaultOptions);\n }\n\n /**\n * Set panel title.\n */\n public setTitle(title: VizPanelState['title']): this {\n this._state.title = title;\n return this;\n }\n\n /**\n * Set panel description.\n */\n public setDescription(description: VizPanelState['description']): this {\n this._state.description = description;\n return this;\n }\n\n /**\n * Set panel display mode.\n */\n public setDisplayMode(displayMode: VizPanelState['displayMode']): this {\n this._state.displayMode = displayMode;\n return this;\n }\n\n /**\n * Set if panel header should be shown on hover.\n */\n public setHoverHeader(hoverHeader: VizPanelState['hoverHeader']): this {\n this._state.hoverHeader = hoverHeader;\n return this;\n }\n\n /**\n * Set panel menu scene object.\n */\n public setMenu(menu: VizPanelState['menu']): this {\n this._state.menu = menu;\n return this;\n }\n\n /**\n * Set scene object or react component to use as panel header actions.\n */\n public setHeaderActions(headerActions: VizPanelState['headerActions']): this {\n this._state.headerActions = headerActions;\n return this;\n }\n\n /**\n * Set color.\n */\n public setColor(color: StandardFieldConfig['color']): this {\n this._fieldConfigBuilder.setColor(color);\n return this;\n }\n\n /**\n * Set number of decimals to show.\n */\n public setDecimals(decimals: StandardFieldConfig['decimals']): this {\n this._fieldConfigBuilder.setDecimals(decimals);\n return this;\n }\n\n /**\n * Set field display name.\n */\n public setDisplayName(displayName: StandardFieldConfig['displayName']): this {\n this._fieldConfigBuilder.setDisplayName(displayName);\n return this;\n }\n\n /**\n * Set the standard field config property filterable.\n */\n public setFilterable(filterable: StandardFieldConfig['filterable']): this {\n this._fieldConfigBuilder.setFilterable(filterable);\n return this;\n }\n\n /**\n * Set data links.\n */\n public setLinks(links: StandardFieldConfig['links']): this {\n this._fieldConfigBuilder.setLinks(links);\n return this;\n }\n\n /**\n * Set value mappings.\n */\n public setMappings(mappings: StandardFieldConfig['mappings']): this {\n this._fieldConfigBuilder.setMappings(mappings);\n return this;\n }\n\n /**\n * Set the standard field config property max.\n */\n public setMax(max: StandardFieldConfig['max']): this {\n this._fieldConfigBuilder.setMax(max);\n return this;\n }\n\n /**\n * Set the standard field config property min.\n */\n public setMin(min: StandardFieldConfig['min']): this {\n this._fieldConfigBuilder.setMin(min);\n return this;\n }\n\n /**\n * Set the standard field config property noValue.\n */\n public setNoValue(noValue: StandardFieldConfig['noValue']): this {\n this._fieldConfigBuilder.setNoValue(noValue);\n return this;\n }\n\n /**\n * Set the standard field config property thresholds.\n */\n public setThresholds(thresholds: StandardFieldConfig['thresholds']): this {\n this._fieldConfigBuilder.setThresholds(thresholds);\n return this;\n }\n\n /**\n * Set the standard field config property unit.\n */\n public setUnit(unit: StandardFieldConfig['unit']): this {\n this._fieldConfigBuilder.setUnit(unit);\n return this;\n }\n\n public setCustomFieldConfig<T extends TFieldConfig, K extends keyof T>(id: K, value: DeepPartial<T[K]>): this {\n this._fieldConfigBuilder.setCustomFieldConfig(id, value);\n return this;\n }\n\n public setOverrides(builder: (b: FieldConfigOverridesBuilder<TFieldConfig>) => void): this {\n this._fieldConfigBuilder.setOverrides(builder);\n return this;\n }\n\n /**\n * Set an individual panel option. This will merge the value with the existing options.\n */\n public setOption<T extends TOptions, K extends keyof T>(id: K, value: DeepPartial<T[K]>): this {\n this._panelOptionsBuilder.setOption(id, value);\n return this;\n }\n\n /**\n * Set data provider for the panel.\n */\n public setData(data: VizPanelState['$data']): this {\n this._state.$data = data;\n return this;\n }\n\n /**\n * Set time range for the panel.\n */\n public setTimeRange(timeRange: VizPanelState['$timeRange']): this {\n this._state.$timeRange = timeRange;\n return this;\n }\n\n /**\n * Set variables for the panel.\n */\n public setVariables(variables: VizPanelState['$variables']): this {\n this._state.$variables = variables;\n return this;\n }\n\n /**\n * Set behaviors for the panel.\n */\n public setBehaviors(behaviors: VizPanelState['$behaviors']): this {\n this._state.$behaviors = behaviors;\n return this;\n }\n\n /**\n * Makes it possible to shared config between different builders\n */\n public applyMixin(mixin: (builder: this) => void): this {\n mixin(this);\n return this;\n }\n\n /**\n * Build the panel.\n */\n public build() {\n const panel = new VizPanel<TOptions, TFieldConfig>({\n ...this._state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,SAAA,CAAA;AACzB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAKO,aAAa,SAA8C,EAAA;AAChE,IAAA,IAAA,CAAK,OAAO,UAAa,GAAA,SAAA,CAAA;AACzB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAKO,aAAa,SAA8C,EAAA;AAChE,IAAA,IAAA,CAAK,OAAO,UAAa,GAAA,SAAA,CAAA;AACzB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAKO,WAAW,KAAsC,EAAA;AACtD,IAAA,KAAA,CAAM,IAAI,CAAA,CAAA;AACV,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAKO,KAAQ,GAAA;AACb,IAAA,MAAM,KAAQ,GAAA,IAAI,QAAiC,CAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAC9C,KAAK,MADyC,CAAA,EAAA;AAAA,MAEjD,OAAA,EAAS,IAAK,CAAA,oBAAA,CAAqB,KAAM,EAAA;AAAA,MACzC,WAAA,EAAa,IAAK,CAAA,mBAAA,CAAoB,KAAM,EAAA;AAAA,KAC7C,CAAA,CAAA,CAAA;AAED,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF;;;;"}
1
+ {"version":3,"file":"VizPanelBuilder.js","sources":["../../../../src/core/PanelBuilders/VizPanelBuilder.ts"],"sourcesContent":["import { VizPanel, VizPanelState } from '../../components/VizPanel/VizPanel';\nimport { DeepPartial, SceneObject } from '../types';\nimport { FieldConfigBuilder } from './FieldConfigBuilder';\nimport { FieldConfigOverridesBuilder } from './FieldConfigOverridesBuilder';\nimport { PanelOptionsBuilder } from './PanelOptionsBuilder';\nimport { StandardFieldConfig, StandardFieldConfigInterface } from './types';\nimport {\n limitFramesTransformation,\n LimitFramesTitleItemScene,\n LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY,\n} from '../../components/LimitFramesTitleItemScene';\nimport { SceneDataTransformer } from '../../querying/SceneDataTransformer';\n\nexport class VizPanelBuilder<TOptions extends {}, TFieldConfig extends {}>\n implements StandardFieldConfigInterface<StandardFieldConfig, VizPanelBuilder<TOptions, TFieldConfig>, 'set'>\n{\n private _state: VizPanelState<TOptions, TFieldConfig> = {} as VizPanelState<TOptions, TFieldConfig>;\n private _fieldConfigBuilder: FieldConfigBuilder<TFieldConfig>;\n private _panelOptionsBuilder: PanelOptionsBuilder<TOptions>;\n\n public constructor(\n pluginId: string,\n pluginVersion: string,\n defaultOptions?: () => Partial<TOptions>,\n defaultFieldConfig?: () => TFieldConfig\n ) {\n this._state.title = '';\n this._state.description = '';\n this._state.displayMode = 'default';\n this._state.hoverHeader = false;\n this._state.pluginId = pluginId;\n this._state.pluginVersion = pluginVersion;\n\n this._fieldConfigBuilder = new FieldConfigBuilder(defaultFieldConfig);\n this._panelOptionsBuilder = new PanelOptionsBuilder(defaultOptions);\n }\n\n /**\n * Set panel title.\n */\n public setTitle(title: VizPanelState['title']): this {\n this._state.title = title;\n return this;\n }\n\n public setTitleItems(titleItems: React.ReactNode | SceneObject | SceneObject[]): this {\n this._state.titleItems = titleItems\n return this;\n }\n\n /**\n * Set panel description.\n */\n public setDescription(description: VizPanelState['description']): this {\n this._state.description = description;\n return this;\n }\n\n /**\n * Set panel display mode.\n */\n public setDisplayMode(displayMode: VizPanelState['displayMode']): this {\n this._state.displayMode = displayMode;\n return this;\n }\n\n /**\n * Set if panel header should be shown on hover.\n */\n public setHoverHeader(hoverHeader: VizPanelState['hoverHeader']): this {\n this._state.hoverHeader = hoverHeader;\n return this;\n }\n\n /**\n * Set panel menu scene object.\n */\n public setMenu(menu: VizPanelState['menu']): this {\n this._state.menu = menu;\n return this;\n }\n\n /**\n * Set scene object or react component to use as panel header actions.\n */\n public setHeaderActions(headerActions: VizPanelState['headerActions']): this {\n this._state.headerActions = headerActions;\n return this;\n }\n\n /**\n * Set color.\n */\n public setColor(color: StandardFieldConfig['color']): this {\n this._fieldConfigBuilder.setColor(color);\n return this;\n }\n\n /**\n * Set number of decimals to show.\n */\n public setDecimals(decimals: StandardFieldConfig['decimals']): this {\n this._fieldConfigBuilder.setDecimals(decimals);\n return this;\n }\n\n /**\n * Set field display name.\n */\n public setDisplayName(displayName: StandardFieldConfig['displayName']): this {\n this._fieldConfigBuilder.setDisplayName(displayName);\n return this;\n }\n\n /**\n * Set the standard field config property filterable.\n */\n public setFilterable(filterable: StandardFieldConfig['filterable']): this {\n this._fieldConfigBuilder.setFilterable(filterable);\n return this;\n }\n\n /**\n * Set data links.\n */\n public setLinks(links: StandardFieldConfig['links']): this {\n this._fieldConfigBuilder.setLinks(links);\n return this;\n }\n\n /**\n * Set value mappings.\n */\n public setMappings(mappings: StandardFieldConfig['mappings']): this {\n this._fieldConfigBuilder.setMappings(mappings);\n return this;\n }\n\n /**\n * Set the standard field config property max.\n */\n public setMax(max: StandardFieldConfig['max']): this {\n this._fieldConfigBuilder.setMax(max);\n return this;\n }\n\n /**\n * Set the standard field config property min.\n */\n public setMin(min: StandardFieldConfig['min']): this {\n this._fieldConfigBuilder.setMin(min);\n return this;\n }\n\n /**\n * Set the standard field config property noValue.\n */\n public setNoValue(noValue: StandardFieldConfig['noValue']): this {\n this._fieldConfigBuilder.setNoValue(noValue);\n return this;\n }\n\n /**\n * Set the standard field config property thresholds.\n */\n public setThresholds(thresholds: StandardFieldConfig['thresholds']): this {\n this._fieldConfigBuilder.setThresholds(thresholds);\n return this;\n }\n\n /**\n * Set the standard field config property unit.\n */\n public setUnit(unit: StandardFieldConfig['unit']): this {\n this._fieldConfigBuilder.setUnit(unit);\n return this;\n }\n\n public setCustomFieldConfig<T extends TFieldConfig, K extends keyof T>(id: K, value: DeepPartial<T[K]>): this {\n this._fieldConfigBuilder.setCustomFieldConfig(id, value);\n return this;\n }\n\n public setOverrides(builder: (b: FieldConfigOverridesBuilder<TFieldConfig>) => void): this {\n this._fieldConfigBuilder.setOverrides(builder);\n return this;\n }\n\n /**\n * Set an individual panel option. This will merge the value with the existing options.\n */\n public setOption<T extends TOptions, K extends keyof T>(id: K, value: DeepPartial<T[K]>): this {\n this._panelOptionsBuilder.setOption(id, value);\n return this;\n }\n\n /**\n * Set data provider for the panel.\n */\n public setData(data: VizPanelState['$data']): this {\n this._state.$data = data;\n return this;\n }\n\n /**\n * Set time range for the panel.\n */\n public setTimeRange(timeRange: VizPanelState['$timeRange']): this {\n this._state.$timeRange = timeRange;\n return this;\n }\n\n /**\n * Set variables for the panel.\n */\n public setVariables(variables: VizPanelState['$variables']): this {\n this._state.$variables = variables;\n return this;\n }\n\n /**\n * Set behaviors for the panel.\n */\n public setBehaviors(behaviors: VizPanelState['$behaviors']): this {\n this._state.$behaviors = behaviors;\n return this;\n }\n\n /**\n * Makes it possible to shared config between different builders\n */\n public applyMixin(mixin: (builder: this) => void): this {\n mixin(this);\n return this;\n }\n\n /**\n * Build the panel.\n */\n public build() {\n this.limitFrames();\n\n const panel = new VizPanel<TOptions, TFieldConfig>({\n ...this._state,\n options: this._panelOptionsBuilder.build(),\n fieldConfig: this._fieldConfigBuilder.build(),\n });\n\n return panel;\n }\n\n /**\n * If titleItems contains TimeSeriesLimitSeriesTitleItemScene, replace queryProvider with SceneDataTransformer and limit the number of series initially rendered\n */\n private limitFrames() {\n if(this._state.$data){\n const limitSeriesTitleItem = this.getLimitSeriesTitleItem()\n\n if (limitSeriesTitleItem && limitSeriesTitleItem.state.frameLimit) {\n this.setData(new SceneDataTransformer({\n key: LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY,\n $data: this._state.$data,\n transformations: [() => limitFramesTransformation(limitSeriesTitleItem.state.frameLimit)],\n }))\n }\n }\n }\n\n /**\n * Gets titleItem of type TimeSeriesLimitSeriesTitleItemScene, if existing\n */\n private getLimitSeriesTitleItem() {\n if (this._state.titleItems) {\n if (Array.isArray(this._state.titleItems)) {\n for (const titleItem of this._state.titleItems) {\n if (titleItem instanceof LimitFramesTitleItemScene) {\n return titleItem;\n }\n }\n } else if (this._state.titleItems instanceof LimitFramesTitleItemScene) {\n return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ACnB,iBAAiB,CAAC,MAAM,0BAA0B,oBAAqB,CAAA,KAAA,CAAM,UAAU,CAAC,CAAA;AAAA,SACzF,CAAC,CAAA,CAAA;AAAA,OACJ;AAAA,KACF;AAAA,GACF;AAAA,EAKQ,uBAA0B,GAAA;AAChC,IAAI,IAAA,IAAA,CAAK,OAAO,UAAY,EAAA;AAC1B,MAAA,IAAI,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,MAAA,CAAO,UAAU,CAAG,EAAA;AACzC,QAAW,KAAA,MAAA,SAAA,IAAa,IAAK,CAAA,MAAA,CAAO,UAAY,EAAA;AAC9C,UAAA,IAAI,qBAAqB,yBAA2B,EAAA;AAClD,YAAO,OAAA,SAAA,CAAA;AAAA,WACT;AAAA,SACF;AAAA,OACS,MAAA,IAAA,IAAA,CAAK,MAAO,CAAA,UAAA,YAAsB,yBAA2B,EAAA;AACtE,QAAA,OAAO,KAAK,MAAO,CAAA,UAAA,CAAA;AAAA,OACrB;AAAA,KACF;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { lookupVariable } from '../../variables/lookupVariable.js';
2
2
  import { getTimeRange } from './getTimeRange.js';
3
- import { getVariables, getData, getLayout, getDataLayers, interpolate, hasVariableDependencyInLoadingState, findByKey, findByKeyAndType, findObject, findAllObjects, getAncestor, findDescendents, getQueryController, getUrlSyncManager } from './sceneGraph.js';
3
+ import { getVariables, getData, getLayout, getDataLayers, interpolate, hasVariableDependencyInLoadingState, findByKey, findByKeyAndType, findObject, findAllObjects, getAncestor, findDescendents, getQueryController, getUrlSyncManager, findDescendent } from './sceneGraph.js';
4
4
 
5
5
  const sceneGraph = {
6
6
  getVariables,
@@ -18,7 +18,8 @@ const sceneGraph = {
18
18
  getAncestor,
19
19
  findDescendents,
20
20
  getQueryController,
21
- getUrlSyncManager
21
+ getUrlSyncManager,
22
+ findDescendent
22
23
  };
23
24
 
24
25
  export { sceneGraph };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/sceneGraph/index.ts"],"sourcesContent":["import { lookupVariable } from '../../variables/lookupVariable';\nimport { getTimeRange } from './getTimeRange';\nimport {\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getData,\n getLayout,\n getVariables,\n getDataLayers,\n hasVariableDependencyInLoadingState,\n interpolate,\n getAncestor,\n findDescendents,\n getQueryController,\n getUrlSyncManager,\n} from './sceneGraph';\n\nexport const sceneGraph = {\n getVariables,\n getData,\n getTimeRange,\n getLayout,\n getDataLayers,\n interpolate,\n lookupVariable,\n hasVariableDependencyInLoadingState,\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getAncestor,\n findDescendents,\n getQueryController,\n getUrlSyncManager,\n};\n"],"names":[],"mappings":";;;;AAmBO,MAAM,UAAa,GAAA;AAAA,EACxB,YAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,mCAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/sceneGraph/index.ts"],"sourcesContent":["import { lookupVariable } from '../../variables/lookupVariable';\nimport { getTimeRange } from './getTimeRange';\nimport {\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getData,\n getLayout,\n getVariables,\n getDataLayers,\n hasVariableDependencyInLoadingState,\n interpolate,\n getAncestor,\n findDescendent,\n findDescendents,\n getQueryController,\n getUrlSyncManager,\n} from './sceneGraph';\n\nexport const sceneGraph = {\n getVariables,\n getData,\n getTimeRange,\n getLayout,\n getDataLayers,\n interpolate,\n lookupVariable,\n hasVariableDependencyInLoadingState,\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getAncestor,\n findDescendents,\n getQueryController,\n getUrlSyncManager,\n findDescendent,\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,UAAa,GAAA;AAAA,EACxB,YAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,mCAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AACF;;;;"}
@@ -106,6 +106,13 @@ function findAllObjects(scene, check) {
106
106
  });
107
107
  return found;
108
108
  }
109
+ function findDescendent(scene, descendentType) {
110
+ function isDescendentType(scene2) {
111
+ return scene2 instanceof descendentType;
112
+ }
113
+ const targetScenes = findAllObjects(scene, isDescendentType);
114
+ return targetScenes.find(isDescendentType);
115
+ }
109
116
  function getDataLayers(sceneObject, localOnly = false) {
110
117
  let currentLevel = sceneObject;
111
118
  let collected = [];
@@ -174,5 +181,5 @@ function getUrlSyncManager(sceneObject) {
174
181
  return void 0;
175
182
  }
176
183
 
177
- export { findAllObjects, findByKey, findByKeyAndType, findDescendents, findObject, getAncestor, getData, getDataLayers, getLayout, getQueryController, getUrlSyncManager, getVariables, hasVariableDependencyInLoadingState, interpolate };
184
+ export { findAllObjects, findByKey, findByKeyAndType, findDescendent, findDescendents, findObject, getAncestor, getData, getDataLayers, getLayout, getQueryController, getUrlSyncManager, getVariables, hasVariableDependencyInLoadingState, interpolate };
178
185
  //# sourceMappingURL=sceneGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sceneGraph.js","sources":["../../../../src/core/sceneGraph/sceneGraph.ts"],"sourcesContent":["import { ScopedVars } from '@grafana/data';\nimport { EmptyDataNode, EmptyVariableSet } from '../../variables/interpolation/defaults';\n\nimport { sceneInterpolator } from '../../variables/interpolation/sceneInterpolator';\nimport { VariableCustomFormatterFn, SceneVariables } from '../../variables/types';\n\nimport { isDataLayer, SceneDataLayerProvider, SceneDataProvider, SceneLayout, SceneObject } from '../types';\nimport { lookupVariable } from '../../variables/lookupVariable';\nimport { getClosest } from './utils';\nimport { SceneQueryControllerLike, isQueryController } from '../../behaviors/SceneQueryController';\nimport { VariableInterpolation } from '@grafana/runtime';\nimport { QueryVariable } from '../../variables/variants/query/QueryVariable';\nimport { UrlSyncManagerLike } from '../../services/UrlSyncManager';\n\n/**\n * Get the closest node with variables\n */\nexport function getVariables(sceneObject: SceneObject): SceneVariables {\n return getClosest(sceneObject, (s) => s.state.$variables) ?? EmptyVariableSet;\n}\n\n/**\n * Will walk up the scene object graph to the closest $data scene object\n */\nexport function getData(sceneObject: SceneObject): SceneDataProvider {\n return getClosest(sceneObject, (s) => s.state.$data) ?? EmptyDataNode;\n}\n\nfunction isSceneLayout(s: SceneObject): s is SceneLayout {\n return 'isDraggable' in s;\n}\n\n/**\n * Will walk up the scene object graph to the closest $layout scene object\n */\nexport function getLayout(scene: SceneObject): SceneLayout | null {\n const parent = getClosest(scene, (s) => (isSceneLayout(s) ? s : undefined));\n if (parent) {\n return parent;\n }\n\n return null;\n}\n\n/**\n * Interpolates the given string using the current scene object as context. *\n *\n * Note: the interpolations array will be mutated by adding information about variables that\n * have been interpolated during replacement. Variables that were specified in the target but not found in\n * the list of available variables are also added to the array. See {@link VariableInterpolation} for more details.\n *\n * @param {VariableInterpolation[]} interpolations an optional array that is updated with interpolated variables.\n */\nexport function interpolate(\n sceneObject: SceneObject,\n value: string | undefined | null,\n scopedVars?: ScopedVars,\n format?: string | VariableCustomFormatterFn,\n interpolations?: VariableInterpolation[]\n): string {\n if (value === '' || value == null) {\n return '';\n }\n\n return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);\n}\n\n/**\n * Checks if the variable is currently loading or waiting to update.\n * It also returns true if a dependency of the variable is loading.\n *\n * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.\n */\nexport function hasVariableDependencyInLoadingState(sceneObject: SceneObject) {\n if (!sceneObject.variableDependency) {\n return false;\n }\n\n for (const name of sceneObject.variableDependency.getNames()) {\n // This is for backwards compability. In the old architecture query variables could reference itself in a query without breaking.\n if (sceneObject instanceof QueryVariable && sceneObject.state.name === name) {\n console.warn('Query variable is referencing itself');\n continue;\n }\n\n const variable = lookupVariable(name, sceneObject);\n if (!variable) {\n continue;\n }\n\n const set = variable.parent as SceneVariables;\n if (set.isVariableLoadingOrWaitingToUpdate(variable)) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction findObjectInternal(\n scene: SceneObject,\n check: (obj: SceneObject) => boolean,\n alreadySearchedChild?: SceneObject,\n shouldSearchUp?: boolean\n): SceneObject | null {\n if (check(scene)) {\n return scene;\n }\n\n let found: SceneObject | null = null;\n\n scene.forEachChild((child) => {\n if (child === alreadySearchedChild) {\n return;\n }\n\n let maybe = findObjectInternal(child, check);\n if (maybe) {\n found = maybe;\n }\n });\n\n if (found) {\n return found;\n }\n\n if (shouldSearchUp && scene.parent) {\n return findObjectInternal(scene.parent, check, scene, true);\n }\n\n return null;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key.\n *\n * Throws error if no key-matching scene object found.\n */\nexport function findByKey(sceneObject: SceneObject, key: string) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n return found;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key and type.\n *\n * Throws error if no key-matching scene object found.\n * Throws error if the given type does not match.\n */\nexport function findByKeyAndType<TargetType extends SceneObject>(\n sceneObject: SceneObject,\n key: string,\n targetType: { new (...args: never[]): TargetType }\n) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n if (!(found instanceof targetType)) {\n throw new Error(`Found scene object with key ${key} does not match type ${targetType.name}`);\n }\n return found;\n}\n\n/**\n * This will search the full scene graph, starting with the scene node passed in, then walking up the parent chain. *\n */\nexport function findObject(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject | null {\n return findObjectInternal(scene, check, undefined, true);\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided predicate.\n */\nexport function findAllObjects(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject[] {\n const found: SceneObject[] = [];\n\n scene.forEachChild((child) => {\n if (check(child)) {\n found.push(child);\n }\n\n found.push(...findAllObjects(child, check));\n });\n\n return found;\n}\n\n/**\n * Will walk up the scene object graph up until the root and collect all SceneDataLayerProvider objects.\n * When localOnly set to true, it will only collect the closest layers.\n */\nexport function getDataLayers(sceneObject: SceneObject, localOnly = false): SceneDataLayerProvider[] {\n let currentLevel: SceneObject | undefined = sceneObject;\n let collected: SceneDataLayerProvider[] = [];\n\n while (currentLevel) {\n const dataProvider = currentLevel.state.$data;\n if (!dataProvider) {\n currentLevel = currentLevel.parent;\n continue;\n }\n\n // Check if data layer exists nested inside another data provider\n if (isDataLayer(dataProvider)) {\n collected = collected.concat(dataProvider);\n } else {\n if (dataProvider.state.$data && isDataLayer(dataProvider.state.$data)) {\n collected = collected.concat(dataProvider.state.$data);\n }\n }\n\n if (localOnly && collected.length > 0) {\n break;\n }\n\n currentLevel = currentLevel.parent;\n }\n\n return collected;\n}\n\ninterface SceneType<T> extends Function {\n new (...args: never[]): T;\n}\n\n/**\n * A utility function to find the closest ancestor of a given type. This function expects\n * to find it and will throw an error if it does not.\n */\nexport function getAncestor<ParentType>(\n sceneObject: SceneObject,\n ancestorType: SceneType<ParentType>\n): ParentType {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if (parent instanceof ancestorType) {\n return parent;\n }\n parent = parent.parent;\n }\n\n if (!parent) {\n throw new Error('Unable to find parent of type ' + ancestorType.name);\n }\n\n return parent as ParentType;\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided descendentType type.\n */\nexport function findDescendents<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>) {\n function isDescendentType(scene: SceneObject): scene is T {\n return scene instanceof descendentType;\n }\n\n const targetScenes = findAllObjects(scene, isDescendentType);\n return targetScenes.filter(isDescendentType);\n}\n\n/**\n * Returns the closest query controller undefined if none found\n */\nexport function getQueryController(sceneObject: SceneObject): SceneQueryControllerLike | undefined {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if (parent.state.$behaviors) {\n for (const behavior of parent.state.$behaviors) {\n if (isQueryController(behavior)) {\n return behavior;\n }\n }\n }\n parent = parent.parent;\n }\n\n return undefined;\n}\n\n/**\n * Returns the closest SceneObject that has a state property with the\n * name urlSyncManager that is of type UrlSyncManager\n */\nexport function getUrlSyncManager(sceneObject: SceneObject): UrlSyncManagerLike | undefined {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if ('urlSyncManager' in parent.state) {\n return parent.state.urlSyncManager as UrlSyncManagerLike;\n }\n parent = parent.parent;\n }\n\n return undefined;\n}\n"],"names":["scene"],"mappings":";;;;;;;;AAiBO,SAAS,aAAa,WAA0C,EAAA;AAjBvE,EAAA,IAAA,EAAA,CAAA;AAkBE,EAAO,OAAA,CAAA,EAAA,GAAA,UAAA,CAAW,aAAa,CAAC,CAAA,KAAM,EAAE,KAAM,CAAA,UAAU,MAAjD,IAAsD,GAAA,EAAA,GAAA,gBAAA,CAAA;AAC/D,CAAA;AAKO,SAAS,QAAQ,WAA6C,EAAA;AAxBrE,EAAA,IAAA,EAAA,CAAA;AAyBE,EAAO,OAAA,CAAA,EAAA,GAAA,UAAA,CAAW,aAAa,CAAC,CAAA,KAAM,EAAE,KAAM,CAAA,KAAK,MAA5C,IAAiD,GAAA,EAAA,GAAA,aAAA,CAAA;AAC1D,CAAA;AAEA,SAAS,cAAc,CAAkC,EAAA;AACvD,EAAA,OAAO,aAAiB,IAAA,CAAA,CAAA;AAC1B,CAAA;AAKO,S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CAAA;AAAA,GAC1B;AAEA,EAAM,MAAA,YAAA,GAAe,cAAe,CAAA,KAAA,EAAO,gBAAgB,CAAA,CAAA;AAC3D,EAAO,OAAA,YAAA,CAAa,OAAO,gBAAgB,CAAA,CAAA;AAC7C,CAAA;AAKO,SAAS,mBAAmB,WAAgE,EAAA;AACjG,EAAA,IAAI,MAAkC,GAAA,WAAA,CAAA;AAEtC,EAAA,OAAO,MAAQ,EAAA;AACb,IAAI,IAAA,MAAA,CAAO,MAAM,UAAY,EAAA;AAC3B,MAAW,KAAA,MAAA,QAAA,IAAY,MAAO,CAAA,KAAA,CAAM,UAAY,EAAA;AAC9C,QAAI,IAAA,iBAAA,CAAkB,QAAQ,CAAG,EAAA;AAC/B,UAAO,OAAA,QAAA,CAAA;AAAA,SACT;AAAA,OACF;AAAA,KACF;AACA,IAAA,MAAA,GAAS,MAAO,CAAA,MAAA,CAAA;AAAA,GAClB;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT,CAAA;AAMO,SAAS,kBAAkB,WAA0D,EAAA;AAC1F,EAAA,IAAI,MAAkC,GAAA,WAAA,CAAA;AAEtC,EAAA,OAAO,MAAQ,EAAA;AACb,IAAI,IAAA,gBAAA,IAAoB,OAAO,KAAO,EAAA;AACpC,MAAA,OAAO,OAAO,KAAM,CAAA,cAAA,CAAA;AAAA,KACtB;AACA,IAAA,MAAA,GAAS,MAAO,CAAA,MAAA,CAAA;AAAA,GAClB;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"sceneGraph.js","sources":["../../../../src/core/sceneGraph/sceneGraph.ts"],"sourcesContent":["import { ScopedVars } from '@grafana/data';\nimport { EmptyDataNode, EmptyVariableSet } from '../../variables/interpolation/defaults';\n\nimport { sceneInterpolator } from '../../variables/interpolation/sceneInterpolator';\nimport { VariableCustomFormatterFn, SceneVariables } from '../../variables/types';\n\nimport { isDataLayer, SceneDataLayerProvider, SceneDataProvider, SceneLayout, SceneObject } from '../types';\nimport { lookupVariable } from '../../variables/lookupVariable';\nimport { getClosest } from './utils';\nimport { SceneQueryControllerLike, isQueryController } from '../../behaviors/SceneQueryController';\nimport { VariableInterpolation } from '@grafana/runtime';\nimport { QueryVariable } from '../../variables/variants/query/QueryVariable';\nimport { UrlSyncManagerLike } from '../../services/UrlSyncManager';\n\n/**\n * Get the closest node with variables\n */\nexport function getVariables(sceneObject: SceneObject): SceneVariables {\n return getClosest(sceneObject, (s) => s.state.$variables) ?? EmptyVariableSet;\n}\n\n/**\n * Will walk up the scene object graph to the closest $data scene object\n */\nexport function getData(sceneObject: SceneObject): SceneDataProvider {\n return getClosest(sceneObject, (s) => s.state.$data) ?? EmptyDataNode;\n}\n\nfunction isSceneLayout(s: SceneObject): s is SceneLayout {\n return 'isDraggable' in s;\n}\n\n/**\n * Will walk up the scene object graph to the closest $layout scene object\n */\nexport function getLayout(scene: SceneObject): SceneLayout | null {\n const parent = getClosest(scene, (s) => (isSceneLayout(s) ? s : undefined));\n if (parent) {\n return parent;\n }\n\n return null;\n}\n\n/**\n * Interpolates the given string using the current scene object as context. *\n *\n * Note: the interpolations array will be mutated by adding information about variables that\n * have been interpolated during replacement. Variables that were specified in the target but not found in\n * the list of available variables are also added to the array. See {@link VariableInterpolation} for more details.\n *\n * @param {VariableInterpolation[]} interpolations an optional array that is updated with interpolated variables.\n */\nexport function interpolate(\n sceneObject: SceneObject,\n value: string | undefined | null,\n scopedVars?: ScopedVars,\n format?: string | VariableCustomFormatterFn,\n interpolations?: VariableInterpolation[]\n): string {\n if (value === '' || value == null) {\n return '';\n }\n\n return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);\n}\n\n/**\n * Checks if the variable is currently loading or waiting to update.\n * It also returns true if a dependency of the variable is loading.\n *\n * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.\n */\nexport function hasVariableDependencyInLoadingState(sceneObject: SceneObject) {\n if (!sceneObject.variableDependency) {\n return false;\n }\n\n for (const name of sceneObject.variableDependency.getNames()) {\n // This is for backwards compability. In the old architecture query variables could reference itself in a query without breaking.\n if (sceneObject instanceof QueryVariable && sceneObject.state.name === name) {\n console.warn('Query variable is referencing itself');\n continue;\n }\n\n const variable = lookupVariable(name, sceneObject);\n if (!variable) {\n continue;\n }\n\n const set = variable.parent as SceneVariables;\n if (set.isVariableLoadingOrWaitingToUpdate(variable)) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction findObjectInternal(\n scene: SceneObject,\n check: (obj: SceneObject) => boolean,\n alreadySearchedChild?: SceneObject,\n shouldSearchUp?: boolean\n): SceneObject | null {\n if (check(scene)) {\n return scene;\n }\n\n let found: SceneObject | null = null;\n\n scene.forEachChild((child) => {\n if (child === alreadySearchedChild) {\n return;\n }\n\n let maybe = findObjectInternal(child, check);\n if (maybe) {\n found = maybe;\n }\n });\n\n if (found) {\n return found;\n }\n\n if (shouldSearchUp && scene.parent) {\n return findObjectInternal(scene.parent, check, scene, true);\n }\n\n return null;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key.\n *\n * Throws error if no key-matching scene object found.\n */\nexport function findByKey(sceneObject: SceneObject, key: string) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n return found;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key and type.\n *\n * Throws error if no key-matching scene object found.\n * Throws error if the given type does not match.\n */\nexport function findByKeyAndType<TargetType extends SceneObject>(\n sceneObject: SceneObject,\n key: string,\n targetType: { new (...args: never[]): TargetType }\n) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n if (!(found instanceof targetType)) {\n throw new Error(`Found scene object with key ${key} does not match type ${targetType.name}`);\n }\n return found;\n}\n\n/**\n * This will search the full scene graph, starting with the scene node passed in, then walking up the parent chain. *\n */\nexport function findObject(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject | null {\n return findObjectInternal(scene, check, undefined, true);\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided predicate.\n */\nexport function findAllObjects(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject[] {\n const found: SceneObject[] = [];\n\n scene.forEachChild((child) => {\n if (check(child)) {\n found.push(child);\n }\n\n found.push(...findAllObjects(child, check));\n });\n\n return found;\n}\n\nexport function findDescendent<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>) {\n function isDescendentType(scene: SceneObject): scene is T {\n return scene instanceof descendentType;\n }\n\n const targetScenes = findAllObjects(scene, isDescendentType);\n return targetScenes.find(isDescendentType);\n}\n\n/**\n * Will walk up the scene object graph up until the root and collect all SceneDataLayerProvider objects.\n * When localOnly set to true, it will only collect the closest layers.\n */\nexport function getDataLayers(sceneObject: SceneObject, localOnly = false): SceneDataLayerProvider[] {\n let currentLevel: SceneObject | undefined = sceneObject;\n let collected: SceneDataLayerProvider[] = [];\n\n while (currentLevel) {\n const dataProvider = currentLevel.state.$data;\n if (!dataProvider) {\n currentLevel = currentLevel.parent;\n continue;\n }\n\n // Check if data layer exists nested inside another data provider\n if (isDataLayer(dataProvider)) {\n collected = collected.concat(dataProvider);\n } else {\n if (dataProvider.state.$data && isDataLayer(dataProvider.state.$data)) {\n collected = collected.concat(dataProvider.state.$data);\n }\n }\n\n if (localOnly && collected.length > 0) {\n break;\n }\n\n currentLevel = currentLevel.parent;\n }\n\n return collected;\n}\n\ninterface SceneType<T> extends Function {\n new (...args: never[]): T;\n}\n\n/**\n * A utility function to find the closest ancestor of a given type. This function expects\n * to find it and will throw an error if it does not.\n */\nexport function getAncestor<ParentType>(\n sceneObject: SceneObject,\n ancestorType: SceneType<ParentType>\n): ParentType {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if (parent instanceof ancestorType) {\n return parent;\n }\n parent = parent.parent;\n }\n\n if (!parent) {\n throw new Error('Unable to find parent of type ' + ancestorType.name);\n }\n\n return parent as ParentType;\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided descendentType type.\n */\nexport function findDescendents<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>) {\n function isDescendentType(scene: SceneObject): scene is T {\n return scene instanceof descendentType;\n }\n\n const targetScenes = findAllObjects(scene, isDescendentType);\n return targetScenes.filter(isDescendentType);\n}\n\n/**\n * Returns the closest query controller undefined if none found\n */\nexport function getQueryController(sceneObject: SceneObject): SceneQueryControllerLike | undefined {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if (parent.state.$behaviors) {\n for (const behavior of parent.state.$behaviors) {\n if (isQueryController(behavior)) {\n return behavior;\n }\n }\n }\n parent = parent.parent;\n }\n\n return undefined;\n}\n\n/**\n * Returns the closest SceneObject that has a state property with the\n * name urlSyncManager that is of type UrlSyncManager\n */\nexport function getUrlSyncManager(sceneObject: SceneObject): UrlSyncManagerLike | undefined {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if ('urlSyncManager' in parent.state) {\n return parent.state.urlSyncManager as UrlSyncManagerLike;\n }\n parent = parent.parent;\n }\n\n return undefined;\n}\n"],"names":["scene"],"mappings":";;;;;;;;AAiBO,SAAS,aAAa,WAA0C,EAAA;AAjBvE,EAAA,IAAA,EAAA,CAAA;AAkBE,EAAO,OAAA,CAAA,EAAA,GAAA,UAAA,CAAW,aAAa,CAAC,CAAA,KAAM,EAAE,KAAM,CAAA,UAAU,MAAjD,IAAsD,GAAA,EAAA,GAAA,gBAAA,CAAA;AAC/D,CAAA;AAKO,SAAS,QAAQ,WAA6C,EAAA;AAxBrE,EAAA,IAAA,EAAA,CAAA;AAyBE,EAAO,OAAA,CAAA,EAAA,GAAA,UAAA,CAAW,aAAa,CAAC,CAAA,KAAM,EAAE,KAAM,CAAA,KAAK,MAA5C,IAAiD,GAAA,EAAA,GAAA,aAAA,CAAA;AAC1D,CAAA;AAEA,SAAS,cAAc,CAAkC,EAAA;AACvD,EAAA,OAAO,aAAiB,IAAA,C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AAA,KAAA,CAAA,CAAA;AACT;;;;"}
package/dist/esm/index.js CHANGED
@@ -60,6 +60,7 @@ export { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare.js';
60
60
  export { SceneByFrameRepeater } from './components/SceneByFrameRepeater.js';
61
61
  export { SceneByVariableRepeater } from './components/SceneByVariableRepeater.js';
62
62
  export { SceneControlsSpacer } from './components/SceneControlsSpacer.js';
63
+ export { LimitFramesTitleItemScene } from './components/LimitFramesTitleItemScene.js';
63
64
  export { SceneFlexItem, SceneFlexLayout } from './components/layout/SceneFlexLayout.js';
64
65
  export { SceneCSSGridItem, SceneCSSGridLayout } from './components/layout/CSSGrid/SceneCSSGridLayout.js';
65
66
  export { SceneGridLayout } from './components/layout/grid/SceneGridLayout.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/utils';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport { renderPrometheusLabelFilters } from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport { DataProviderProxy } from './querying/DataProviderProxy';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n} from './behaviors/SceneQueryController';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, NewSceneObjectAddedEvent } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { ControlsLabel } from './utils/ControlsLabel';\nexport { renderSelectForVariable } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\nexport { getExploreURL } from './utils/explore';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/utils';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport { renderPrometheusLabelFilters } from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport { DataProviderProxy } from './querying/DataProviderProxy';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n} from './behaviors/SceneQueryController';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, NewSceneObjectAddedEvent } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {LimitFramesTitleItemScene} from './components/LimitFramesTitleItemScene'\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { ControlsLabel } from './utils/ControlsLabel';\nexport { renderSelectForVariable } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\nexport { getExploreURL } from './utils/explore';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
package/dist/index.d.ts CHANGED
@@ -1082,6 +1082,7 @@ declare function findObject(scene: SceneObject, check: (obj: SceneObject) => boo
1082
1082
  * This will search down the full scene graph, looking for objects that match the provided predicate.
1083
1083
  */
1084
1084
  declare function findAllObjects(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject[];
1085
+ declare function findDescendent<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>): T | undefined;
1085
1086
  /**
1086
1087
  * Will walk up the scene object graph up until the root and collect all SceneDataLayerProvider objects.
1087
1088
  * When localOnly set to true, it will only collect the closest layers.
@@ -1126,6 +1127,7 @@ declare const sceneGraph: {
1126
1127
  findDescendents: typeof findDescendents;
1127
1128
  getQueryController: typeof getQueryController;
1128
1129
  getUrlSyncManager: typeof getUrlSyncManager;
1130
+ findDescendent: typeof findDescendent;
1129
1131
  };
1130
1132
 
1131
1133
  interface ActWhenVariableChangedState extends SceneObjectState {
@@ -2006,6 +2008,32 @@ declare class SceneControlsSpacer extends SceneObjectBase {
2006
2008
  static Component: (_props: SceneComponentProps<SceneControlsSpacer>) => React__default.JSX.Element;
2007
2009
  }
2008
2010
 
2011
+ interface LimitFramesTitleItemSceneState extends SceneObjectState {
2012
+ showAllFrames?: boolean;
2013
+ currentFrameCount?: number;
2014
+ totalFrameCount?: number;
2015
+ frameLimit: number;
2016
+ }
2017
+ /**
2018
+ * PanelBuilder titleItems component that will limit the default number of series rendered
2019
+ *
2020
+ * Usage:
2021
+ * PanelBuilders.timeseries()
2022
+ * .setData($data)
2023
+ * .setTitleItems([new LimitFramesTitleItemScene({
2024
+ * frameLimit: 20, // limits the default number of series that are rendered in the viz
2025
+ * })])
2026
+ */
2027
+ declare class LimitFramesTitleItemScene extends SceneObjectBase<LimitFramesTitleItemSceneState> {
2028
+ constructor(state: LimitFramesTitleItemSceneState);
2029
+ private onActivate;
2030
+ /**
2031
+ * Removes the default series limit and renders all series in the viz
2032
+ */
2033
+ showAllSeries(): void;
2034
+ static Component: ({ model }: SceneComponentProps<LimitFramesTitleItemScene>) => React__default.JSX.Element | null;
2035
+ }
2036
+
2009
2037
  interface SceneFlexItemStateLike extends SceneFlexItemPlacement, SceneObjectState {
2010
2038
  }
2011
2039
  interface SceneFlexItemLike extends SceneObject<SceneFlexItemStateLike> {
@@ -2430,6 +2458,7 @@ declare class VizPanelBuilder<TOptions extends {}, TFieldConfig extends {}> impl
2430
2458
  * Set panel title.
2431
2459
  */
2432
2460
  setTitle(title: VizPanelState['title']): this;
2461
+ setTitleItems(titleItems: React.ReactNode | SceneObject | SceneObject[]): this;
2433
2462
  /**
2434
2463
  * Set panel description.
2435
2464
  */
@@ -2524,6 +2553,14 @@ declare class VizPanelBuilder<TOptions extends {}, TFieldConfig extends {}> impl
2524
2553
  * Build the panel.
2525
2554
  */
2526
2555
  build(): VizPanel<TOptions, TFieldConfig>;
2556
+ /**
2557
+ * If titleItems contains TimeSeriesLimitSeriesTitleItemScene, replace queryProvider with SceneDataTransformer and limit the number of series initially rendered
2558
+ */
2559
+ private limitFrames;
2560
+ /**
2561
+ * Gets titleItem of type TimeSeriesLimitSeriesTitleItemScene, if existing
2562
+ */
2563
+ private getLimitSeriesTitleItem;
2527
2564
  }
2528
2565
 
2529
2566
  declare class PanelOptionsBuilder<TOptions extends {} = {}> {
@@ -2827,4 +2864,4 @@ declare const sceneUtils: {
2827
2864
  isGroupByVariable: typeof isGroupByVariable;
2828
2865
  };
2829
2866
 
2830
- export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLabel, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataProviderProxy, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
2867
+ export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLabel, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataProviderProxy, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LimitFramesTitleItemScene, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, NewSceneObjectAddedEvent, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };