@grafana/scenes 6.4.0--canary.1062.13832864605.0 → 6.4.0--canary.1062.13918541857.0

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.js CHANGED
@@ -4720,6 +4720,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4720
4720
  return;
4721
4721
  }
4722
4722
  }
4723
+ if (filter == null ? void 0 : filter.origin) {
4724
+ return;
4725
+ }
4723
4726
  setInputType("operator");
4724
4727
  return;
4725
4728
  }
@@ -4915,9 +4918,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4915
4918
  operatorIdentifier
4916
4919
  ),
4917
4920
  "aria-label": "Edit filter operator",
4918
- tabIndex: 0,
4921
+ tabIndex: filter.origin ? -1 : 0,
4919
4922
  onClick: (event) => {
4920
4923
  if (filter.origin) {
4924
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
4921
4925
  return;
4922
4926
  }
4923
4927
  event.stopPropagation();
@@ -4925,6 +4929,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4925
4929
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4926
4930
  },
4927
4931
  onKeyDown: (event) => {
4932
+ if (filter.origin) {
4933
+ return;
4934
+ }
4928
4935
  handleShiftTabInput(event, hasMultiValueOperator);
4929
4936
  if (event.key === "Enter") {
4930
4937
  setInputValue("");
@@ -5580,7 +5587,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5580
5587
  ...scopeFilters.filter((filter) => !editedScopeFilterKeys.includes(filter.key))
5581
5588
  ];
5582
5589
  }
5583
- const newFilters = [...finalFilters, ...remainingFilters];
5590
+ const newFilters = [...remainingFilters, ...finalFilters];
5584
5591
  this.setState({ baseFilters: newFilters });
5585
5592
  };
5586
5593
  if (this.state.applyMode === "auto") {
@@ -5685,6 +5692,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5685
5692
  }
5686
5693
  }
5687
5694
  _handleComboboxBackspace(filter) {
5695
+ var _a;
5688
5696
  if (this.state.filters.length) {
5689
5697
  let filterToForceIndex = this.state.filters.length - 1;
5690
5698
  if (filter !== this.state._wip) {
@@ -5706,6 +5714,27 @@ class AdHocFiltersVariable extends SceneObjectBase {
5706
5714
  return [...acc, f];
5707
5715
  }, [])
5708
5716
  });
5717
+ } else if ((_a = this.state.baseFilters) == null ? void 0 : _a.length) {
5718
+ let filterToForceIndex = this.state.baseFilters.length - 1;
5719
+ if (filter !== this.state._wip) {
5720
+ filterToForceIndex = -1;
5721
+ }
5722
+ this.setState({
5723
+ baseFilters: this.state.baseFilters.reduce((acc, f, index) => {
5724
+ if (index === filterToForceIndex) {
5725
+ return [
5726
+ ...acc,
5727
+ __spreadProps$n(__spreadValues$z({}, f), {
5728
+ forceEdit: true
5729
+ })
5730
+ ];
5731
+ }
5732
+ if (f === filter) {
5733
+ return acc;
5734
+ }
5735
+ return [...acc, f];
5736
+ }, [])
5737
+ });
5709
5738
  }
5710
5739
  }
5711
5740
  async _getKeys(currentKey) {
@@ -5744,7 +5773,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5744
5773
  return keys.map(toSelectableValue);
5745
5774
  }
5746
5775
  async _getValuesFor(filter) {
5747
- var _a, _b, _c, _d, _e, _f;
5776
+ var _a, _b, _c, _d, _e;
5748
5777
  const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
5749
5778
  if (override && override.replace) {
5750
5779
  return dataFromResponse(override.values).map(toSelectableValue);
@@ -5758,16 +5787,11 @@ class AdHocFiltersVariable extends SceneObjectBase {
5758
5787
  const timeRange = sceneGraph.getTimeRange(this).state.value;
5759
5788
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
5760
5789
  let scopes = (_e = this._scopesBridge) == null ? void 0 : _e.getValue();
5761
- if ((_f = this.state.baseFilters) == null ? void 0 : _f.some((filter2) => filter2.origin === "scopes" /* Scopes */)) {
5790
+ if (filter.origin === "scopes" /* Scopes */) {
5762
5791
  scopes = scopes == null ? void 0 : scopes.map((scope) => {
5763
5792
  return __spreadProps$n(__spreadValues$z({}, scope), {
5764
5793
  spec: __spreadProps$n(__spreadValues$z({}, scope.spec), {
5765
- filters: scope.spec.filters.filter(
5766
- (f) => {
5767
- var _a2;
5768
- return !((_a2 = this.state.baseFilters) == null ? void 0 : _a2.find((bf) => bf.key === f.key && "scopes" /* Scopes */));
5769
- }
5770
- )
5794
+ filters: scope.spec.filters.filter((f) => f.key !== filter.key)
5771
5795
  })
5772
5796
  });
5773
5797
  });