@grafana/scenes 5.5.1 → 5.5.2--canary.830.10005065313.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -14,6 +14,8 @@ var ui = require('@grafana/ui');
14
14
  var e2eSelectors = require('@grafana/e2e-selectors');
15
15
  var css = require('@emotion/css');
16
16
  var uFuzzy = require('@leeoniya/ufuzzy');
17
+ var react = require('@floating-ui/react');
18
+ var reactDom = require('react-dom');
17
19
  var reactUse = require('react-use');
18
20
  var operators = require('rxjs/operators');
19
21
  var ReactGridLayout = require('react-grid-layout');
@@ -41,19 +43,19 @@ var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
41
43
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
42
44
  var AutoSizer__default = /*#__PURE__*/_interopDefaultLegacy(AutoSizer);
43
45
 
44
- var __defProp$K = Object.defineProperty;
45
- var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
46
- var __hasOwnProp$K = Object.prototype.hasOwnProperty;
47
- var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
48
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
- var __spreadValues$K = (a, b) => {
46
+ var __defProp$M = Object.defineProperty;
47
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
48
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
49
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
50
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
51
+ var __spreadValues$M = (a, b) => {
50
52
  for (var prop in b || (b = {}))
51
- if (__hasOwnProp$K.call(b, prop))
52
- __defNormalProp$K(a, prop, b[prop]);
53
- if (__getOwnPropSymbols$K)
54
- for (var prop of __getOwnPropSymbols$K(b)) {
55
- if (__propIsEnum$K.call(b, prop))
56
- __defNormalProp$K(a, prop, b[prop]);
53
+ if (__hasOwnProp$M.call(b, prop))
54
+ __defNormalProp$M(a, prop, b[prop]);
55
+ if (__getOwnPropSymbols$M)
56
+ for (var prop of __getOwnPropSymbols$M(b)) {
57
+ if (__propIsEnum$M.call(b, prop))
58
+ __defNormalProp$M(a, prop, b[prop]);
57
59
  }
58
60
  return a;
59
61
  };
@@ -62,7 +64,7 @@ function useAppQueryParams() {
62
64
  return runtime.locationSearchToObject(location.search || "");
63
65
  }
64
66
  function getUrlWithAppState(path, preserveParams) {
65
- const paramsCopy = __spreadValues$K({}, runtime.locationService.getSearchObject());
67
+ const paramsCopy = __spreadValues$M({}, runtime.locationService.getSearchObject());
66
68
  if (preserveParams) {
67
69
  for (const key of Object.keys(paramsCopy)) {
68
70
  if (!preserveParams.includes(key)) {
@@ -76,31 +78,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
76
78
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
77
79
  }
78
80
 
79
- var __defProp$J = Object.defineProperty;
80
- var __defProps$t = Object.defineProperties;
81
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
82
- var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
83
- var __hasOwnProp$J = Object.prototype.hasOwnProperty;
84
- var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
85
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
- var __spreadValues$J = (a, b) => {
81
+ var __defProp$L = Object.defineProperty;
82
+ var __defProps$v = Object.defineProperties;
83
+ var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
84
+ var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
85
+ var __hasOwnProp$L = Object.prototype.hasOwnProperty;
86
+ var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
87
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
88
+ var __spreadValues$L = (a, b) => {
87
89
  for (var prop in b || (b = {}))
88
- if (__hasOwnProp$J.call(b, prop))
89
- __defNormalProp$J(a, prop, b[prop]);
90
- if (__getOwnPropSymbols$J)
91
- for (var prop of __getOwnPropSymbols$J(b)) {
92
- if (__propIsEnum$J.call(b, prop))
93
- __defNormalProp$J(a, prop, b[prop]);
90
+ if (__hasOwnProp$L.call(b, prop))
91
+ __defNormalProp$L(a, prop, b[prop]);
92
+ if (__getOwnPropSymbols$L)
93
+ for (var prop of __getOwnPropSymbols$L(b)) {
94
+ if (__propIsEnum$L.call(b, prop))
95
+ __defNormalProp$L(a, prop, b[prop]);
94
96
  }
95
97
  return a;
96
98
  };
97
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
99
+ var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
98
100
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
99
101
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
100
102
  if (runtimePanelPlugins.has(pluginId)) {
101
103
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
102
104
  }
103
- plugin.meta = __spreadProps$t(__spreadValues$J({}, plugin.meta), {
105
+ plugin.meta = __spreadProps$v(__spreadValues$L({}, plugin.meta), {
104
106
  id: pluginId,
105
107
  name: pluginId,
106
108
  module: "runtime plugin",
@@ -128,39 +130,39 @@ function loadPanelPluginSync(pluginId) {
128
130
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
129
131
  }
130
132
 
131
- var __defProp$I = Object.defineProperty;
132
- var __defProps$s = Object.defineProperties;
133
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
134
- var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
135
- var __hasOwnProp$I = Object.prototype.hasOwnProperty;
136
- var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
137
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
- var __spreadValues$I = (a, b) => {
133
+ var __defProp$K = Object.defineProperty;
134
+ var __defProps$u = Object.defineProperties;
135
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
136
+ var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
137
+ var __hasOwnProp$K = Object.prototype.hasOwnProperty;
138
+ var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
139
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
140
+ var __spreadValues$K = (a, b) => {
139
141
  for (var prop in b || (b = {}))
140
- if (__hasOwnProp$I.call(b, prop))
141
- __defNormalProp$I(a, prop, b[prop]);
142
- if (__getOwnPropSymbols$I)
143
- for (var prop of __getOwnPropSymbols$I(b)) {
144
- if (__propIsEnum$I.call(b, prop))
145
- __defNormalProp$I(a, prop, b[prop]);
142
+ if (__hasOwnProp$K.call(b, prop))
143
+ __defNormalProp$K(a, prop, b[prop]);
144
+ if (__getOwnPropSymbols$K)
145
+ for (var prop of __getOwnPropSymbols$K(b)) {
146
+ if (__propIsEnum$K.call(b, prop))
147
+ __defNormalProp$K(a, prop, b[prop]);
146
148
  }
147
149
  return a;
148
150
  };
149
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
150
- var __objRest$4 = (source, exclude) => {
151
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
152
+ var __objRest$5 = (source, exclude) => {
151
153
  var target = {};
152
154
  for (var prop in source)
153
- if (__hasOwnProp$I.call(source, prop) && exclude.indexOf(prop) < 0)
155
+ if (__hasOwnProp$K.call(source, prop) && exclude.indexOf(prop) < 0)
154
156
  target[prop] = source[prop];
155
- if (source != null && __getOwnPropSymbols$I)
156
- for (var prop of __getOwnPropSymbols$I(source)) {
157
- if (exclude.indexOf(prop) < 0 && __propIsEnum$I.call(source, prop))
157
+ if (source != null && __getOwnPropSymbols$K)
158
+ for (var prop of __getOwnPropSymbols$K(source)) {
159
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$K.call(source, prop))
158
160
  target[prop] = source[prop];
159
161
  }
160
162
  return target;
161
163
  };
162
164
  function SceneComponentWrapperWithoutMemo(_a) {
163
- var _b = _a, { model } = _b, otherProps = __objRest$4(_b, ["model"]);
165
+ var _b = _a, { model } = _b, otherProps = __objRest$5(_b, ["model"]);
164
166
  var _a2;
165
167
  const Component = (_a2 = model.constructor["Component"]) != null ? _a2 : EmptyRenderer;
166
168
  const [_, setValue] = React.useState(0);
@@ -172,7 +174,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
172
174
  if (!model.isActive) {
173
175
  return null;
174
176
  }
175
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$s(__spreadValues$I({}, otherProps), {
177
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$u(__spreadValues$K({}, otherProps), {
176
178
  model
177
179
  }));
178
180
  }
@@ -218,19 +220,19 @@ class SceneObjectRef {
218
220
  }
219
221
  _ref = new WeakMap();
220
222
 
221
- var __defProp$H = Object.defineProperty;
222
- var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
223
- var __hasOwnProp$H = Object.prototype.hasOwnProperty;
224
- var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
225
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
- var __spreadValues$H = (a, b) => {
223
+ var __defProp$J = Object.defineProperty;
224
+ var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
225
+ var __hasOwnProp$J = Object.prototype.hasOwnProperty;
226
+ var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
227
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
228
+ var __spreadValues$J = (a, b) => {
227
229
  for (var prop in b || (b = {}))
228
- if (__hasOwnProp$H.call(b, prop))
229
- __defNormalProp$H(a, prop, b[prop]);
230
- if (__getOwnPropSymbols$H)
231
- for (var prop of __getOwnPropSymbols$H(b)) {
232
- if (__propIsEnum$H.call(b, prop))
233
- __defNormalProp$H(a, prop, b[prop]);
230
+ if (__hasOwnProp$J.call(b, prop))
231
+ __defNormalProp$J(a, prop, b[prop]);
232
+ if (__getOwnPropSymbols$J)
233
+ for (var prop of __getOwnPropSymbols$J(b)) {
234
+ if (__propIsEnum$J.call(b, prop))
235
+ __defNormalProp$J(a, prop, b[prop]);
234
236
  }
235
237
  return a;
236
238
  };
@@ -290,7 +292,7 @@ class SceneObjectBase {
290
292
  }
291
293
  setState(update) {
292
294
  const prevState = this._state;
293
- const newState = __spreadValues$H(__spreadValues$H({}, this._state), update);
295
+ const newState = __spreadValues$J(__spreadValues$J({}, this._state), update);
294
296
  this._state = Object.freeze(newState);
295
297
  this._setParent(update);
296
298
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -486,19 +488,19 @@ function forEachChild(state, callback) {
486
488
  }
487
489
  }
488
490
 
489
- var __defProp$G = Object.defineProperty;
490
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
491
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
492
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
493
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
494
- var __spreadValues$G = (a, b) => {
491
+ var __defProp$I = Object.defineProperty;
492
+ var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
493
+ var __hasOwnProp$I = Object.prototype.hasOwnProperty;
494
+ var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
495
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
496
+ var __spreadValues$I = (a, b) => {
495
497
  for (var prop in b || (b = {}))
496
- if (__hasOwnProp$G.call(b, prop))
497
- __defNormalProp$G(a, prop, b[prop]);
498
- if (__getOwnPropSymbols$G)
499
- for (var prop of __getOwnPropSymbols$G(b)) {
500
- if (__propIsEnum$G.call(b, prop))
501
- __defNormalProp$G(a, prop, b[prop]);
498
+ if (__hasOwnProp$I.call(b, prop))
499
+ __defNormalProp$I(a, prop, b[prop]);
500
+ if (__getOwnPropSymbols$I)
501
+ for (var prop of __getOwnPropSymbols$I(b)) {
502
+ if (__propIsEnum$I.call(b, prop))
503
+ __defNormalProp$I(a, prop, b[prop]);
502
504
  }
503
505
  return a;
504
506
  };
@@ -507,7 +509,7 @@ function cloneSceneObject(sceneObject, withState) {
507
509
  return new sceneObject.constructor(clonedState);
508
510
  }
509
511
  function cloneSceneObjectState(sceneState, withState) {
510
- const clonedState = __spreadValues$G({}, sceneState);
512
+ const clonedState = __spreadValues$I({}, sceneState);
511
513
  for (const key in clonedState) {
512
514
  const propValue = clonedState[key];
513
515
  if (propValue instanceof SceneObjectBase) {
@@ -604,25 +606,25 @@ function lookupVariable(name, sceneObject) {
604
606
  return null;
605
607
  }
606
608
 
607
- var __defProp$F = Object.defineProperty;
608
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
609
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
610
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
611
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
612
- var __spreadValues$F = (a, b) => {
609
+ var __defProp$H = Object.defineProperty;
610
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
611
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
612
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
613
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
614
+ var __spreadValues$H = (a, b) => {
613
615
  for (var prop in b || (b = {}))
614
- if (__hasOwnProp$F.call(b, prop))
615
- __defNormalProp$F(a, prop, b[prop]);
616
- if (__getOwnPropSymbols$F)
617
- for (var prop of __getOwnPropSymbols$F(b)) {
618
- if (__propIsEnum$F.call(b, prop))
619
- __defNormalProp$F(a, prop, b[prop]);
616
+ if (__hasOwnProp$H.call(b, prop))
617
+ __defNormalProp$H(a, prop, b[prop]);
618
+ if (__getOwnPropSymbols$H)
619
+ for (var prop of __getOwnPropSymbols$H(b)) {
620
+ if (__propIsEnum$H.call(b, prop))
621
+ __defNormalProp$H(a, prop, b[prop]);
620
622
  }
621
623
  return a;
622
624
  };
623
625
  class SceneDataNode extends SceneObjectBase {
624
626
  constructor(state) {
625
- super(__spreadValues$F({
627
+ super(__spreadValues$H({
626
628
  data: emptyPanelData
627
629
  }, state));
628
630
  }
@@ -703,19 +705,19 @@ function evaluateTimeRange(from, to, timeZone, fiscalYearStartMonth, delay) {
703
705
  };
704
706
  }
705
707
 
706
- var __defProp$E = Object.defineProperty;
707
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
708
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
709
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
710
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
711
- var __spreadValues$E = (a, b) => {
708
+ var __defProp$G = Object.defineProperty;
709
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
710
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
711
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
712
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
713
+ var __spreadValues$G = (a, b) => {
712
714
  for (var prop in b || (b = {}))
713
- if (__hasOwnProp$E.call(b, prop))
714
- __defNormalProp$E(a, prop, b[prop]);
715
- if (__getOwnPropSymbols$E)
716
- for (var prop of __getOwnPropSymbols$E(b)) {
717
- if (__propIsEnum$E.call(b, prop))
718
- __defNormalProp$E(a, prop, b[prop]);
715
+ if (__hasOwnProp$G.call(b, prop))
716
+ __defNormalProp$G(a, prop, b[prop]);
717
+ if (__getOwnPropSymbols$G)
718
+ for (var prop of __getOwnPropSymbols$G(b)) {
719
+ if (__propIsEnum$G.call(b, prop))
720
+ __defNormalProp$G(a, prop, b[prop]);
719
721
  }
720
722
  return a;
721
723
  };
@@ -732,7 +734,7 @@ class SceneTimeRange extends SceneObjectBase {
732
734
  state.fiscalYearStartMonth,
733
735
  state.UNSAFE_nowDelay
734
736
  );
735
- super(__spreadValues$E({ from, to, timeZone, value }, state));
737
+ super(__spreadValues$G({ from, to, timeZone, value }, state));
736
738
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to", "timezone"] });
737
739
  this.onTimeRangeChange = (timeRange) => {
738
740
  const update = {};
@@ -1363,25 +1365,25 @@ function collectAllVariables(sceneObject, record = {}) {
1363
1365
  return record;
1364
1366
  }
1365
1367
 
1366
- var __defProp$D = Object.defineProperty;
1367
- var __defProps$r = Object.defineProperties;
1368
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
1369
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
1370
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
1371
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
1372
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1373
- var __spreadValues$D = (a, b) => {
1368
+ var __defProp$F = Object.defineProperty;
1369
+ var __defProps$t = Object.defineProperties;
1370
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
1371
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
1372
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
1373
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
1374
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1375
+ var __spreadValues$F = (a, b) => {
1374
1376
  for (var prop in b || (b = {}))
1375
- if (__hasOwnProp$D.call(b, prop))
1376
- __defNormalProp$D(a, prop, b[prop]);
1377
- if (__getOwnPropSymbols$D)
1378
- for (var prop of __getOwnPropSymbols$D(b)) {
1379
- if (__propIsEnum$D.call(b, prop))
1380
- __defNormalProp$D(a, prop, b[prop]);
1377
+ if (__hasOwnProp$F.call(b, prop))
1378
+ __defNormalProp$F(a, prop, b[prop]);
1379
+ if (__getOwnPropSymbols$F)
1380
+ for (var prop of __getOwnPropSymbols$F(b)) {
1381
+ if (__propIsEnum$F.call(b, prop))
1382
+ __defNormalProp$F(a, prop, b[prop]);
1381
1383
  }
1382
1384
  return a;
1383
1385
  };
1384
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
1386
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
1385
1387
  function getTemplateProxyForField(field, frame, frames) {
1386
1388
  return new Proxy(
1387
1389
  {},
@@ -1397,7 +1399,7 @@ function getTemplateProxyForField(field, frame, frames) {
1397
1399
  if (!field.labels) {
1398
1400
  return "";
1399
1401
  }
1400
- return __spreadProps$r(__spreadValues$D({}, field.labels), {
1402
+ return __spreadProps$t(__spreadValues$F({}, field.labels), {
1401
1403
  __values: Object.values(field.labels).sort().join(", "),
1402
1404
  toString: () => {
1403
1405
  return data.formatLabels(field.labels, "", true);
@@ -2282,25 +2284,25 @@ function isExtraQueryProvider(obj) {
2282
2284
  return typeof obj === "object" && "getExtraQueries" in obj;
2283
2285
  }
2284
2286
 
2285
- var __defProp$C = Object.defineProperty;
2286
- var __defProps$q = Object.defineProperties;
2287
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2288
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
2289
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
2290
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
2291
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2292
- var __spreadValues$C = (a, b) => {
2287
+ var __defProp$E = Object.defineProperty;
2288
+ var __defProps$s = Object.defineProperties;
2289
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
2290
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
2291
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
2292
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
2293
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2294
+ var __spreadValues$E = (a, b) => {
2293
2295
  for (var prop in b || (b = {}))
2294
- if (__hasOwnProp$C.call(b, prop))
2295
- __defNormalProp$C(a, prop, b[prop]);
2296
- if (__getOwnPropSymbols$C)
2297
- for (var prop of __getOwnPropSymbols$C(b)) {
2298
- if (__propIsEnum$C.call(b, prop))
2299
- __defNormalProp$C(a, prop, b[prop]);
2296
+ if (__hasOwnProp$E.call(b, prop))
2297
+ __defNormalProp$E(a, prop, b[prop]);
2298
+ if (__getOwnPropSymbols$E)
2299
+ for (var prop of __getOwnPropSymbols$E(b)) {
2300
+ if (__propIsEnum$E.call(b, prop))
2301
+ __defNormalProp$E(a, prop, b[prop]);
2300
2302
  }
2301
2303
  return a;
2302
2304
  };
2303
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2305
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2304
2306
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
2305
2307
  const extraQueryProcessingOperator = (processors) => (data) => {
2306
2308
  return data.pipe(
@@ -2313,7 +2315,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2313
2315
  }),
2314
2316
  rxjs.map(([primary, ...processedSecondaries]) => {
2315
2317
  var _a;
2316
- return __spreadProps$q(__spreadValues$C({}, primary), {
2318
+ return __spreadProps$s(__spreadValues$E({}, primary), {
2317
2319
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
2318
2320
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
2319
2321
  var _a2;
@@ -2324,25 +2326,25 @@ const extraQueryProcessingOperator = (processors) => (data) => {
2324
2326
  );
2325
2327
  };
2326
2328
 
2327
- var __defProp$B = Object.defineProperty;
2328
- var __defProps$p = Object.defineProperties;
2329
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2330
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
2331
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
2332
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
2333
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2334
- var __spreadValues$B = (a, b) => {
2329
+ var __defProp$D = Object.defineProperty;
2330
+ var __defProps$r = Object.defineProperties;
2331
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
2332
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
2333
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
2334
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
2335
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2336
+ var __spreadValues$D = (a, b) => {
2335
2337
  for (var prop in b || (b = {}))
2336
- if (__hasOwnProp$B.call(b, prop))
2337
- __defNormalProp$B(a, prop, b[prop]);
2338
- if (__getOwnPropSymbols$B)
2339
- for (var prop of __getOwnPropSymbols$B(b)) {
2340
- if (__propIsEnum$B.call(b, prop))
2341
- __defNormalProp$B(a, prop, b[prop]);
2338
+ if (__hasOwnProp$D.call(b, prop))
2339
+ __defNormalProp$D(a, prop, b[prop]);
2340
+ if (__getOwnPropSymbols$D)
2341
+ for (var prop of __getOwnPropSymbols$D(b)) {
2342
+ if (__propIsEnum$D.call(b, prop))
2343
+ __defNormalProp$D(a, prop, b[prop]);
2342
2344
  }
2343
2345
  return a;
2344
2346
  };
2345
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2347
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
2346
2348
  function filterAnnotations(data, filters) {
2347
2349
  var _a;
2348
2350
  if (!Array.isArray(data) || data.length === 0) {
@@ -2393,11 +2395,11 @@ function filterAnnotations(data, filters) {
2393
2395
  continue;
2394
2396
  }
2395
2397
  }
2396
- fields.push(__spreadProps$p(__spreadValues$B({}, field), {
2398
+ fields.push(__spreadProps$r(__spreadValues$D({}, field), {
2397
2399
  values: buffer
2398
2400
  }));
2399
2401
  }
2400
- processed.push(__spreadProps$p(__spreadValues$B({}, frame), {
2402
+ processed.push(__spreadProps$r(__spreadValues$D({}, frame), {
2401
2403
  fields,
2402
2404
  length: frameLength
2403
2405
  }));
@@ -2823,33 +2825,33 @@ function getOptionSearcher(options, includeAll) {
2823
2825
  };
2824
2826
  }
2825
2827
 
2826
- var __defProp$A = Object.defineProperty;
2827
- var __defProps$o = Object.defineProperties;
2828
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2829
- var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
2830
- var __hasOwnProp$A = Object.prototype.hasOwnProperty;
2831
- var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
2832
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2833
- var __spreadValues$A = (a, b) => {
2834
- for (var prop in b || (b = {}))
2835
- if (__hasOwnProp$A.call(b, prop))
2836
- __defNormalProp$A(a, prop, b[prop]);
2837
- if (__getOwnPropSymbols$A)
2838
- for (var prop of __getOwnPropSymbols$A(b)) {
2839
- if (__propIsEnum$A.call(b, prop))
2840
- __defNormalProp$A(a, prop, b[prop]);
2828
+ var __defProp$C = Object.defineProperty;
2829
+ var __defProps$q = Object.defineProperties;
2830
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2831
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
2832
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
2833
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
2834
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2835
+ var __spreadValues$C = (a, b) => {
2836
+ for (var prop in b || (b = {}))
2837
+ if (__hasOwnProp$C.call(b, prop))
2838
+ __defNormalProp$C(a, prop, b[prop]);
2839
+ if (__getOwnPropSymbols$C)
2840
+ for (var prop of __getOwnPropSymbols$C(b)) {
2841
+ if (__propIsEnum$C.call(b, prop))
2842
+ __defNormalProp$C(a, prop, b[prop]);
2841
2843
  }
2842
2844
  return a;
2843
2845
  };
2844
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
2845
- var __objRest$3 = (source, exclude) => {
2846
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2847
+ var __objRest$4 = (source, exclude) => {
2846
2848
  var target = {};
2847
2849
  for (var prop in source)
2848
- if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
2850
+ if (__hasOwnProp$C.call(source, prop) && exclude.indexOf(prop) < 0)
2849
2851
  target[prop] = source[prop];
2850
- if (source != null && __getOwnPropSymbols$A)
2851
- for (var prop of __getOwnPropSymbols$A(source)) {
2852
- if (exclude.indexOf(prop) < 0 && __propIsEnum$A.call(source, prop))
2852
+ if (source != null && __getOwnPropSymbols$C)
2853
+ for (var prop of __getOwnPropSymbols$C(source)) {
2854
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$C.call(source, prop))
2853
2855
  target[prop] = source[prop];
2854
2856
  }
2855
2857
  return target;
@@ -2977,11 +2979,11 @@ const OptionWithCheckbox = ({
2977
2979
  renderOptionLabel
2978
2980
  }) => {
2979
2981
  var _b;
2980
- const _a = innerProps, rest = __objRest$3(_a, ["onMouseMove", "onMouseOver"]);
2982
+ const _a = innerProps, rest = __objRest$4(_a, ["onMouseMove", "onMouseOver"]);
2981
2983
  const theme = ui.useTheme2();
2982
2984
  const selectStyles = ui.getSelectStyles(theme);
2983
2985
  const optionStyles = ui.useStyles2(getOptionStyles);
2984
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({
2986
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$q(__spreadValues$C({
2985
2987
  ref: innerRef,
2986
2988
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2987
2989
  }, rest), {
@@ -3083,28 +3085,28 @@ function getEnrichedFiltersRequest(sourceRunner) {
3083
3085
  return null;
3084
3086
  }
3085
3087
 
3086
- var __defProp$z = Object.defineProperty;
3087
- var __defProps$n = Object.defineProperties;
3088
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
3089
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
3090
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
3091
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
3092
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3093
- var __spreadValues$z = (a, b) => {
3088
+ var __defProp$B = Object.defineProperty;
3089
+ var __defProps$p = Object.defineProperties;
3090
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
3091
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3092
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3093
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3094
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3095
+ var __spreadValues$B = (a, b) => {
3094
3096
  for (var prop in b || (b = {}))
3095
- if (__hasOwnProp$z.call(b, prop))
3096
- __defNormalProp$z(a, prop, b[prop]);
3097
- if (__getOwnPropSymbols$z)
3098
- for (var prop of __getOwnPropSymbols$z(b)) {
3099
- if (__propIsEnum$z.call(b, prop))
3100
- __defNormalProp$z(a, prop, b[prop]);
3097
+ if (__hasOwnProp$B.call(b, prop))
3098
+ __defNormalProp$B(a, prop, b[prop]);
3099
+ if (__getOwnPropSymbols$B)
3100
+ for (var prop of __getOwnPropSymbols$B(b)) {
3101
+ if (__propIsEnum$B.call(b, prop))
3102
+ __defNormalProp$B(a, prop, b[prop]);
3101
3103
  }
3102
3104
  return a;
3103
3105
  };
3104
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
3106
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
3105
3107
  class GroupByVariable extends MultiValueVariable {
3106
3108
  constructor(initialState) {
3107
- super(__spreadProps$n(__spreadValues$z({
3109
+ super(__spreadProps$p(__spreadValues$B({
3108
3110
  isMulti: true,
3109
3111
  name: "",
3110
3112
  value: [],
@@ -3137,7 +3139,7 @@ class GroupByVariable extends MultiValueVariable {
3137
3139
  const queries = getQueriesForVariables(this);
3138
3140
  const otherFilters = this.state.baseFilters || [];
3139
3141
  const timeRange = sceneGraph.getTimeRange(this).state.value;
3140
- const response = await ds.getTagKeys(__spreadValues$z({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
3142
+ const response = await ds.getTagKeys(__spreadValues$B({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
3141
3143
  if (responseHasError(response)) {
3142
3144
  this.setState({ error: response.error.message });
3143
3145
  }
@@ -3328,7 +3330,7 @@ function LoadingIndicator(props) {
3328
3330
  }
3329
3331
 
3330
3332
  function ControlsLabel(props) {
3331
- const styles = ui.useStyles2(getStyles$a);
3333
+ const styles = ui.useStyles2(getStyles$c);
3332
3334
  const theme = ui.useTheme2();
3333
3335
  const isVertical = props.layout === "vertical";
3334
3336
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3391,7 +3393,7 @@ function ControlsLabel(props) {
3391
3393
  }
3392
3394
  return labelElement;
3393
3395
  }
3394
- const getStyles$a = (theme) => ({
3396
+ const getStyles$c = (theme) => ({
3395
3397
  horizontalLabel: css.css({
3396
3398
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3397
3399
  display: `flex`,
@@ -3471,7 +3473,7 @@ function keyLabelToOption(key, label) {
3471
3473
  const filterNoOp = () => true;
3472
3474
  function AdHocFilterRenderer({ filter, model }) {
3473
3475
  var _a, _b;
3474
- const styles = ui.useStyles2(getStyles$9);
3476
+ const styles = ui.useStyles2(getStyles$b);
3475
3477
  const [keys, setKeys] = React.useState([]);
3476
3478
  const [values, setValues] = React.useState([]);
3477
3479
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3482,10 +3484,7 @@ function AdHocFilterRenderer({ filter, model }) {
3482
3484
  const [valueHasCustomValue, setValueHasCustomValue] = React.useState(false);
3483
3485
  const keyValue = keyLabelToOption(filter.key, filter.keyLabel);
3484
3486
  const valueValue = keyLabelToOption(filter.value, filter.valueLabel);
3485
- const optionSearcher = React.useMemo(
3486
- () => getAdhocOptionSearcher(values),
3487
- [values]
3488
- );
3487
+ const optionSearcher = React.useMemo(() => getAdhocOptionSearcher(values), [values]);
3489
3488
  const onValueInputChange = (value, { action }) => {
3490
3489
  if (action === "input-change") {
3491
3490
  setValueInputValue(value);
@@ -3615,7 +3614,7 @@ function AdHocFilterRenderer({ filter, model }) {
3615
3614
  onClick: () => model._removeFilter(filter)
3616
3615
  }));
3617
3616
  }
3618
- const getStyles$9 = (theme) => ({
3617
+ const getStyles$b = (theme) => ({
3619
3618
  field: css.css({
3620
3619
  marginBottom: 0
3621
3620
  }),
@@ -3753,6 +3752,564 @@ function isFilter(filter) {
3753
3752
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3754
3753
  }
3755
3754
 
3755
+ var __defProp$A = Object.defineProperty;
3756
+ var __defProps$o = Object.defineProperties;
3757
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
3758
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
3759
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
3760
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
3761
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3762
+ var __spreadValues$A = (a, b) => {
3763
+ for (var prop in b || (b = {}))
3764
+ if (__hasOwnProp$A.call(b, prop))
3765
+ __defNormalProp$A(a, prop, b[prop]);
3766
+ if (__getOwnPropSymbols$A)
3767
+ for (var prop of __getOwnPropSymbols$A(b)) {
3768
+ if (__propIsEnum$A.call(b, prop))
3769
+ __defNormalProp$A(a, prop, b[prop]);
3770
+ }
3771
+ return a;
3772
+ };
3773
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
3774
+ var __objRest$3 = (source, exclude) => {
3775
+ var target = {};
3776
+ for (var prop in source)
3777
+ if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
3778
+ target[prop] = source[prop];
3779
+ if (source != null && __getOwnPropSymbols$A)
3780
+ for (var prop of __getOwnPropSymbols$A(source)) {
3781
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$A.call(source, prop))
3782
+ target[prop] = source[prop];
3783
+ }
3784
+ return target;
3785
+ };
3786
+ const Item = React.forwardRef(
3787
+ (_a, ref) => {
3788
+ var _b = _a, { children, active } = _b, rest = __objRest$3(_b, ["children", "active"]);
3789
+ const theme = ui.useTheme2();
3790
+ const selectStyles = ui.getSelectStyles(theme);
3791
+ const id = react.useId();
3792
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$A({
3793
+ ref,
3794
+ role: "option",
3795
+ id,
3796
+ "aria-selected": active,
3797
+ className: css.cx(selectStyles.option, active && selectStyles.optionFocused)
3798
+ }, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
3799
+ className: selectStyles.optionBody,
3800
+ "data-testid": `data-testid ad hoc filter option value ${children}`
3801
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
3802
+ }
3803
+ );
3804
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, wip, handleChangeViewMode }, parentRef) {
3805
+ var _a;
3806
+ const [open, setOpen] = React.useState(false);
3807
+ const [options, setOptions] = React.useState([]);
3808
+ const [optionsLoading, setOptionsLoading] = React.useState(false);
3809
+ const [optionsError, setOptionsError] = React.useState(false);
3810
+ const [inputValue, setInputValue] = React.useState("");
3811
+ const [activeIndex, setActiveIndex] = React.useState(null);
3812
+ const [inputType, setInputType] = React.useState(!wip ? "value" : "key");
3813
+ const styles = ui.useStyles2(getStyles2);
3814
+ const listRef = React.useRef([]);
3815
+ const { _wip } = model.useState();
3816
+ const handleResetWip = React.useCallback(() => {
3817
+ if (wip) {
3818
+ model._addWip();
3819
+ setInputType("key");
3820
+ setInputValue("");
3821
+ }
3822
+ }, [model, wip]);
3823
+ const filterToUse = filter || _wip;
3824
+ const operatorIdentifier = `${(_a = filterToUse == null ? void 0 : filterToUse.key) != null ? _a : ""}-operator`;
3825
+ const { refs, floatingStyles, context } = react.useFloating({
3826
+ whileElementsMounted: react.autoUpdate,
3827
+ open,
3828
+ onOpenChange: (nextOpen, _, reason) => {
3829
+ setOpen(nextOpen);
3830
+ if (["outside-press", "escape-key"].includes(reason || "")) {
3831
+ handleResetWip();
3832
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3833
+ }
3834
+ },
3835
+ middleware: [
3836
+ react.flip({ padding: 10 }),
3837
+ react.size({
3838
+ apply({ rects, availableHeight, elements }) {
3839
+ Object.assign(elements.floating.style, {
3840
+ width: `${rects.reference.width}px`,
3841
+ maxHeight: `${availableHeight > 256 ? 256 : availableHeight}px`
3842
+ });
3843
+ },
3844
+ padding: 10
3845
+ })
3846
+ ]
3847
+ });
3848
+ const role = react.useRole(context, { role: "listbox" });
3849
+ const dismiss = react.useDismiss(context, {
3850
+ outsidePress: (event) => {
3851
+ return !event.currentTarget.classList.contains(
3852
+ operatorIdentifier
3853
+ );
3854
+ }
3855
+ });
3856
+ const listNav = react.useListNavigation(context, {
3857
+ listRef,
3858
+ activeIndex,
3859
+ onNavigate: setActiveIndex,
3860
+ virtual: true,
3861
+ loop: true
3862
+ });
3863
+ const { getReferenceProps, getFloatingProps, getItemProps } = react.useInteractions([role, dismiss, listNav]);
3864
+ React.useImperativeHandle(parentRef, () => () => {
3865
+ var _a2;
3866
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3867
+ }, [refs.domReference]);
3868
+ function onChange(event) {
3869
+ var _a2, _b;
3870
+ if (inputType === "key") {
3871
+ const lastChar = event.target.value.slice(-1);
3872
+ if (["=", "!", "<", ">"].includes(lastChar)) {
3873
+ const key = event.target.value.slice(0, -1);
3874
+ const optionIndex = options.findIndex((option) => option.value === key);
3875
+ if (optionIndex >= 0) {
3876
+ model._updateFilter(filterToUse, inputType, options[optionIndex]);
3877
+ setInputValue(lastChar);
3878
+ }
3879
+ reactDom.flushSync(() => {
3880
+ setInputType("operator");
3881
+ });
3882
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3883
+ return;
3884
+ }
3885
+ }
3886
+ if (inputType === "operator") {
3887
+ const lastChar = event.target.value.slice(-1);
3888
+ if (/\w/.test(lastChar)) {
3889
+ const operator = event.target.value.slice(0, -1);
3890
+ if (!/\w/.test(operator)) {
3891
+ const optionIndex = options.findIndex((option) => option.value === operator);
3892
+ if (optionIndex >= 0) {
3893
+ model._updateFilter(filterToUse, inputType, options[optionIndex]);
3894
+ setInputValue(lastChar);
3895
+ }
3896
+ reactDom.flushSync(() => {
3897
+ setInputType("value");
3898
+ });
3899
+ (_b = refs.domReference.current) == null ? void 0 : _b.focus();
3900
+ return;
3901
+ }
3902
+ }
3903
+ }
3904
+ const value = event.target.value;
3905
+ setInputValue(value);
3906
+ setActiveIndex(0);
3907
+ }
3908
+ const items = options.filter(
3909
+ (item) => {
3910
+ var _a2, _b;
3911
+ return (_b = (_a2 = item.label) != null ? _a2 : item.value) == null ? void 0 : _b.toLocaleLowerCase().startsWith(inputValue.toLowerCase());
3912
+ }
3913
+ );
3914
+ const flushInputType = React.useCallback((inputType2) => {
3915
+ reactDom.flushSync(() => {
3916
+ setInputType(inputType2);
3917
+ });
3918
+ }, []);
3919
+ React.useEffect(() => {
3920
+ if (wip && !_wip) {
3921
+ model._addWip();
3922
+ }
3923
+ }, [_wip]);
3924
+ React.useEffect(() => {
3925
+ if (!wip && refs.domReference.current) {
3926
+ setInputType("value");
3927
+ setInputValue("");
3928
+ refs.domReference.current.focus();
3929
+ }
3930
+ }, []);
3931
+ const handleFetchOptions = React.useCallback(
3932
+ async (inputType2) => {
3933
+ setOptionsError(false);
3934
+ setOptionsLoading(true);
3935
+ setOptions([]);
3936
+ let options2 = [];
3937
+ try {
3938
+ if (inputType2 === "key") {
3939
+ options2 = await model._getKeys(null);
3940
+ } else if (inputType2 === "operator") {
3941
+ options2 = model._getOperators();
3942
+ } else if (inputType2 === "value") {
3943
+ options2 = await model._getValuesFor(filterToUse);
3944
+ }
3945
+ setOptions(options2);
3946
+ } catch (e) {
3947
+ setOptionsError(true);
3948
+ }
3949
+ setOptionsLoading(false);
3950
+ },
3951
+ [filterToUse, model]
3952
+ );
3953
+ const handleBackspaceInput = React.useCallback(
3954
+ (event) => {
3955
+ if (event.key === "Backspace" && !inputValue && inputType === "key") {
3956
+ model._removeLastFilter();
3957
+ handleFetchOptions(inputType);
3958
+ }
3959
+ },
3960
+ [inputValue, inputType]
3961
+ );
3962
+ const handleTabInput = React.useCallback((event) => {
3963
+ if (event.key === "Tab" && !event.shiftKey) {
3964
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3965
+ handleResetWip();
3966
+ }
3967
+ }, []);
3968
+ const handleShiftTabInput = React.useCallback((event) => {
3969
+ if (event.key === "Tab" && event.shiftKey) {
3970
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3971
+ handleResetWip();
3972
+ }
3973
+ }, []);
3974
+ const handleEnterInput = React.useCallback(
3975
+ (event) => {
3976
+ var _a2;
3977
+ if (event.key === "Enter" && activeIndex != null && items[activeIndex]) {
3978
+ model._updateFilter(filterToUse, inputType, items[activeIndex]);
3979
+ setInputValue("");
3980
+ setActiveIndex(0);
3981
+ if (inputType === "key") {
3982
+ flushInputType("operator");
3983
+ } else if (inputType === "operator") {
3984
+ flushInputType("value");
3985
+ } else if (inputType === "value") {
3986
+ flushInputType("key");
3987
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3988
+ }
3989
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3990
+ }
3991
+ },
3992
+ [activeIndex, filterToUse, inputType, items, model]
3993
+ );
3994
+ React.useEffect(() => {
3995
+ if (open) {
3996
+ handleFetchOptions(inputType);
3997
+ }
3998
+ }, [open, inputType]);
3999
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4000
+ className: styles.comboboxWrapper
4001
+ }, filterToUse ? /* @__PURE__ */ React__default["default"].createElement("div", {
4002
+ className: styles.pillWrapper
4003
+ }, (filterToUse == null ? void 0 : filterToUse.key) ? /* @__PURE__ */ React__default["default"].createElement("div", {
4004
+ className: css.cx(styles.basePill, styles.keyPill)
4005
+ }, filterToUse.key) : null, (filterToUse == null ? void 0 : filterToUse.key) && (filterToUse == null ? void 0 : filterToUse.operator) && inputType !== "operator" ? /* @__PURE__ */ React__default["default"].createElement("div", {
4006
+ className: css.cx(styles.basePill, styles.operatorPill, operatorIdentifier),
4007
+ role: "button",
4008
+ "aria-label": "Edit filter operator",
4009
+ tabIndex: 0,
4010
+ onClick: (event) => {
4011
+ var _a2;
4012
+ event.stopPropagation();
4013
+ flushInputType("operator");
4014
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
4015
+ },
4016
+ onKeyDown: (event) => {
4017
+ var _a2;
4018
+ handleShiftTabInput(event);
4019
+ if (event.key === "Enter") {
4020
+ flushInputType("operator");
4021
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
4022
+ }
4023
+ }
4024
+ }, filterToUse.operator) : null, (filterToUse == null ? void 0 : filterToUse.key) && (filterToUse == null ? void 0 : filterToUse.operator) && (filterToUse == null ? void 0 : filterToUse.value) && !["operator", "value"].includes(inputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
4025
+ className: css.cx(styles.basePill, styles.valuePill)
4026
+ }, filterToUse.value) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
4027
+ ref: refs.setReference,
4028
+ onChange,
4029
+ value: inputValue,
4030
+ placeholder: !wip ? inputType === "operator" ? `${filterToUse[inputType]} ${filterToUse.value || ""}` : filterToUse[inputType] : "Filter by label values",
4031
+ "aria-autocomplete": "list",
4032
+ onKeyDown(event) {
4033
+ if (inputType === "operator") {
4034
+ handleShiftTabInput(event);
4035
+ }
4036
+ handleBackspaceInput(event);
4037
+ handleTabInput(event);
4038
+ handleEnterInput(event);
4039
+ }
4040
+ })), {
4041
+ className: styles.inputStyle,
4042
+ onClick: (event) => {
4043
+ event.stopPropagation();
4044
+ setOpen(true);
4045
+ },
4046
+ onFocus: () => {
4047
+ setActiveIndex(0);
4048
+ setOpen(true);
4049
+ }
4050
+ })), /* @__PURE__ */ React__default["default"].createElement(react.FloatingPortal, null, open && /* @__PURE__ */ React__default["default"].createElement(react.FloatingFocusManager, {
4051
+ context,
4052
+ initialFocus: -1,
4053
+ visuallyHiddenDismiss: true
4054
+ }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({}, getFloatingProps({
4055
+ ref: refs.setFloating,
4056
+ style: __spreadProps$o(__spreadValues$A({}, floatingStyles), {
4057
+ overflowY: "auto"
4058
+ })
4059
+ })), {
4060
+ className: styles.dropdownWrapper
4061
+ }), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React__default["default"].createElement(OptionsErrorPlaceholder, {
4062
+ handleFetchOptions: () => handleFetchOptions(inputType)
4063
+ }) : !items.length ? /* @__PURE__ */ React__default["default"].createElement(NoOptionsPlaceholder, null) : items.map((item, index) => {
4064
+ var _a2;
4065
+ return /* @__PURE__ */ React__default["default"].createElement(Item, __spreadProps$o(__spreadValues$A({}, getItemProps({
4066
+ key: item.value,
4067
+ ref(node) {
4068
+ listRef.current[index] = node;
4069
+ },
4070
+ onClick() {
4071
+ var _a3;
4072
+ model._updateFilter(filterToUse, inputType, item);
4073
+ setInputValue("");
4074
+ if (inputType === "key") {
4075
+ flushInputType("operator");
4076
+ } else if (inputType === "operator") {
4077
+ flushInputType("value");
4078
+ } else if (inputType === "value") {
4079
+ flushInputType("key");
4080
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
4081
+ }
4082
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
4083
+ }
4084
+ })), {
4085
+ active: activeIndex === index
4086
+ }), (_a2 = item.label) != null ? _a2 : item.value);
4087
+ })))));
4088
+ });
4089
+ const LoadingOptionsPlaceholder = () => {
4090
+ return /* @__PURE__ */ React__default["default"].createElement(Item, {
4091
+ active: false
4092
+ }, "Loading options...");
4093
+ };
4094
+ const NoOptionsPlaceholder = () => {
4095
+ return /* @__PURE__ */ React__default["default"].createElement(Item, {
4096
+ active: false
4097
+ }, "No options found");
4098
+ };
4099
+ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
4100
+ return /* @__PURE__ */ React__default["default"].createElement(Item, {
4101
+ active: false,
4102
+ onClick: handleFetchOptions
4103
+ }, "Error. Click to try again!");
4104
+ };
4105
+ const getStyles2 = (theme) => ({
4106
+ comboboxWrapper: css.css({
4107
+ display: "flex",
4108
+ flexWrap: "nowrap"
4109
+ }),
4110
+ pillWrapper: css.css({
4111
+ display: "flex",
4112
+ alignItems: "center",
4113
+ whiteSpace: "nowrap"
4114
+ }),
4115
+ basePill: css.css(__spreadProps$o(__spreadValues$A({
4116
+ display: "flex",
4117
+ alignItems: "center",
4118
+ background: theme.colors.action.disabledBackground,
4119
+ border: `1px solid ${theme.colors.border.weak}`,
4120
+ padding: theme.spacing(0.125, 1, 0.125, 1),
4121
+ color: theme.colors.text.primary,
4122
+ overflow: "hidden",
4123
+ whiteSpace: "nowrap",
4124
+ minHeight: "22px"
4125
+ }, theme.typography.bodySmall), {
4126
+ cursor: "pointer"
4127
+ })),
4128
+ keyPill: css.css({
4129
+ fontWeight: theme.typography.fontWeightBold,
4130
+ cursor: "default"
4131
+ }),
4132
+ operatorPill: css.css({
4133
+ "&:hover": {
4134
+ background: theme.colors.action.hover
4135
+ }
4136
+ }),
4137
+ valuePill: css.css({
4138
+ background: theme.colors.action.selected
4139
+ }),
4140
+ dropdownWrapper: css.css({
4141
+ backgroundColor: theme.colors.background.primary,
4142
+ color: theme.colors.text.primary,
4143
+ boxShadow: theme.shadows.z2
4144
+ }),
4145
+ inputStyle: css.css({
4146
+ paddingBlock: 0,
4147
+ "&:focus": {
4148
+ outline: "none"
4149
+ }
4150
+ })
4151
+ });
4152
+
4153
+ var __defProp$z = Object.defineProperty;
4154
+ var __defProps$n = Object.defineProperties;
4155
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
4156
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
4157
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
4158
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
4159
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4160
+ var __spreadValues$z = (a, b) => {
4161
+ for (var prop in b || (b = {}))
4162
+ if (__hasOwnProp$z.call(b, prop))
4163
+ __defNormalProp$z(a, prop, b[prop]);
4164
+ if (__getOwnPropSymbols$z)
4165
+ for (var prop of __getOwnPropSymbols$z(b)) {
4166
+ if (__propIsEnum$z.call(b, prop))
4167
+ __defNormalProp$z(a, prop, b[prop]);
4168
+ }
4169
+ return a;
4170
+ };
4171
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
4172
+ function AdHocFiltersComboboxEditSwitch({
4173
+ filter,
4174
+ model
4175
+ }) {
4176
+ const styles = ui.useStyles2(getStyles$a);
4177
+ const [viewMode, setViewMode] = React.useState(true);
4178
+ const pillWrapperRef = React.useRef(null);
4179
+ const handleChangeViewMode = React.useCallback((event) => {
4180
+ var _a;
4181
+ event == null ? void 0 : event.stopPropagation();
4182
+ let viewMode2 = false;
4183
+ reactDom.flushSync(() => {
4184
+ setViewMode((mode) => {
4185
+ viewMode2 = mode;
4186
+ return !mode;
4187
+ });
4188
+ });
4189
+ if (!viewMode2) {
4190
+ (_a = pillWrapperRef.current) == null ? void 0 : _a.focus();
4191
+ }
4192
+ }, []);
4193
+ if (viewMode) {
4194
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4195
+ className: styles.combinedFilterPill,
4196
+ onClick: handleChangeViewMode,
4197
+ onKeyDown: (e) => {
4198
+ if (e.key === "Enter") {
4199
+ handleChangeViewMode();
4200
+ }
4201
+ },
4202
+ role: "button",
4203
+ "aria-label": "Edit filter",
4204
+ tabIndex: 0,
4205
+ ref: pillWrapperRef
4206
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, filter.key, " ", filter.operator, " ", filter.value), /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
4207
+ onClick: (e) => {
4208
+ e.stopPropagation();
4209
+ model._removeFilter(filter);
4210
+ },
4211
+ onKeyDownCapture: (e) => {
4212
+ if (e.key === "Enter") {
4213
+ e.preventDefault();
4214
+ e.stopPropagation();
4215
+ model._removeFilter(filter);
4216
+ }
4217
+ },
4218
+ name: "times",
4219
+ size: "md",
4220
+ className: styles.removeButton,
4221
+ tooltip: "Remove filter"
4222
+ }));
4223
+ }
4224
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4225
+ filter,
4226
+ model,
4227
+ handleChangeViewMode
4228
+ });
4229
+ }
4230
+ const getStyles$a = (theme) => ({
4231
+ combinedFilterPill: css.css(__spreadProps$n(__spreadValues$z({
4232
+ display: "flex",
4233
+ alignItems: "center",
4234
+ background: theme.colors.action.selected,
4235
+ borderRadius: theme.shape.radius.default,
4236
+ border: `1px solid ${theme.colors.border.weak}`,
4237
+ padding: theme.spacing(0.125, 0, 0.125, 1),
4238
+ color: theme.colors.text.primary,
4239
+ overflow: "hidden",
4240
+ whiteSpace: "nowrap",
4241
+ minHeight: "22px"
4242
+ }, theme.typography.bodySmall), {
4243
+ fontWeight: theme.typography.fontWeightBold,
4244
+ cursor: "pointer",
4245
+ "&:hover": {
4246
+ background: theme.colors.action.hover
4247
+ }
4248
+ })),
4249
+ removeButton: css.css({
4250
+ marginInline: theme.spacing(0.5),
4251
+ cursor: "pointer",
4252
+ "&:hover": {
4253
+ color: theme.colors.text.primary
4254
+ }
4255
+ })
4256
+ });
4257
+
4258
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({
4259
+ model
4260
+ }) {
4261
+ const { filters } = model.useState();
4262
+ const styles = ui.useStyles2(getStyles$9);
4263
+ const focusOnInputRef = React.useRef();
4264
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4265
+ className: styles.comboboxWrapper,
4266
+ onClick: () => {
4267
+ var _a;
4268
+ (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
4269
+ }
4270
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4271
+ name: "filter",
4272
+ className: styles.filterIcon,
4273
+ size: "lg"
4274
+ }), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxEditSwitch, {
4275
+ key: index,
4276
+ filter,
4277
+ model
4278
+ })), /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4279
+ model,
4280
+ wip: true,
4281
+ ref: focusOnInputRef
4282
+ }));
4283
+ });
4284
+ const getStyles$9 = (theme) => ({
4285
+ comboboxWrapper: css.css({
4286
+ display: "flex",
4287
+ flexWrap: "wrap",
4288
+ alignItems: "center",
4289
+ columnGap: theme.spacing(1),
4290
+ rowGap: theme.spacing(0.5),
4291
+ minHeight: theme.spacing(4),
4292
+ backgroundColor: theme.components.input.background,
4293
+ border: `1px solid ${theme.colors.border.strong}`,
4294
+ borderRadius: theme.shape.radius.default,
4295
+ paddingInline: theme.spacing(1),
4296
+ paddingBlock: theme.spacing(0.5),
4297
+ flexGrow: 1,
4298
+ "&:focus-within": {
4299
+ outline: "2px dotted transparent",
4300
+ outlineOffset: "2px",
4301
+ boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,
4302
+ transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,
4303
+ transitionDuration: "0.2s",
4304
+ transitionProperty: "outline, outline-offset, box-shadow"
4305
+ }
4306
+ }),
4307
+ filterIcon: css.css({
4308
+ color: theme.colors.text.secondary,
4309
+ alignSelf: "center"
4310
+ })
4311
+ });
4312
+
3756
4313
  var __defProp$y = Object.defineProperty;
3757
4314
  var __defProps$m = Object.defineProperties;
3758
4315
  var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
@@ -3838,6 +4395,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
3838
4395
  }
3839
4396
  this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
3840
4397
  }
4398
+ _removeLastFilter() {
4399
+ const filterToRemove = this.state.filters.at(-1);
4400
+ if (filterToRemove) {
4401
+ this._removeFilter(filterToRemove);
4402
+ }
4403
+ }
3841
4404
  async _getKeys(currentKey) {
3842
4405
  var _a, _b, _c;
3843
4406
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
@@ -3854,7 +4417,11 @@ class AdHocFiltersVariable extends SceneObjectBase {
3854
4417
  const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat((_c = this.state.baseFilters) != null ? _c : []);
3855
4418
  const timeRange = sceneGraph.getTimeRange(this).state.value;
3856
4419
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
3857
- const response = await ds.getTagKeys(__spreadValues$y({ filters: otherFilters, queries, timeRange }, getEnrichedFiltersRequest(this)));
4420
+ const response = await ds.getTagKeys(__spreadValues$y({
4421
+ filters: otherFilters,
4422
+ queries,
4423
+ timeRange
4424
+ }, getEnrichedFiltersRequest(this)));
3858
4425
  if (responseHasError(response)) {
3859
4426
  this.setState({ error: response.error.message });
3860
4427
  }
@@ -3915,6 +4482,11 @@ function renderExpression(builder, filters) {
3915
4482
  function AdHocFiltersVariableRenderer({ model }) {
3916
4483
  const { filters, readOnly, addFilterButtonText } = model.useState();
3917
4484
  const styles = ui.useStyles2(getStyles$8);
4485
+ if (model.state.layout === "combobox") {
4486
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
4487
+ model
4488
+ });
4489
+ }
3918
4490
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3919
4491
  className: styles.wrapper
3920
4492
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3935,10 +4507,6 @@ const getStyles$8 = (theme) => ({
3935
4507
  alignItems: "flex-end",
3936
4508
  columnGap: theme.spacing(2),
3937
4509
  rowGap: theme.spacing(1)
3938
- }),
3939
- filterIcon: css.css({
3940
- color: theme.colors.text.secondary,
3941
- paddingRight: theme.spacing(0.5)
3942
4510
  })
3943
4511
  });
3944
4512
  function toSelectableValue(input) {