@grafana/scenes 5.3.9--canary.824.9873640037.0 → 5.3.9--canary.827.9887483180.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. package/dist/esm/components/layout/LazyLoader.js +12 -8
  2. package/dist/esm/components/layout/LazyLoader.js.map +1 -1
  3. package/dist/esm/index.js +1 -1
  4. package/dist/esm/querying/SceneQueryRunner.js +1 -2
  5. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  6. package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js +1 -4
  7. package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js.map +1 -1
  8. package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js +1 -2
  9. package/dist/esm/querying/layers/annotations/standardAnnotationQuery.js.map +1 -1
  10. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +2 -7
  11. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  12. package/dist/esm/variables/groupby/GroupByVariable.js +5 -8
  13. package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
  14. package/dist/esm/variables/sets/SceneVariableSet.js +8 -1
  15. package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
  16. package/dist/esm/variables/types.js +4 -1
  17. package/dist/esm/variables/types.js.map +1 -1
  18. package/dist/esm/variables/variants/MultiValueVariable.js +4 -1
  19. package/dist/esm/variables/variants/MultiValueVariable.js.map +1 -1
  20. package/dist/esm/variables/variants/query/QueryVariable.js +2 -3
  21. package/dist/esm/variables/variants/query/QueryVariable.js.map +1 -1
  22. package/dist/index.d.ts +6 -1
  23. package/dist/index.js +45 -48
  24. package/dist/index.js.map +1 -1
  25. package/package.json +2 -2
  26. package/dist/esm/utils/proxifyScopedVarSceneObject.js +0 -14
  27. package/dist/esm/utils/proxifyScopedVarSceneObject.js.map +0 -1
package/dist/index.js CHANGED
@@ -891,6 +891,9 @@ function getTimeRange(sceneObject) {
891
891
  class SceneVariableValueChangedEvent extends data.BusEventWithPayload {
892
892
  }
893
893
  SceneVariableValueChangedEvent.type = "scene-variable-changed-value";
894
+ class SceneVariableOptionsRefreshEvent extends data.BusEventWithPayload {
895
+ }
896
+ SceneVariableOptionsRefreshEvent.type = "scene-variable-options-refresh";
894
897
  function isCustomVariableValue(value) {
895
898
  return typeof value === "object" && "formatter" in value;
896
899
  }
@@ -2699,6 +2702,9 @@ class MultiValueVariable extends SceneObjectBase {
2699
2702
  }
2700
2703
  return options;
2701
2704
  }
2705
+ refreshOptions() {
2706
+ this.publishEvent(new SceneVariableOptionsRefreshEvent(this), true);
2707
+ }
2702
2708
  }
2703
2709
  function findOptionMatchingCurrent(currentValue, currentText, options) {
2704
2710
  let textMatch;
@@ -3082,18 +3088,6 @@ function getEnrichedFiltersRequest(sourceRunner) {
3082
3088
  return null;
3083
3089
  }
3084
3090
 
3085
- const handler = {
3086
- get(target, prop) {
3087
- if (prop === "__proxiedObject") {
3088
- return target;
3089
- }
3090
- return "_r";
3091
- }
3092
- };
3093
- function proxifyScopedVarSceneObject(target) {
3094
- return new Proxy(target, handler);
3095
- }
3096
-
3097
3091
  var __defProp$z = Object.defineProperty;
3098
3092
  var __defProps$n = Object.defineProperties;
3099
3093
  var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
@@ -3138,7 +3132,9 @@ class GroupByVariable extends MultiValueVariable {
3138
3132
  return override.values;
3139
3133
  }
3140
3134
  if (this.state.defaultOptions) {
3141
- return this.state.defaultOptions.concat(dataFromResponse((_c = override == null ? void 0 : override.values) != null ? _c : []));
3135
+ return this.state.defaultOptions.concat(
3136
+ dataFromResponse((_c = override == null ? void 0 : override.values) != null ? _c : [])
3137
+ );
3142
3138
  }
3143
3139
  if (!ds.getTagKeys) {
3144
3140
  return [];
@@ -3146,11 +3142,7 @@ class GroupByVariable extends MultiValueVariable {
3146
3142
  const queries = getQueriesForVariables(this);
3147
3143
  const otherFilters = this.state.baseFilters || [];
3148
3144
  const timeRange = sceneGraph.getTimeRange(this).state.value;
3149
- const response = await ds.getTagKeys(__spreadValues$z({
3150
- filters: otherFilters,
3151
- queries,
3152
- timeRange
3153
- }, getEnrichedFiltersRequest(this)));
3145
+ const response = await ds.getTagKeys(__spreadValues$z({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
3154
3146
  if (responseHasError(response)) {
3155
3147
  this.setState({ error: response.error.message });
3156
3148
  }
@@ -3199,7 +3191,7 @@ class GroupByVariable extends MultiValueVariable {
3199
3191
  this.setState({ loading: true, error: null });
3200
3192
  return rxjs.from(
3201
3193
  getDataSource(this.state.datasource, {
3202
- __sceneObject: { text: "__sceneObject", value: proxifyScopedVarSceneObject(this) }
3194
+ __sceneObject: { text: "__sceneObject", value: this }
3203
3195
  })
3204
3196
  ).pipe(
3205
3197
  rxjs.mergeMap((ds) => {
@@ -3325,7 +3317,7 @@ function LoadingIndicator(props) {
3325
3317
  }
3326
3318
 
3327
3319
  function ControlsLabel(props) {
3328
- const styles = ui.useStyles2(getStyles$9);
3320
+ const styles = ui.useStyles2(getStyles$a);
3329
3321
  const theme = ui.useTheme2();
3330
3322
  const isVertical = props.layout === "vertical";
3331
3323
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3388,7 +3380,7 @@ function ControlsLabel(props) {
3388
3380
  }
3389
3381
  return labelElement;
3390
3382
  }
3391
- const getStyles$9 = (theme) => ({
3383
+ const getStyles$a = (theme) => ({
3392
3384
  horizontalLabel: css.css({
3393
3385
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3394
3386
  display: `flex`,
@@ -3487,7 +3479,7 @@ function keyLabelToOption(key, label) {
3487
3479
  const filterNoOp = () => true;
3488
3480
  function AdHocFilterRenderer({ filter, model }) {
3489
3481
  var _a, _b;
3490
- const styles = ui.useStyles2(getStyles$8);
3482
+ const styles = ui.useStyles2(getStyles$9);
3491
3483
  const [keys, setKeys] = React.useState([]);
3492
3484
  const [values, setValues] = React.useState([]);
3493
3485
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3631,7 +3623,7 @@ function AdHocFilterRenderer({ filter, model }) {
3631
3623
  onClick: () => model._removeFilter(filter)
3632
3624
  }));
3633
3625
  }
3634
- const getStyles$8 = (theme) => ({
3626
+ const getStyles$9 = (theme) => ({
3635
3627
  field: css.css({
3636
3628
  marginBottom: 0
3637
3629
  }),
@@ -3799,7 +3791,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
3799
3791
  applyMode: "auto",
3800
3792
  filterExpression: (_b = state.filterExpression) != null ? _b : renderExpression(state.expressionBuilder, state.filters)
3801
3793
  }, state));
3802
- this._scopedVars = { __sceneObject: { value: proxifyScopedVarSceneObject(this) } };
3794
+ this._scopedVars = { __sceneObject: { value: this } };
3803
3795
  this._dataSourceSrv = runtime.getDataSourceSrv();
3804
3796
  this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
3805
3797
  if (this.state.applyMode === "auto") {
@@ -3870,11 +3862,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
3870
3862
  const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat((_c = this.state.baseFilters) != null ? _c : []);
3871
3863
  const timeRange = sceneGraph.getTimeRange(this).state.value;
3872
3864
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
3873
- const response = await ds.getTagKeys(__spreadValues$y({
3874
- filters: otherFilters,
3875
- queries,
3876
- timeRange
3877
- }, getEnrichedFiltersRequest(this)));
3865
+ const response = await ds.getTagKeys(__spreadValues$y({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
3878
3866
  if (responseHasError(response)) {
3879
3867
  this.setState({ error: response.error.message });
3880
3868
  }
@@ -3934,7 +3922,7 @@ function renderExpression(builder, filters) {
3934
3922
  }
3935
3923
  function AdHocFiltersVariableRenderer({ model }) {
3936
3924
  const { filters, readOnly, addFilterButtonText } = model.useState();
3937
- const styles = ui.useStyles2(getStyles$7);
3925
+ const styles = ui.useStyles2(getStyles$8);
3938
3926
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3939
3927
  className: styles.wrapper
3940
3928
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3948,7 +3936,7 @@ function AdHocFiltersVariableRenderer({ model }) {
3948
3936
  addFilterButtonText
3949
3937
  }));
3950
3938
  }
3951
- const getStyles$7 = (theme) => ({
3939
+ const getStyles$8 = (theme) => ({
3952
3940
  wrapper: css.css({
3953
3941
  display: "flex",
3954
3942
  flexWrap: "wrap",
@@ -4047,7 +4035,7 @@ class SceneQueryRunner extends SceneObjectBase {
4047
4035
  this._dataLayersMerger = new DataLayersMerger();
4048
4036
  this._variableValueRecorder = new VariableValueRecorder();
4049
4037
  this._results = new rxjs.ReplaySubject(1);
4050
- this._scopedVars = { __sceneObject: { value: proxifyScopedVarSceneObject(this), text: "__sceneObject" } };
4038
+ this._scopedVars = { __sceneObject: { value: this, text: "__sceneObject" } };
4051
4039
  this._variableDependency = new VariableDependencyConfig(this, {
4052
4040
  statePaths: ["queries", "datasource"],
4053
4041
  onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
@@ -5950,7 +5938,7 @@ function executeAnnotationQuery(datasource, timeRange, query, layer) {
5950
5938
  __interval: { text: interval.interval, value: interval.interval },
5951
5939
  __interval_ms: { text: interval.intervalMs.toString(), value: interval.intervalMs },
5952
5940
  __annotation: { text: annotation.name, value: annotation },
5953
- __sceneObject: { text: "__sceneObject", value: proxifyScopedVarSceneObject(layer) }
5941
+ __sceneObject: { text: "__sceneObject", value: layer }
5954
5942
  };
5955
5943
  const queryRequest = __spreadValues$q(__spreadProps$f(__spreadValues$q({
5956
5944
  startTime: Date.now(),
@@ -6094,9 +6082,7 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
6094
6082
  }, initialState),
6095
6083
  ["query"]
6096
6084
  );
6097
- this._scopedVars = {
6098
- __sceneObject: { value: proxifyScopedVarSceneObject(this), text: "__sceneObject" }
6099
- };
6085
+ this._scopedVars = { __sceneObject: { value: this, text: "__sceneObject" } };
6100
6086
  }
6101
6087
  onEnable() {
6102
6088
  const timeRange = sceneGraph.getTimeRange(this);
@@ -6620,6 +6606,9 @@ class SceneVariableSet extends SceneObjectBase {
6620
6606
  this._subs.add(
6621
6607
  this.subscribeToEvent(SceneVariableValueChangedEvent, (event) => this._handleVariableValueChanged(event.payload))
6622
6608
  );
6609
+ this._subs.add(
6610
+ this.subscribeToEvent(SceneVariableOptionsRefreshEvent, (event) => this._handleVariableOptionsUpdate(event.payload))
6611
+ );
6623
6612
  this._subs.add(
6624
6613
  timeRange.subscribeToState(() => {
6625
6614
  this._refreshTimeRangeBasedVariables();
@@ -6761,6 +6750,10 @@ class SceneVariableSet extends SceneObjectBase {
6761
6750
  console.error("SceneVariableSet updateAndValidate error", err);
6762
6751
  writeVariableTraceLog(variable, "updateAndValidate error", err);
6763
6752
  }
6753
+ _handleVariableOptionsUpdate(variable) {
6754
+ this._variablesToUpdate.add(variable);
6755
+ this._updateNextBatch();
6756
+ }
6764
6757
  _handleVariableValueChanged(variableThatChanged) {
6765
6758
  this._variablesThatHaveChanged.add(variableThatChanged);
6766
6759
  this._addDependentVariablesToUpdateQueue(variableThatChanged);
@@ -7419,7 +7412,7 @@ class QueryVariable extends MultiValueVariable {
7419
7412
  this.setState({ loading: true, error: null });
7420
7413
  return rxjs.from(
7421
7414
  getDataSource(this.state.datasource, {
7422
- __sceneObject: { text: "__sceneObject", value: proxifyScopedVarSceneObject(this) }
7415
+ __sceneObject: { text: "__sceneObject", value: this }
7423
7416
  })
7424
7417
  ).pipe(
7425
7418
  rxjs.mergeMap((ds) => {
@@ -7460,7 +7453,7 @@ class QueryVariable extends MultiValueVariable {
7460
7453
  }
7461
7454
  getRequest(target, searchFilter) {
7462
7455
  const scopedVars = {
7463
- __sceneObject: { text: "__sceneObject", value: proxifyScopedVarSceneObject(this) }
7456
+ __sceneObject: { text: "__sceneObject", value: this }
7464
7457
  };
7465
7458
  if (searchFilter) {
7466
7459
  scopedVars.__searchFilter = { value: searchFilter, text: searchFilter };
@@ -8052,7 +8045,7 @@ class EmbeddedScene extends SceneObjectBase {
8052
8045
  EmbeddedScene.Component = EmbeddedSceneRenderer;
8053
8046
  function EmbeddedSceneRenderer({ model }) {
8054
8047
  const { body, controls } = model.useState();
8055
- const styles = ui.useStyles2(getStyles$6);
8048
+ const styles = ui.useStyles2(getStyles$7);
8056
8049
  return /* @__PURE__ */ React__default["default"].createElement("div", {
8057
8050
  className: styles.container
8058
8051
  }, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -8066,7 +8059,7 @@ function EmbeddedSceneRenderer({ model }) {
8066
8059
  model: body
8067
8060
  })));
8068
8061
  }
8069
- const getStyles$6 = (theme) => {
8062
+ const getStyles$7 = (theme) => {
8070
8063
  return {
8071
8064
  container: css.css({
8072
8065
  flexGrow: 1,
@@ -8207,7 +8200,7 @@ const LazyLoader = React__default["default"].forwardRef(
8207
8200
  (_a, ref) => {
8208
8201
  var _b = _a, { children, onLoad, onChange, className } = _b, rest = __objRest$1(_b, ["children", "onLoad", "onChange", "className"]);
8209
8202
  const id = useUniqueId();
8210
- const style = useStyle();
8203
+ const { hideEmpty } = ui.useStyles2(getStyles$6);
8211
8204
  const [loaded, setLoaded] = React.useState(false);
8212
8205
  const [isInView, setIsInView] = React.useState(false);
8213
8206
  const innerRef = React.useRef(null);
@@ -8233,19 +8226,22 @@ const LazyLoader = React__default["default"].forwardRef(
8233
8226
  }
8234
8227
  };
8235
8228
  });
8229
+ const classes = `${loaded ? hideEmpty : ""} ${className}`;
8236
8230
  return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$b({
8237
8231
  id,
8238
8232
  ref: innerRef,
8239
- className: `${loaded ? style : ""} ${className}`
8233
+ className: classes
8240
8234
  }, rest), loaded && (typeof children === "function" ? children({ isInView }) : children));
8241
8235
  }
8242
8236
  );
8243
- function useStyle() {
8244
- return css.css({
8245
- "&:empty": {
8246
- display: "none"
8247
- }
8248
- });
8237
+ function getStyles$6() {
8238
+ return {
8239
+ hideEmpty: css.css({
8240
+ "&:empty": {
8241
+ display: "none"
8242
+ }
8243
+ })
8244
+ };
8249
8245
  }
8250
8246
  LazyLoader.displayName = "LazyLoader";
8251
8247
  LazyLoader.callbacks = {};
@@ -11604,6 +11600,7 @@ exports.SceneTimeRangeTransformerBase = SceneTimeRangeTransformerBase;
11604
11600
  exports.SceneTimeZoneOverride = SceneTimeZoneOverride;
11605
11601
  exports.SceneToolbarButton = SceneToolbarButton;
11606
11602
  exports.SceneToolbarInput = SceneToolbarInput;
11603
+ exports.SceneVariableOptionsRefreshEvent = SceneVariableOptionsRefreshEvent;
11607
11604
  exports.SceneVariableSet = SceneVariableSet;
11608
11605
  exports.SceneVariableValueChangedEvent = SceneVariableValueChangedEvent;
11609
11606
  exports.SplitLayout = SplitLayout;