@grafana/scenes 4.5.0 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -901,8 +901,8 @@ declare class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
901
901
  * Allows clearing the value of the variable to an empty value. Overrides default behavior of a MultiValueVariable
902
902
  */
903
903
  getDefaultMultiState(options: VariableValueOption[]): {
904
- value: never[];
905
- text: never[];
904
+ value: VariableValueSingle[];
905
+ text: string[];
906
906
  };
907
907
  /**
908
908
  * Get all queries in the scene that have the same datasource as this AggregationsSet
@@ -1090,7 +1090,7 @@ declare class LiveNowTimer extends SceneObjectBase<LiveNowTimerState> {
1090
1090
  private timerId;
1091
1091
  private static REFRESH_RATE;
1092
1092
  constructor({ enabled }: {
1093
- enabled?: boolean | undefined;
1093
+ enabled?: boolean;
1094
1094
  });
1095
1095
  private _activationHandler;
1096
1096
  enable(): void;
@@ -1185,18 +1185,18 @@ declare class AnnotationsDataLayer extends SceneDataLayerBase<AnnotationsDataLay
1185
1185
  protected processEvents(query: AnnotationQuery, events: AnnotationQueryResults): {
1186
1186
  state: LoadingState;
1187
1187
  series: _grafana_data.DataFrame[];
1188
- structureRev?: number | undefined;
1189
- annotations?: _grafana_data.DataFrame[] | undefined;
1190
- alertState?: _grafana_data.AlertStateInfo | undefined;
1191
- request?: _grafana_data.DataQueryRequest<_grafana_data.DataQuery> | undefined;
1192
- timings?: _grafana_data.DataQueryTimings | undefined;
1193
- errors?: _grafana_data.DataQueryError[] | undefined;
1194
- error?: _grafana_data.DataQueryError | undefined;
1188
+ structureRev?: number;
1189
+ annotations?: _grafana_data.DataFrame[];
1190
+ alertState?: _grafana_data.AlertStateInfo;
1191
+ request?: _grafana_data.DataQueryRequest<_grafana_data.DataQuery>;
1192
+ timings?: _grafana_data.DataQueryTimings;
1193
+ errors?: _grafana_data.DataQueryError[];
1194
+ error?: _grafana_data.DataQueryError;
1195
1195
  timeRange: _grafana_data.TimeRange;
1196
- traceIds?: string[] | undefined;
1196
+ traceIds?: string[];
1197
1197
  };
1198
1198
  }
1199
- declare function AnnotationsDataLayerRenderer({ model }: SceneComponentProps<AnnotationsDataLayer>): JSX.Element | null;
1199
+ declare function AnnotationsDataLayerRenderer({ model }: SceneComponentProps<AnnotationsDataLayer>): JSX.Element;
1200
1200
 
1201
1201
  type index_AnnotationsDataLayer = AnnotationsDataLayer;
1202
1202
  declare const index_AnnotationsDataLayer: typeof AnnotationsDataLayer;
@@ -1303,7 +1303,7 @@ declare class SceneDataLayerControls extends SceneObjectBase<SceneDataLayerContr
1303
1303
  static Component: typeof SceneDataLayerControlsRenderer;
1304
1304
  constructor();
1305
1305
  }
1306
- declare function SceneDataLayerControlsRenderer({ model }: SceneComponentProps<SceneDataLayerControls>): JSX.Element | null;
1306
+ declare function SceneDataLayerControlsRenderer({ model }: SceneComponentProps<SceneDataLayerControls>): JSX.Element;
1307
1307
 
1308
1308
  interface SceneDataTransformerState extends SceneDataState {
1309
1309
  /**
@@ -1358,7 +1358,7 @@ interface VariableValueControlState extends SceneObjectState {
1358
1358
  declare class VariableValueControl extends SceneObjectBase<VariableValueControlState> {
1359
1359
  static Component: typeof VariableValueControlRenderer;
1360
1360
  }
1361
- declare function VariableValueControlRenderer({ model }: SceneComponentProps<VariableValueControl>): JSX.Element | null;
1361
+ declare function VariableValueControlRenderer({ model }: SceneComponentProps<VariableValueControl>): JSX.Element;
1362
1362
 
1363
1363
  declare class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> implements SceneVariables {
1364
1364
  /** Variables that have changed in since the activation or since the first manual value change */
@@ -1689,7 +1689,7 @@ declare class SceneTimePicker extends SceneObjectBase<SceneTimePickerState> {
1689
1689
  onMoveBackward: () => void;
1690
1690
  onMoveForward: () => void;
1691
1691
  }
1692
- declare function SceneTimePickerRenderer({ model }: SceneComponentProps<SceneTimePicker>): JSX.Element | null;
1692
+ declare function SceneTimePickerRenderer({ model }: SceneComponentProps<SceneTimePicker>): JSX.Element;
1693
1693
 
1694
1694
  interface SceneRefreshPickerState extends SceneObjectState {
1695
1695
  refresh: string;
@@ -1785,7 +1785,7 @@ declare class SceneFlexLayout extends SceneObjectBase<SceneFlexLayoutState> impl
1785
1785
  toggleDirection(): void;
1786
1786
  isDraggable(): boolean;
1787
1787
  }
1788
- declare function SceneFlexLayoutRenderer({ model, parentState }: SceneFlexItemRenderProps$1<SceneFlexLayout>): JSX.Element | null;
1788
+ declare function SceneFlexLayoutRenderer({ model, parentState }: SceneFlexItemRenderProps$1<SceneFlexLayout>): JSX.Element;
1789
1789
  interface SceneFlexItemPlacement {
1790
1790
  wrap?: CSSProperties['flexWrap'];
1791
1791
  direction?: CSSProperties['flexDirection'];
@@ -1817,7 +1817,7 @@ interface SceneFlexItemRenderProps$1<T> extends SceneComponentProps<T> {
1817
1817
  declare class SceneFlexItem extends SceneObjectBase<SceneFlexItemState> {
1818
1818
  static Component: typeof SceneFlexItemRenderer;
1819
1819
  }
1820
- declare function SceneFlexItemRenderer({ model, parentState }: SceneFlexItemRenderProps$1<SceneFlexItem>): JSX.Element | null;
1820
+ declare function SceneFlexItemRenderer({ model, parentState }: SceneFlexItemRenderProps$1<SceneFlexItem>): JSX.Element;
1821
1821
 
1822
1822
  interface SceneCSSGridLayoutState extends SceneObjectState, SceneCSSGridLayoutOptions {
1823
1823
  children: Array<SceneCSSGridItem | SceneObject>;
@@ -1861,7 +1861,7 @@ declare class SceneCSSGridLayout extends SceneObjectBase<SceneCSSGridLayoutState
1861
1861
  constructor(state: Partial<SceneCSSGridLayoutState>);
1862
1862
  isDraggable(): boolean;
1863
1863
  }
1864
- declare function SceneCSSGridLayoutRenderer({ model }: SceneCSSGridItemRenderProps<SceneCSSGridLayout>): JSX.Element | null;
1864
+ declare function SceneCSSGridLayoutRenderer({ model }: SceneCSSGridItemRenderProps<SceneCSSGridLayout>): JSX.Element;
1865
1865
  interface SceneCSSGridItemPlacement {
1866
1866
  /**
1867
1867
  * True when the item should rendered but not visible.
@@ -1883,7 +1883,7 @@ interface SceneCSSGridItemRenderProps<T> extends SceneComponentProps<T> {
1883
1883
  declare class SceneCSSGridItem extends SceneObjectBase<SceneCSSGridItemState> {
1884
1884
  static Component: typeof SceneCSSGridItemRenderer;
1885
1885
  }
1886
- declare function SceneCSSGridItemRenderer({ model, parentState }: SceneCSSGridItemRenderProps<SceneCSSGridItem>): JSX.Element | null;
1886
+ declare function SceneCSSGridItemRenderer({ model, parentState }: SceneCSSGridItemRenderProps<SceneCSSGridItem>): JSX.Element;
1887
1887
 
1888
1888
  declare function SceneGridLayoutRenderer({ model }: SceneComponentProps<SceneGridLayout>): JSX.Element;
1889
1889
 
@@ -1925,7 +1925,7 @@ declare function SceneGridRowRenderer({ model }: SceneComponentProps<SceneGridRo
1925
1925
 
1926
1926
  interface SceneGridLayoutState extends SceneObjectState {
1927
1927
  /**
1928
- * Turn on or off dragging for all items. Indiviadual items can still disabled via isDraggable property
1928
+ * Turn on or off dragging for all items. Individual items can still disabled via isDraggable property
1929
1929
  **/
1930
1930
  isDraggable?: boolean;
1931
1931
  /** Enable or disable item resizing */
@@ -1942,6 +1942,8 @@ interface SceneGridLayoutState extends SceneObjectState {
1942
1942
  declare class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> implements SceneLayout {
1943
1943
  static Component: typeof SceneGridLayoutRenderer;
1944
1944
  private _skipOnLayoutChange;
1945
+ private _oldLayout;
1946
+ private _loadOldLayout;
1945
1947
  constructor(state: SceneGridLayoutState);
1946
1948
  /**
1947
1949
  * SceneLayout interface. Used for example by VizPanelRenderer
@@ -1958,14 +1960,15 @@ declare class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> impl
1958
1960
  onResizeStop: ReactGridLayout.ItemCallback;
1959
1961
  private pushChildDown;
1960
1962
  /**
1961
- * We assume the layout array is storted according to y pos, and walk upwards until we find a row.
1963
+ * We assume the layout array is sorted according to y pos, and walk upwards until we find a row.
1962
1964
  * If it is collapsed there is no row to add it to. The default is then to return the SceneGridLayout itself
1963
1965
  */
1964
1966
  private findGridItemSceneParent;
1965
1967
  /**
1966
- * This likely needs a slighltly different approach. Where we clone or deactivate or and re-activate the moved child
1968
+ * This likely needs a slightly different approach. Where we clone or deactivate or and re-activate the moved child
1967
1969
  */
1968
1970
  moveChildTo(child: SceneGridItemLike, target: SceneGridLayout | SceneGridRow): SceneGridItemLike[];
1971
+ onDragStart: ReactGridLayout.ItemCallback;
1969
1972
  onDragStop: ReactGridLayout.ItemCallback;
1970
1973
  private toGridCell;
1971
1974
  buildGridLayout(width: number, height: number): ReactGridLayout.Layout[];
@@ -1977,9 +1980,9 @@ interface SceneGridItemState extends SceneGridItemStateLike {
1977
1980
  declare class SceneGridItem extends SceneObjectBase<SceneGridItemState> implements SceneGridItemLike {
1978
1981
  static Component: typeof SceneGridItemRenderer;
1979
1982
  }
1980
- declare function SceneGridItemRenderer({ model }: SceneComponentProps<SceneGridItem>): JSX.Element | null;
1983
+ declare function SceneGridItemRenderer({ model }: SceneComponentProps<SceneGridItem>): JSX.Element;
1981
1984
 
1982
- declare function SplitLayoutRenderer({ model }: SceneFlexItemRenderProps<SplitLayout>): JSX.Element | null;
1985
+ declare function SplitLayoutRenderer({ model }: SceneFlexItemRenderProps<SplitLayout>): JSX.Element;
1983
1986
  interface SceneFlexItemRenderProps<T> extends SceneComponentProps<T> {
1984
1987
  parentState?: SceneFlexItemPlacement;
1985
1988
  }
@@ -2097,7 +2100,7 @@ declare class SceneAppPage extends SceneObjectBase<SceneAppPageState> implements
2097
2100
  initializeScene(scene: EmbeddedScene): void;
2098
2101
  getScene(routeMatch: SceneRouteMatch): EmbeddedScene;
2099
2102
  getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch<{}>): SceneAppPageLike;
2100
- enrichDataRequest(source: SceneObject): Partial<_grafana_data.DataQueryRequest<_grafana_data.DataQuery>> | null;
2103
+ enrichDataRequest(source: SceneObject): Partial<_grafana_data.DataQueryRequest<_grafana_data.DataQuery>>;
2101
2104
  }
2102
2105
  interface SceneAppPageRendererProps extends SceneComponentProps<SceneAppPage> {
2103
2106
  routeProps: RouteComponentProps;
@@ -2122,7 +2125,7 @@ interface SceneReactObjectState<TProps = {}> extends SceneObjectState {
2122
2125
  * A utility object that can be used to render any React component or ReactNode
2123
2126
  */
2124
2127
  declare class SceneReactObject<TProps = {}> extends SceneObjectBase<SceneReactObjectState<TProps>> {
2125
- static Component: ({ model }: SceneComponentProps<SceneReactObject>) => {} | null;
2128
+ static Component: ({ model }: SceneComponentProps<SceneReactObject>) => {};
2126
2129
  }
2127
2130
 
2128
2131
  type StandardFieldConfigInterface<T, C, Prefix extends string> = {
@@ -2275,7 +2278,7 @@ declare class VizPanelBuilder<TOptions extends {}, TFieldConfig extends {}> impl
2275
2278
  declare class PanelOptionsBuilder<TOptions extends {} = {}> {
2276
2279
  private defaultOptions?;
2277
2280
  private _options;
2278
- constructor(defaultOptions?: (() => Partial<TOptions>) | undefined);
2281
+ constructor(defaultOptions?: () => Partial<TOptions>);
2279
2282
  private setDefaults;
2280
2283
  /**
2281
2284
  * Set an individual panel option. This will merge the value with the existing options.
@@ -2312,7 +2315,7 @@ declare class FieldConfigBuilder<TFieldConfig extends {}> implements StandardFie
2312
2315
  private defaultFieldConfig?;
2313
2316
  private _fieldConfig;
2314
2317
  private _overridesBuilder;
2315
- constructor(defaultFieldConfig?: (() => TFieldConfig) | undefined);
2318
+ constructor(defaultFieldConfig?: () => TFieldConfig);
2316
2319
  private setDefaults;
2317
2320
  /**
2318
2321
  * Set color.
package/dist/index.js CHANGED
@@ -1546,7 +1546,7 @@ function getQueryController(sceneObject) {
1546
1546
  }
1547
1547
  parent = parent.parent;
1548
1548
  }
1549
- return parent;
1549
+ return void 0;
1550
1550
  }
1551
1551
 
1552
1552
  class SkipFormattingValue {
@@ -6590,8 +6590,9 @@ function createQueryVariableRunnerFactory(datasource) {
6590
6590
  }
6591
6591
  let createQueryVariableRunner = createQueryVariableRunnerFactory;
6592
6592
  function ensureVariableQueryModelIsADataQuery(variable) {
6593
- const query = variable.state.query;
6594
- if (!query || typeof query !== "object") {
6593
+ var _a;
6594
+ const query = (_a = variable.state.query) != null ? _a : "";
6595
+ if (typeof query === "string") {
6595
6596
  return { query, refId: `variable-${variable.state.name}` };
6596
6597
  }
6597
6598
  if (query.refId == null) {
@@ -7681,6 +7682,7 @@ function SceneGridLayoutRenderer({ model }) {
7681
7682
  draggableHandle: `.grid-drag-handle-${model.state.key}`,
7682
7683
  draggableCancel: ".grid-drag-cancel",
7683
7684
  layout,
7685
+ onDragStart: model.onDragStart,
7684
7686
  onDragStop: model.onDragStop,
7685
7687
  onResizeStop: model.onResizeStop,
7686
7688
  onLayoutChange: model.onLayoutChange,
@@ -7830,11 +7832,17 @@ const _SceneGridLayout = class extends SceneObjectBase {
7830
7832
  children: sortChildrenByPosition(state.children)
7831
7833
  }));
7832
7834
  this._skipOnLayoutChange = false;
7835
+ this._oldLayout = [];
7836
+ this._loadOldLayout = false;
7833
7837
  this.onLayoutChange = (layout) => {
7834
7838
  if (this._skipOnLayoutChange) {
7835
7839
  this._skipOnLayoutChange = false;
7836
7840
  return;
7837
7841
  }
7842
+ if (this._loadOldLayout) {
7843
+ layout = [...this._oldLayout];
7844
+ this._loadOldLayout = false;
7845
+ }
7838
7846
  for (const item of layout) {
7839
7847
  const child = this.getSceneLayoutChild(item.i);
7840
7848
  const nextSize = {
@@ -7856,6 +7864,9 @@ const _SceneGridLayout = class extends SceneObjectBase {
7856
7864
  height: n.h
7857
7865
  });
7858
7866
  };
7867
+ this.onDragStart = (gridLayout) => {
7868
+ this._oldLayout = [...gridLayout];
7869
+ };
7859
7870
  this.onDragStop = (gridLayout, o, updatedItem) => {
7860
7871
  const sceneChild = this.getSceneLayoutChild(updatedItem.i);
7861
7872
  gridLayout = sortGridLayout(gridLayout);
@@ -7871,8 +7882,12 @@ const _SceneGridLayout = class extends SceneObjectBase {
7871
7882
  }
7872
7883
  }
7873
7884
  const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);
7874
- const newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);
7885
+ let newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);
7875
7886
  let newChildren = this.state.children;
7887
+ if (sceneChild instanceof SceneGridRow && newParent instanceof SceneGridRow) {
7888
+ this._loadOldLayout = true;
7889
+ newParent = this;
7890
+ }
7876
7891
  if (newParent !== sceneChild.parent) {
7877
7892
  newChildren = this.moveChildTo(sceneChild, newParent);
7878
7893
  }