@grafana/scenes 5.21.1--canary.947.11593224430.0 → 5.21.1--canary.942.11596595400.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -77,8 +77,8 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
77
77
  }
78
78
 
79
79
  var __defProp$N = Object.defineProperty;
80
- var __defProps$u = Object.defineProperties;
81
- var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
80
+ var __defProps$v = Object.defineProperties;
81
+ var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
82
82
  var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
83
83
  var __hasOwnProp$N = Object.prototype.hasOwnProperty;
84
84
  var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
@@ -94,13 +94,13 @@ var __spreadValues$N = (a, b) => {
94
94
  }
95
95
  return a;
96
96
  };
97
- var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
97
+ var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
98
98
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
99
99
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
100
100
  if (runtimePanelPlugins.has(pluginId)) {
101
101
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
102
102
  }
103
- plugin.meta = __spreadProps$u(__spreadValues$N({}, plugin.meta), {
103
+ plugin.meta = __spreadProps$v(__spreadValues$N({}, plugin.meta), {
104
104
  id: pluginId,
105
105
  name: pluginId,
106
106
  module: "runtime plugin",
@@ -129,8 +129,8 @@ function loadPanelPluginSync(pluginId) {
129
129
  }
130
130
 
131
131
  var __defProp$M = Object.defineProperty;
132
- var __defProps$t = Object.defineProperties;
133
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
132
+ var __defProps$u = Object.defineProperties;
133
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
134
134
  var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
135
135
  var __hasOwnProp$M = Object.prototype.hasOwnProperty;
136
136
  var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
@@ -146,7 +146,7 @@ var __spreadValues$M = (a, b) => {
146
146
  }
147
147
  return a;
148
148
  };
149
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
149
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
150
150
  var __objRest$5 = (source, exclude) => {
151
151
  var target = {};
152
152
  for (var prop in source)
@@ -172,7 +172,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
172
172
  if (!model.isActive) {
173
173
  return null;
174
174
  }
175
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$t(__spreadValues$M({}, otherProps), {
175
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$u(__spreadValues$M({}, otherProps), {
176
176
  model
177
177
  }));
178
178
  }
@@ -893,7 +893,10 @@ class SceneTimeRange extends SceneObjectBase {
893
893
  }
894
894
  getUrlState() {
895
895
  const params = runtime.locationService.getSearchObject();
896
- const urlValues = { from: this.state.from, to: this.state.to, timezone: this.getTimeZone() };
896
+ const urlValues = { from: this.state.from, to: this.state.to };
897
+ if (this.state.timeZone) {
898
+ urlValues.timezone = this.state.timeZone;
899
+ }
897
900
  if (params.time && params["time.window"]) {
898
901
  urlValues.time = null;
899
902
  urlValues["time.window"] = null;
@@ -1339,9 +1342,6 @@ class UrlTimeRangeMacro {
1339
1342
  var _a;
1340
1343
  const timeRange = getTimeRange(this._sceneObject);
1341
1344
  const urlState = (_a = timeRange.urlSync) == null ? void 0 : _a.getUrlState();
1342
- if ((urlState == null ? void 0 : urlState.timezone) === "browser") {
1343
- urlState.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1344
- }
1345
1345
  return new SkipFormattingValue(data.urlUtil.toUrlParams(urlState));
1346
1346
  }
1347
1347
  getValueText() {
@@ -1747,8 +1747,8 @@ function collectAllVariables(sceneObject, record = {}) {
1747
1747
  }
1748
1748
 
1749
1749
  var __defProp$H = Object.defineProperty;
1750
- var __defProps$s = Object.defineProperties;
1751
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
1750
+ var __defProps$t = Object.defineProperties;
1751
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
1752
1752
  var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
1753
1753
  var __hasOwnProp$H = Object.prototype.hasOwnProperty;
1754
1754
  var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
@@ -1764,7 +1764,7 @@ var __spreadValues$H = (a, b) => {
1764
1764
  }
1765
1765
  return a;
1766
1766
  };
1767
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
1767
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
1768
1768
  function getTemplateProxyForField(field, frame, frames) {
1769
1769
  return new Proxy(
1770
1770
  {},
@@ -1780,7 +1780,7 @@ function getTemplateProxyForField(field, frame, frames) {
1780
1780
  if (!field.labels) {
1781
1781
  return "";
1782
1782
  }
1783
- return __spreadProps$s(__spreadValues$H({}, field.labels), {
1783
+ return __spreadProps$t(__spreadValues$H({}, field.labels), {
1784
1784
  __values: Object.values(field.labels).sort().join(", "),
1785
1785
  toString: () => {
1786
1786
  return data.formatLabels(field.labels, "", true);
@@ -2278,8 +2278,8 @@ function isExtraQueryProvider(obj) {
2278
2278
  }
2279
2279
 
2280
2280
  var __defProp$G = Object.defineProperty;
2281
- var __defProps$r = Object.defineProperties;
2282
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2281
+ var __defProps$s = Object.defineProperties;
2282
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
2283
2283
  var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
2284
2284
  var __hasOwnProp$G = Object.prototype.hasOwnProperty;
2285
2285
  var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
@@ -2295,7 +2295,7 @@ var __spreadValues$G = (a, b) => {
2295
2295
  }
2296
2296
  return a;
2297
2297
  };
2298
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2298
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2299
2299
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
2300
2300
  const extraQueryProcessingOperator = (processors) => (data) => {
2301
2301
  return data.pipe(
@@ -2308,7 +2308,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2308
2308
  }),
2309
2309
  rxjs.map(([primary, ...processedSecondaries]) => {
2310
2310
  var _a;
2311
- return __spreadProps$r(__spreadValues$G({}, primary), {
2311
+ return __spreadProps$s(__spreadValues$G({}, primary), {
2312
2312
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
2313
2313
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
2314
2314
  var _a2;
@@ -2320,8 +2320,8 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2320
2320
  };
2321
2321
 
2322
2322
  var __defProp$F = Object.defineProperty;
2323
- var __defProps$q = Object.defineProperties;
2324
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2323
+ var __defProps$r = Object.defineProperties;
2324
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2325
2325
  var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
2326
2326
  var __hasOwnProp$F = Object.prototype.hasOwnProperty;
2327
2327
  var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
@@ -2337,7 +2337,7 @@ var __spreadValues$F = (a, b) => {
2337
2337
  }
2338
2338
  return a;
2339
2339
  };
2340
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2340
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2341
2341
  function filterAnnotations(data, filters) {
2342
2342
  var _a;
2343
2343
  if (!Array.isArray(data) || data.length === 0) {
@@ -2388,11 +2388,11 @@ function filterAnnotations(data, filters) {
2388
2388
  continue;
2389
2389
  }
2390
2390
  }
2391
- fields.push(__spreadProps$q(__spreadValues$F({}, field), {
2391
+ fields.push(__spreadProps$r(__spreadValues$F({}, field), {
2392
2392
  values: buffer
2393
2393
  }));
2394
2394
  }
2395
- processed.push(__spreadProps$q(__spreadValues$F({}, frame), {
2395
+ processed.push(__spreadProps$r(__spreadValues$F({}, frame), {
2396
2396
  fields,
2397
2397
  length: frameLength
2398
2398
  }));
@@ -2543,8 +2543,8 @@ function getOptionSearcher(options, includeAll) {
2543
2543
  }
2544
2544
 
2545
2545
  var __defProp$E = Object.defineProperty;
2546
- var __defProps$p = Object.defineProperties;
2547
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2546
+ var __defProps$q = Object.defineProperties;
2547
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2548
2548
  var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2549
2549
  var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2550
2550
  var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
@@ -2560,7 +2560,7 @@ var __spreadValues$E = (a, b) => {
2560
2560
  }
2561
2561
  return a;
2562
2562
  };
2563
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2563
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2564
2564
  var __objRest$4 = (source, exclude) => {
2565
2565
  var target = {};
2566
2566
  for (var prop in source)
@@ -2716,7 +2716,7 @@ const OptionWithCheckbox = ({
2716
2716
  const theme = ui.useTheme2();
2717
2717
  const selectStyles = ui.getSelectStyles(theme);
2718
2718
  const optionStyles = ui.useStyles2(getOptionStyles);
2719
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$p(__spreadValues$E({
2719
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$q(__spreadValues$E({
2720
2720
  ref: innerRef,
2721
2721
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2722
2722
  }, rest), {
@@ -2882,8 +2882,8 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
2882
2882
  }
2883
2883
 
2884
2884
  var __defProp$D = Object.defineProperty;
2885
- var __defProps$o = Object.defineProperties;
2886
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2885
+ var __defProps$p = Object.defineProperties;
2886
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2887
2887
  var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
2888
2888
  var __hasOwnProp$D = Object.prototype.hasOwnProperty;
2889
2889
  var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
@@ -2899,10 +2899,10 @@ var __spreadValues$D = (a, b) => {
2899
2899
  }
2900
2900
  return a;
2901
2901
  };
2902
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
2902
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2903
2903
  class GroupByVariable extends MultiValueVariable {
2904
2904
  constructor(initialState) {
2905
- super(__spreadProps$o(__spreadValues$D({
2905
+ super(__spreadProps$p(__spreadValues$D({
2906
2906
  isMulti: true,
2907
2907
  name: "",
2908
2908
  value: [],
@@ -3872,15 +3872,16 @@ const nextInputTypeMap = {
3872
3872
  operator: "value",
3873
3873
  value: "key"
3874
3874
  };
3875
- const switchToNextInputType = (filterInputType, setInputType, handleChangeViewMode, element) => switchInputType(
3875
+ const switchToNextInputType = (filterInputType, setInputType, handleChangeViewMode, element, shouldFocusOnPillWrapperOverride) => switchInputType(
3876
3876
  nextInputTypeMap[filterInputType],
3877
3877
  setInputType,
3878
3878
  filterInputType === "value" ? handleChangeViewMode : void 0,
3879
- element
3879
+ element,
3880
+ shouldFocusOnPillWrapperOverride
3880
3881
  );
3881
- const switchInputType = (filterInputType, setInputType, handleChangeViewMode, element) => {
3882
+ const switchInputType = (filterInputType, setInputType, handleChangeViewMode, element, shouldFocusOnPillWrapperOverride) => {
3882
3883
  setInputType(filterInputType);
3883
- handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3884
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode(void 0, shouldFocusOnPillWrapperOverride);
3884
3885
  setTimeout(() => element == null ? void 0 : element.focus());
3885
3886
  };
3886
3887
  const generateFilterUpdatePayload = ({
@@ -4013,8 +4014,8 @@ const useFloatingInteractions = ({
4013
4014
  };
4014
4015
 
4015
4016
  var __defProp$A = Object.defineProperty;
4016
- var __defProps$n = Object.defineProperties;
4017
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
4017
+ var __defProps$o = Object.defineProperties;
4018
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
4018
4019
  var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
4019
4020
  var __hasOwnProp$A = Object.prototype.hasOwnProperty;
4020
4021
  var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
@@ -4030,8 +4031,8 @@ var __spreadValues$A = (a, b) => {
4030
4031
  }
4031
4032
  return a;
4032
4033
  };
4033
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
4034
- const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
4034
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
4035
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef }, parentRef) {
4035
4036
  var _a, _b, _c;
4036
4037
  const [open, setOpen] = React.useState(false);
4037
4038
  const [options, setOptions] = React.useState([]);
@@ -4050,6 +4051,15 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4050
4051
  const listRef = React.useRef([]);
4051
4052
  const disabledIndicesRef = React.useRef([]);
4052
4053
  const optionsSearcher = React.useMemo(() => fuzzySearchOptions(options), [options]);
4054
+ const isLastFilter = React.useMemo(() => {
4055
+ if (isAlwaysWip) {
4056
+ return false;
4057
+ }
4058
+ if (model.state.filters.at(-1) === filter) {
4059
+ return true;
4060
+ }
4061
+ return false;
4062
+ }, [filter, isAlwaysWip, model.state.filters]);
4053
4063
  const handleResetWip = React.useCallback(() => {
4054
4064
  if (isAlwaysWip) {
4055
4065
  model._addWip();
@@ -4166,6 +4176,8 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4166
4176
  setOptions(options2);
4167
4177
  if ((_a2 = options2[0]) == null ? void 0 : _a2.group) {
4168
4178
  setActiveIndex(1);
4179
+ } else {
4180
+ setActiveIndex(0);
4169
4181
  }
4170
4182
  } catch (e) {
4171
4183
  setOptionsError(true);
@@ -4183,19 +4195,37 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4183
4195
  const handleBackspaceInput = React.useCallback(
4184
4196
  (event, multiValueEdit) => {
4185
4197
  if (event.key === "Backspace" && !inputValue) {
4186
- if (multiValueEdit) {
4187
- setFilterMultiValues((items) => {
4188
- const updated = [...items];
4189
- updated.splice(-1, 1);
4190
- return updated;
4191
- });
4192
- } else if (filterInputType === "key") {
4193
- model._removeLastFilter();
4194
- handleFetchOptions(filterInputType);
4198
+ if (filterInputType === "value") {
4199
+ if (multiValueEdit) {
4200
+ if (filterMultiValues.length) {
4201
+ setFilterMultiValues((items) => {
4202
+ const updated = [...items];
4203
+ updated.splice(-1, 1);
4204
+ return updated;
4205
+ });
4206
+ return;
4207
+ }
4208
+ }
4209
+ setInputType("operator");
4210
+ return;
4211
+ }
4212
+ focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
4213
+ model._handleComboboxBackspace(filter);
4214
+ if (isAlwaysWip) {
4215
+ handleResetWip();
4195
4216
  }
4196
4217
  }
4197
4218
  },
4198
- [inputValue, filterInputType, model, handleFetchOptions]
4219
+ [
4220
+ inputValue,
4221
+ filterInputType,
4222
+ model,
4223
+ filter,
4224
+ isAlwaysWip,
4225
+ filterMultiValues.length,
4226
+ handleResetWip,
4227
+ focusOnWipInputRef
4228
+ ]
4199
4229
  );
4200
4230
  const handleTabInput = React.useCallback(
4201
4231
  (event, multiValueEdit) => {
@@ -4252,21 +4282,32 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4252
4282
  setFilterMultiValues
4253
4283
  })
4254
4284
  );
4255
- switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
4256
- setActiveIndex(0);
4285
+ switchToNextInputType(
4286
+ filterInputType,
4287
+ setInputType,
4288
+ handleChangeViewMode,
4289
+ refs.domReference.current,
4290
+ isLastFilter ? false : void 0
4291
+ );
4292
+ setActiveIndex(null);
4293
+ if (isLastFilter) {
4294
+ focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
4295
+ }
4257
4296
  }
4258
4297
  setInputValue("");
4259
4298
  }
4260
4299
  },
4261
4300
  [
4262
4301
  activeIndex,
4263
- filter,
4264
- filterInputType,
4265
4302
  filteredDropDownItems,
4266
4303
  handleLocalMultiValueChange,
4267
- handleChangeViewMode,
4268
4304
  model,
4269
- refs.domReference
4305
+ filter,
4306
+ filterInputType,
4307
+ handleChangeViewMode,
4308
+ refs.domReference,
4309
+ isLastFilter,
4310
+ focusOnWipInputRef
4270
4311
  ]
4271
4312
  );
4272
4313
  React.useEffect(() => {
@@ -4339,7 +4380,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4339
4380
  item,
4340
4381
  index: i,
4341
4382
  handleRemoveMultiValue
4342
- })) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
4383
+ })) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
4343
4384
  ref: refs.setReference,
4344
4385
  onChange,
4345
4386
  value: inputValue,
@@ -4376,14 +4417,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4376
4417
  visuallyHiddenDismiss: true,
4377
4418
  modal: false
4378
4419
  }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4379
- style: __spreadProps$n(__spreadValues$A({}, floatingStyles), {
4420
+ style: __spreadProps$o(__spreadValues$A({}, floatingStyles), {
4380
4421
  width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,
4381
4422
  transform: isMultiValueEdit ? `translate(${((_b = multiValuePillWrapperRef.current) == null ? void 0 : _b.getBoundingClientRect().left) || 0}px, ${(((_c = refs.domReference.current) == null ? void 0 : _c.getBoundingClientRect().bottom) || 0) + 10}px )` : floatingStyles.transform
4382
4423
  }),
4383
4424
  ref: refs.setFloating,
4384
4425
  className: styles.dropdownWrapper,
4385
4426
  tabIndex: -1
4386
- }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$n(__spreadValues$A({
4427
+ }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({
4387
4428
  style: {
4388
4429
  height: `${rowVirtualizer.getTotalSize() || VIRTUAL_LIST_ITEM_HEIGHT}px`
4389
4430
  }
@@ -4411,7 +4452,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4411
4452
  }
4412
4453
  const nextItem = filteredDropDownItems[virtualItem.index + 1];
4413
4454
  const shouldAddBottomBorder = nextItem && !nextItem.group && !nextItem.options && item.group;
4414
- return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$n(__spreadValues$A({}, getItemProps({
4455
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$o(__spreadValues$A({}, getItemProps({
4415
4456
  key: `${item.value}-${index}`,
4416
4457
  ref(node) {
4417
4458
  listRef.current[index] = node;
@@ -4441,7 +4482,8 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4441
4482
  filterInputType,
4442
4483
  setInputType,
4443
4484
  handleChangeViewMode,
4444
- refs.domReference.current
4485
+ refs.domReference.current,
4486
+ false
4445
4487
  );
4446
4488
  }
4447
4489
  }
@@ -4507,7 +4549,7 @@ const getStyles$b = (theme) => ({
4507
4549
  alignItems: "center",
4508
4550
  flexWrap: "wrap"
4509
4551
  }),
4510
- basePill: css.css(__spreadProps$n(__spreadValues$A({
4552
+ basePill: css.css(__spreadProps$o(__spreadValues$A({
4511
4553
  display: "flex",
4512
4554
  alignItems: "center",
4513
4555
  background: theme.colors.action.disabledBackground,
@@ -4574,7 +4616,7 @@ const getStyles$b = (theme) => ({
4574
4616
  color: theme.colors.text.primary
4575
4617
  }
4576
4618
  }),
4577
- descriptionText: css.css(__spreadProps$n(__spreadValues$A({}, theme.typography.bodySmall), {
4619
+ descriptionText: css.css(__spreadProps$o(__spreadValues$A({}, theme.typography.bodySmall), {
4578
4620
  color: theme.colors.text.secondary,
4579
4621
  paddingTop: theme.spacing(0.5)
4580
4622
  })),
@@ -4587,8 +4629,8 @@ const getStyles$b = (theme) => ({
4587
4629
  });
4588
4630
 
4589
4631
  var __defProp$z = Object.defineProperty;
4590
- var __defProps$m = Object.defineProperties;
4591
- var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
4632
+ var __defProps$n = Object.defineProperties;
4633
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
4592
4634
  var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
4593
4635
  var __hasOwnProp$z = Object.prototype.hasOwnProperty;
4594
4636
  var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
@@ -4604,33 +4646,39 @@ var __spreadValues$z = (a, b) => {
4604
4646
  }
4605
4647
  return a;
4606
4648
  };
4607
- var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
4608
- function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
4649
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
4650
+ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4609
4651
  var _a, _b, _c;
4610
4652
  const styles = ui.useStyles2(getStyles$a);
4611
4653
  const [viewMode, setViewMode] = React.useState(true);
4612
- const [shouldFocus, setShouldFocus] = React.useState(false);
4654
+ const [shouldFocusOnPillWrapper, setShouldFocusOnPillWrapper] = React.useState(false);
4613
4655
  const pillWrapperRef = React.useRef(null);
4614
4656
  const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
4615
4657
  const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b.join(", ")) || ((_c = filter.values) == null ? void 0 : _c.join(", ")) || filter.value;
4616
4658
  const handleChangeViewMode = React.useCallback(
4617
- (event) => {
4659
+ (event, shouldFocusOnPillWrapperOverride) => {
4618
4660
  event == null ? void 0 : event.stopPropagation();
4619
4661
  if (readOnly) {
4620
4662
  return;
4621
4663
  }
4622
- setShouldFocus(!viewMode);
4664
+ setShouldFocusOnPillWrapper(shouldFocusOnPillWrapperOverride != null ? shouldFocusOnPillWrapperOverride : !viewMode);
4623
4665
  setViewMode(!viewMode);
4624
4666
  },
4625
4667
  [readOnly, viewMode]
4626
4668
  );
4627
4669
  React.useEffect(() => {
4628
4670
  var _a2;
4629
- if (shouldFocus) {
4671
+ if (shouldFocusOnPillWrapper) {
4630
4672
  (_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
4631
- setShouldFocus(false);
4673
+ setShouldFocusOnPillWrapper(false);
4632
4674
  }
4633
- }, [shouldFocus]);
4675
+ }, [shouldFocusOnPillWrapper]);
4676
+ React.useEffect(() => {
4677
+ if (filter.forceEdit && viewMode) {
4678
+ setViewMode(false);
4679
+ model._updateFilter(filter, { forceEdit: void 0 });
4680
+ }
4681
+ }, [filter, model, viewMode]);
4634
4682
  if (viewMode) {
4635
4683
  const pillText = /* @__PURE__ */ React__default["default"].createElement("span", {
4636
4684
  className: styles.pillText
@@ -4656,14 +4704,14 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
4656
4704
  onClick: (e) => {
4657
4705
  e.stopPropagation();
4658
4706
  model._removeFilter(filter);
4659
- setTimeout(() => focusOnInputRef == null ? void 0 : focusOnInputRef());
4707
+ setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
4660
4708
  },
4661
4709
  onKeyDownCapture: (e) => {
4662
4710
  if (e.key === "Enter") {
4663
4711
  e.preventDefault();
4664
4712
  e.stopPropagation();
4665
4713
  model._removeFilter(filter);
4666
- setTimeout(() => focusOnInputRef == null ? void 0 : focusOnInputRef());
4714
+ setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
4667
4715
  }
4668
4716
  },
4669
4717
  name: "times",
@@ -4675,11 +4723,12 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
4675
4723
  return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4676
4724
  filter,
4677
4725
  model,
4678
- handleChangeViewMode
4726
+ handleChangeViewMode,
4727
+ focusOnWipInputRef
4679
4728
  });
4680
4729
  }
4681
4730
  const getStyles$a = (theme) => ({
4682
- combinedFilterPill: css.css(__spreadProps$m(__spreadValues$z({
4731
+ combinedFilterPill: css.css(__spreadProps$n(__spreadValues$z({
4683
4732
  display: "flex",
4684
4733
  alignItems: "center",
4685
4734
  background: theme.colors.action.selected,
@@ -4740,26 +4789,26 @@ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwa
4740
4789
  const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
4741
4790
  const { filters, readOnly } = model.useState();
4742
4791
  const styles = ui.useStyles2(getStyles$9);
4743
- const focusOnInputRef = React.useRef();
4792
+ const focusOnWipInputRef = React.useRef();
4744
4793
  return /* @__PURE__ */ React__default["default"].createElement("div", {
4745
4794
  className: css.cx(styles.comboboxWrapper, { [styles.comboboxFocusOutline]: !readOnly }),
4746
4795
  onClick: () => {
4747
4796
  var _a;
4748
- (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
4797
+ (_a = focusOnWipInputRef.current) == null ? void 0 : _a.call(focusOnWipInputRef);
4749
4798
  }
4750
4799
  }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4751
4800
  name: "filter",
4752
4801
  className: styles.filterIcon,
4753
4802
  size: "lg"
4754
4803
  }), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFilterPill, {
4755
- key: index,
4804
+ key: `${index}-${filter.key}`,
4756
4805
  filter,
4757
4806
  model,
4758
4807
  readOnly,
4759
- focusOnInputRef: focusOnInputRef.current
4808
+ focusOnWipInputRef: focusOnWipInputRef.current
4760
4809
  })), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersAlwaysWipCombobox, {
4761
4810
  model,
4762
- ref: focusOnInputRef
4811
+ ref: focusOnWipInputRef
4763
4812
  }) : null);
4764
4813
  });
4765
4814
  const getStyles$9 = (theme) => ({
@@ -4795,6 +4844,8 @@ const getStyles$9 = (theme) => ({
4795
4844
  });
4796
4845
 
4797
4846
  var __defProp$y = Object.defineProperty;
4847
+ var __defProps$m = Object.defineProperties;
4848
+ var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
4798
4849
  var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
4799
4850
  var __hasOwnProp$y = Object.prototype.hasOwnProperty;
4800
4851
  var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
@@ -4810,6 +4861,7 @@ var __spreadValues$y = (a, b) => {
4810
4861
  }
4811
4862
  return a;
4812
4863
  };
4864
+ var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
4813
4865
  const OPERATORS = [
4814
4866
  {
4815
4867
  value: "=",
@@ -4906,6 +4958,30 @@ class AdHocFiltersVariable extends SceneObjectBase {
4906
4958
  this._removeFilter(filterToRemove);
4907
4959
  }
4908
4960
  }
4961
+ _handleComboboxBackspace(filter) {
4962
+ if (this.state.filters.length) {
4963
+ let filterToForceIndex = this.state.filters.length - 1;
4964
+ if (filter !== this.state._wip) {
4965
+ filterToForceIndex = -1;
4966
+ }
4967
+ this.setState({
4968
+ filters: this.state.filters.reduce((acc, f, index) => {
4969
+ if (index === filterToForceIndex) {
4970
+ return [
4971
+ ...acc,
4972
+ __spreadProps$m(__spreadValues$y({}, f), {
4973
+ forceEdit: true
4974
+ })
4975
+ ];
4976
+ }
4977
+ if (f === filter) {
4978
+ return acc;
4979
+ }
4980
+ return [...acc, f];
4981
+ }, [])
4982
+ });
4983
+ }
4984
+ }
4909
4985
  async _getKeys(currentKey) {
4910
4986
  var _a, _b, _c;
4911
4987
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));