@grafana/scenes 6.35.1--canary.1148.17638446145.0 → 6.35.1

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
@@ -601,10 +601,6 @@ interface SceneDataProvider<T extends SceneObjectState = SceneDataState> extends
601
601
  isDataReadyToDisplay?: () => boolean;
602
602
  cancelQuery?: () => void;
603
603
  getResultsStream(): Observable<SceneDataProviderResult>;
604
- /**
605
- * Can be used to disable query execution for scene elements that are out of view
606
- */
607
- isInViewChanged?(isInView: boolean): void;
608
604
  }
609
605
  interface SceneDataLayerProviderState extends SceneDataState {
610
606
  name: string;
@@ -1833,9 +1829,6 @@ declare class SceneQueryRunner extends SceneObjectBase<QueryRunnerState> impleme
1833
1829
  */
1834
1830
  private getClosestExtraQueryProviders;
1835
1831
  private isQueryModeAuto;
1836
- private _isInView;
1837
- private _queryNotExecutedWhenOutOfView;
1838
- isInViewChanged(isInView: boolean): void;
1839
1832
  }
1840
1833
 
1841
1834
  interface DataProviderSharerState extends SceneDataState {
package/dist/index.js CHANGED
@@ -6491,8 +6491,6 @@ class SceneQueryRunner extends SceneObjectBase {
6491
6491
  this.setState({ data: dataWithLayersApplied, _hasFetchedData: hasFetchedData });
6492
6492
  this._results.next({ origin: this, data: dataWithLayersApplied });
6493
6493
  };
6494
- this._isInView = true;
6495
- this._queryNotExecutedWhenOutOfView = false;
6496
6494
  this.addActivationHandler(() => this._onActivate());
6497
6495
  }
6498
6496
  getResultsStream() {
@@ -6714,11 +6712,6 @@ class SceneQueryRunner extends SceneObjectBase {
6714
6712
  if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
6715
6713
  return;
6716
6714
  }
6717
- if (this.isQueryModeAuto() && !this._isInView) {
6718
- this._queryNotExecutedWhenOutOfView = true;
6719
- return;
6720
- }
6721
- this._queryNotExecutedWhenOutOfView = false;
6722
6715
  if (!this._dataLayersSub) {
6723
6716
  this._handleDataLayers();
6724
6717
  }
@@ -6882,13 +6875,6 @@ class SceneQueryRunner extends SceneObjectBase {
6882
6875
  var _a;
6883
6876
  return ((_a = this.state.runQueriesMode) != null ? _a : "auto") === "auto";
6884
6877
  }
6885
- isInViewChanged(isInView) {
6886
- writeSceneLog("SceneQueryRunner", `isInViewChanged: ${isInView}`, this.state.key);
6887
- this._isInView = isInView;
6888
- if (isInView && this._queryNotExecutedWhenOutOfView) {
6889
- this.runQueries();
6890
- }
6891
- }
6892
6878
  }
6893
6879
  function findFirstDatasource(targets) {
6894
6880
  var _a, _b;
@@ -8329,71 +8315,6 @@ const getStyles$8 = (theme) => ({
8329
8315
  })
8330
8316
  });
8331
8317
 
8332
- function useUniqueId() {
8333
- var _a;
8334
- const idRefLazy = React.useRef(void 0);
8335
- (_a = idRefLazy.current) != null ? _a : idRefLazy.current = lodash.uniqueId();
8336
- return idRefLazy.current;
8337
- }
8338
- const LazyLoader = React__default.default.forwardRef(
8339
- ({ children, onLoad, onChange, className, ...rest }, ref) => {
8340
- const id = useUniqueId();
8341
- const { hideEmpty } = ui.useStyles2(getStyles$7);
8342
- const [loaded, setLoaded] = React.useState(false);
8343
- const [isInView, setIsInView] = React.useState(false);
8344
- const innerRef = React.useRef(null);
8345
- React.useImperativeHandle(ref, () => innerRef.current);
8346
- reactUse.useEffectOnce(() => {
8347
- LazyLoader.addCallback(id, (entry) => {
8348
- if (!loaded && entry.isIntersecting) {
8349
- setLoaded(true);
8350
- onLoad == null ? void 0 : onLoad();
8351
- }
8352
- setIsInView(entry.isIntersecting);
8353
- onChange == null ? void 0 : onChange(entry.isIntersecting);
8354
- });
8355
- const wrapperEl = innerRef.current;
8356
- if (wrapperEl) {
8357
- LazyLoader.observer.observe(wrapperEl);
8358
- }
8359
- return () => {
8360
- wrapperEl && LazyLoader.observer.unobserve(wrapperEl);
8361
- delete LazyLoader.callbacks[id];
8362
- if (Object.keys(LazyLoader.callbacks).length === 0) {
8363
- LazyLoader.observer.disconnect();
8364
- }
8365
- };
8366
- });
8367
- return /* @__PURE__ */ React__default.default.createElement("div", { id, ref: innerRef, className: `${hideEmpty} ${className}`, ...rest }, !loaded || !isInView ? i18n.t("grafana-scenes.components.lazy-loader.placeholder", "\xA0") : /* @__PURE__ */ React__default.default.createElement(LazyLoaderInViewContext.Provider, { value: isInView }, children));
8368
- }
8369
- );
8370
- function getStyles$7() {
8371
- return {
8372
- hideEmpty: css.css({
8373
- "&:empty": {
8374
- display: "none"
8375
- }
8376
- })
8377
- };
8378
- }
8379
- LazyLoader.displayName = "LazyLoader";
8380
- LazyLoader.callbacks = {};
8381
- LazyLoader.addCallback = (id, c) => LazyLoader.callbacks[id] = c;
8382
- LazyLoader.observer = new IntersectionObserver(
8383
- (entries) => {
8384
- for (const entry of entries) {
8385
- if (typeof LazyLoader.callbacks[entry.target.id] === "function") {
8386
- LazyLoader.callbacks[entry.target.id](entry);
8387
- }
8388
- }
8389
- },
8390
- { rootMargin: "100px" }
8391
- );
8392
- const LazyLoaderInViewContext = React__default.default.createContext(true);
8393
- function useLazyLoaderIsInView() {
8394
- return React__default.default.useContext(LazyLoaderInViewContext);
8395
- }
8396
-
8397
8318
  function VizPanelRenderer({ model }) {
8398
8319
  var _a;
8399
8320
  const {
@@ -8436,12 +8357,6 @@ function VizPanelRenderer({ model }) {
8436
8357
  const sceneTimeRange = sceneGraph.getTimeRange(model);
8437
8358
  const timeZone = sceneTimeRange.getTimeZone();
8438
8359
  const timeRange = model.getTimeRange(dataWithFieldConfig);
8439
- const isInView = useLazyLoaderIsInView();
8440
- React.useEffect(() => {
8441
- if (dataObject.isInViewChanged) {
8442
- dataObject.isInViewChanged(isInView);
8443
- }
8444
- }, [isInView, dataObject]);
8445
8360
  const titleInterpolated = model.interpolate(title, void 0, "text");
8446
8361
  const alertStateStyles = ui.useStyles2(getAlertStateStyles);
8447
8362
  if (!plugin) {
@@ -9057,15 +8972,21 @@ class SceneDataTransformer extends SceneObjectBase {
9057
8972
  if (data$1.annotations && data$1.annotations.length > 0 && annotationsTransformations.length > 0) {
9058
8973
  streams.push(data.transformDataFrame(annotationsTransformations, (_a = data$1.annotations) != null ? _a : []));
9059
8974
  }
8975
+ let series = [];
8976
+ let annotations = [];
9060
8977
  this._transformSub = rxjs.forkJoin(streams).pipe(
9061
- rxjs.map((values) => {
9062
- const transformedSeries = values[0];
9063
- const transformedAnnotations = values[1];
9064
- return {
9065
- ...data$1,
9066
- series: transformedSeries,
9067
- annotations: transformedAnnotations != null ? transformedAnnotations : data$1.annotations
9068
- };
8978
+ rxjs.map((results) => {
8979
+ results.forEach((frames) => {
8980
+ var _a2;
8981
+ for (const frame of frames) {
8982
+ if (((_a2 = frame.meta) == null ? void 0 : _a2.dataTopic) === data.DataTopic.Annotations) {
8983
+ annotations.push(frame);
8984
+ } else {
8985
+ series.push(frame);
8986
+ }
8987
+ }
8988
+ });
8989
+ return { ...data$1, series, annotations };
9069
8990
  }),
9070
8991
  rxjs.catchError((err) => {
9071
8992
  var _a2;
@@ -11303,10 +11224,10 @@ class EmbeddedScene extends SceneObjectBase {
11303
11224
  EmbeddedScene.Component = EmbeddedSceneRenderer;
11304
11225
  function EmbeddedSceneRenderer({ model }) {
11305
11226
  const { body, controls } = model.useState();
11306
- const styles = ui.useStyles2(getStyles$6);
11227
+ const styles = ui.useStyles2(getStyles$7);
11307
11228
  return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, controls && /* @__PURE__ */ React__default.default.createElement("div", { className: styles.controls }, controls.map((control) => /* @__PURE__ */ React__default.default.createElement(control.Component, { key: control.state.key, model: control }))), /* @__PURE__ */ React__default.default.createElement("div", { className: styles.body }, /* @__PURE__ */ React__default.default.createElement(body.Component, { model: body })));
11308
11229
  }
11309
- const getStyles$6 = (theme) => {
11230
+ const getStyles$7 = (theme) => {
11310
11231
  return {
11311
11232
  container: css.css({
11312
11233
  flexGrow: 1,
@@ -11492,6 +11413,67 @@ function isSceneGridLayout(child) {
11492
11413
  return child instanceof SceneGridLayout;
11493
11414
  }
11494
11415
 
11416
+ function useUniqueId() {
11417
+ var _a;
11418
+ const idRefLazy = React.useRef(void 0);
11419
+ (_a = idRefLazy.current) != null ? _a : idRefLazy.current = lodash.uniqueId();
11420
+ return idRefLazy.current;
11421
+ }
11422
+ const LazyLoader = React__default.default.forwardRef(
11423
+ ({ children, onLoad, onChange, className, ...rest }, ref) => {
11424
+ const id = useUniqueId();
11425
+ const { hideEmpty } = ui.useStyles2(getStyles$6);
11426
+ const [loaded, setLoaded] = React.useState(false);
11427
+ const [isInView, setIsInView] = React.useState(false);
11428
+ const innerRef = React.useRef(null);
11429
+ React.useImperativeHandle(ref, () => innerRef.current);
11430
+ reactUse.useEffectOnce(() => {
11431
+ LazyLoader.addCallback(id, (entry) => {
11432
+ if (!loaded && entry.isIntersecting) {
11433
+ setLoaded(true);
11434
+ onLoad == null ? void 0 : onLoad();
11435
+ }
11436
+ setIsInView(entry.isIntersecting);
11437
+ onChange == null ? void 0 : onChange(entry.isIntersecting);
11438
+ });
11439
+ const wrapperEl = innerRef.current;
11440
+ if (wrapperEl) {
11441
+ LazyLoader.observer.observe(wrapperEl);
11442
+ }
11443
+ return () => {
11444
+ wrapperEl && LazyLoader.observer.unobserve(wrapperEl);
11445
+ delete LazyLoader.callbacks[id];
11446
+ if (Object.keys(LazyLoader.callbacks).length === 0) {
11447
+ LazyLoader.observer.disconnect();
11448
+ }
11449
+ };
11450
+ });
11451
+ return /* @__PURE__ */ React__default.default.createElement("div", { id, ref: innerRef, className: `${hideEmpty} ${className}`, ...rest }, !loaded || !isInView ? i18n.t("grafana-scenes.components.lazy-loader.placeholder", "\xA0") : children);
11452
+ }
11453
+ );
11454
+ function getStyles$6() {
11455
+ return {
11456
+ hideEmpty: css.css({
11457
+ "&:empty": {
11458
+ display: "none"
11459
+ }
11460
+ })
11461
+ };
11462
+ }
11463
+ LazyLoader.displayName = "LazyLoader";
11464
+ LazyLoader.callbacks = {};
11465
+ LazyLoader.addCallback = (id, c) => LazyLoader.callbacks[id] = c;
11466
+ LazyLoader.observer = new IntersectionObserver(
11467
+ (entries) => {
11468
+ for (const entry of entries) {
11469
+ if (typeof LazyLoader.callbacks[entry.target.id] === "function") {
11470
+ LazyLoader.callbacks[entry.target.id](entry);
11471
+ }
11472
+ }
11473
+ },
11474
+ { rootMargin: "100px" }
11475
+ );
11476
+
11495
11477
  function SceneGridLayoutRenderer({ model }) {
11496
11478
  const { children, isLazy, isDraggable, isResizable } = model.useState();
11497
11479
  const [outerDivRef, { width, height }] = reactUse.useMeasure();