@grafana/scenes 5.10.0 → 5.10.1--canary.830.10456603604.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,9 @@ 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 reactDom = require('react-dom');
18
+ var react = require('@floating-ui/react');
19
+ var reactVirtual = require('@tanstack/react-virtual');
17
20
  var reactUse = require('react-use');
18
21
  var operators = require('rxjs/operators');
19
22
  var ReactGridLayout = require('react-grid-layout');
@@ -39,19 +42,19 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
39
42
  var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
40
43
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
41
44
 
42
- var __defProp$K = Object.defineProperty;
43
- var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
44
- var __hasOwnProp$K = Object.prototype.hasOwnProperty;
45
- var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
46
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
47
- var __spreadValues$K = (a, b) => {
45
+ var __defProp$N = Object.defineProperty;
46
+ var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
47
+ var __hasOwnProp$N = Object.prototype.hasOwnProperty;
48
+ var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
49
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
50
+ var __spreadValues$N = (a, b) => {
48
51
  for (var prop in b || (b = {}))
49
- if (__hasOwnProp$K.call(b, prop))
50
- __defNormalProp$K(a, prop, b[prop]);
51
- if (__getOwnPropSymbols$K)
52
- for (var prop of __getOwnPropSymbols$K(b)) {
53
- if (__propIsEnum$K.call(b, prop))
54
- __defNormalProp$K(a, prop, b[prop]);
52
+ if (__hasOwnProp$N.call(b, prop))
53
+ __defNormalProp$N(a, prop, b[prop]);
54
+ if (__getOwnPropSymbols$N)
55
+ for (var prop of __getOwnPropSymbols$N(b)) {
56
+ if (__propIsEnum$N.call(b, prop))
57
+ __defNormalProp$N(a, prop, b[prop]);
55
58
  }
56
59
  return a;
57
60
  };
@@ -60,7 +63,7 @@ function useAppQueryParams() {
60
63
  return runtime.locationSearchToObject(location.search || "");
61
64
  }
62
65
  function getUrlWithAppState(path, preserveParams) {
63
- const paramsCopy = __spreadValues$K({}, runtime.locationService.getSearchObject());
66
+ const paramsCopy = __spreadValues$N({}, runtime.locationService.getSearchObject());
64
67
  if (preserveParams) {
65
68
  for (const key of Object.keys(paramsCopy)) {
66
69
  if (!preserveParams.includes(key)) {
@@ -74,31 +77,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
74
77
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
75
78
  }
76
79
 
77
- var __defProp$J = Object.defineProperty;
78
- var __defProps$t = Object.defineProperties;
79
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
80
- var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
81
- var __hasOwnProp$J = Object.prototype.hasOwnProperty;
82
- var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
83
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
84
- var __spreadValues$J = (a, b) => {
80
+ var __defProp$M = Object.defineProperty;
81
+ var __defProps$v = Object.defineProperties;
82
+ var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
83
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
84
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
85
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
86
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
87
+ var __spreadValues$M = (a, b) => {
85
88
  for (var prop in b || (b = {}))
86
- if (__hasOwnProp$J.call(b, prop))
87
- __defNormalProp$J(a, prop, b[prop]);
88
- if (__getOwnPropSymbols$J)
89
- for (var prop of __getOwnPropSymbols$J(b)) {
90
- if (__propIsEnum$J.call(b, prop))
91
- __defNormalProp$J(a, prop, b[prop]);
89
+ if (__hasOwnProp$M.call(b, prop))
90
+ __defNormalProp$M(a, prop, b[prop]);
91
+ if (__getOwnPropSymbols$M)
92
+ for (var prop of __getOwnPropSymbols$M(b)) {
93
+ if (__propIsEnum$M.call(b, prop))
94
+ __defNormalProp$M(a, prop, b[prop]);
92
95
  }
93
96
  return a;
94
97
  };
95
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
98
+ var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
96
99
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
97
100
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
98
101
  if (runtimePanelPlugins.has(pluginId)) {
99
102
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
100
103
  }
101
- plugin.meta = __spreadProps$t(__spreadValues$J({}, plugin.meta), {
104
+ plugin.meta = __spreadProps$v(__spreadValues$M({}, plugin.meta), {
102
105
  id: pluginId,
103
106
  name: pluginId,
104
107
  module: "runtime plugin",
@@ -126,39 +129,39 @@ function loadPanelPluginSync(pluginId) {
126
129
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
127
130
  }
128
131
 
129
- var __defProp$I = Object.defineProperty;
130
- var __defProps$s = Object.defineProperties;
131
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
132
- var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
133
- var __hasOwnProp$I = Object.prototype.hasOwnProperty;
134
- var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
135
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
136
- var __spreadValues$I = (a, b) => {
132
+ var __defProp$L = Object.defineProperty;
133
+ var __defProps$u = Object.defineProperties;
134
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
135
+ var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
136
+ var __hasOwnProp$L = Object.prototype.hasOwnProperty;
137
+ var __propIsEnum$L = Object.prototype.propertyIsEnumerable;
138
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
139
+ var __spreadValues$L = (a, b) => {
137
140
  for (var prop in b || (b = {}))
138
- if (__hasOwnProp$I.call(b, prop))
139
- __defNormalProp$I(a, prop, b[prop]);
140
- if (__getOwnPropSymbols$I)
141
- for (var prop of __getOwnPropSymbols$I(b)) {
142
- if (__propIsEnum$I.call(b, prop))
143
- __defNormalProp$I(a, prop, b[prop]);
141
+ if (__hasOwnProp$L.call(b, prop))
142
+ __defNormalProp$L(a, prop, b[prop]);
143
+ if (__getOwnPropSymbols$L)
144
+ for (var prop of __getOwnPropSymbols$L(b)) {
145
+ if (__propIsEnum$L.call(b, prop))
146
+ __defNormalProp$L(a, prop, b[prop]);
144
147
  }
145
148
  return a;
146
149
  };
147
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
148
- var __objRest$4 = (source, exclude) => {
150
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
151
+ var __objRest$5 = (source, exclude) => {
149
152
  var target = {};
150
153
  for (var prop in source)
151
- if (__hasOwnProp$I.call(source, prop) && exclude.indexOf(prop) < 0)
154
+ if (__hasOwnProp$L.call(source, prop) && exclude.indexOf(prop) < 0)
152
155
  target[prop] = source[prop];
153
- if (source != null && __getOwnPropSymbols$I)
154
- for (var prop of __getOwnPropSymbols$I(source)) {
155
- if (exclude.indexOf(prop) < 0 && __propIsEnum$I.call(source, prop))
156
+ if (source != null && __getOwnPropSymbols$L)
157
+ for (var prop of __getOwnPropSymbols$L(source)) {
158
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$L.call(source, prop))
156
159
  target[prop] = source[prop];
157
160
  }
158
161
  return target;
159
162
  };
160
163
  function SceneComponentWrapperWithoutMemo(_a) {
161
- var _b = _a, { model } = _b, otherProps = __objRest$4(_b, ["model"]);
164
+ var _b = _a, { model } = _b, otherProps = __objRest$5(_b, ["model"]);
162
165
  var _a2;
163
166
  const Component = (_a2 = model.constructor["Component"]) != null ? _a2 : EmptyRenderer;
164
167
  const [_, setValue] = React.useState(0);
@@ -170,7 +173,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
170
173
  if (!model.isActive) {
171
174
  return null;
172
175
  }
173
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$s(__spreadValues$I({}, otherProps), {
176
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$u(__spreadValues$L({}, otherProps), {
174
177
  model
175
178
  }));
176
179
  }
@@ -216,19 +219,19 @@ class SceneObjectRef {
216
219
  }
217
220
  _ref = new WeakMap();
218
221
 
219
- var __defProp$H = Object.defineProperty;
220
- var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
221
- var __hasOwnProp$H = Object.prototype.hasOwnProperty;
222
- var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
223
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
224
- var __spreadValues$H = (a, b) => {
222
+ var __defProp$K = Object.defineProperty;
223
+ var __getOwnPropSymbols$K = Object.getOwnPropertySymbols;
224
+ var __hasOwnProp$K = Object.prototype.hasOwnProperty;
225
+ var __propIsEnum$K = Object.prototype.propertyIsEnumerable;
226
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
227
+ var __spreadValues$K = (a, b) => {
225
228
  for (var prop in b || (b = {}))
226
- if (__hasOwnProp$H.call(b, prop))
227
- __defNormalProp$H(a, prop, b[prop]);
228
- if (__getOwnPropSymbols$H)
229
- for (var prop of __getOwnPropSymbols$H(b)) {
230
- if (__propIsEnum$H.call(b, prop))
231
- __defNormalProp$H(a, prop, b[prop]);
229
+ if (__hasOwnProp$K.call(b, prop))
230
+ __defNormalProp$K(a, prop, b[prop]);
231
+ if (__getOwnPropSymbols$K)
232
+ for (var prop of __getOwnPropSymbols$K(b)) {
233
+ if (__propIsEnum$K.call(b, prop))
234
+ __defNormalProp$K(a, prop, b[prop]);
232
235
  }
233
236
  return a;
234
237
  };
@@ -288,7 +291,7 @@ class SceneObjectBase {
288
291
  }
289
292
  setState(update) {
290
293
  const prevState = this._state;
291
- const newState = __spreadValues$H(__spreadValues$H({}, this._state), update);
294
+ const newState = __spreadValues$K(__spreadValues$K({}, this._state), update);
292
295
  this._state = Object.freeze(newState);
293
296
  this._setParent(update);
294
297
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -484,19 +487,19 @@ function forEachChild(state, callback) {
484
487
  }
485
488
  }
486
489
 
487
- var __defProp$G = Object.defineProperty;
488
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
489
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
490
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
491
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
492
- var __spreadValues$G = (a, b) => {
490
+ var __defProp$J = Object.defineProperty;
491
+ var __getOwnPropSymbols$J = Object.getOwnPropertySymbols;
492
+ var __hasOwnProp$J = Object.prototype.hasOwnProperty;
493
+ var __propIsEnum$J = Object.prototype.propertyIsEnumerable;
494
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
495
+ var __spreadValues$J = (a, b) => {
493
496
  for (var prop in b || (b = {}))
494
- if (__hasOwnProp$G.call(b, prop))
495
- __defNormalProp$G(a, prop, b[prop]);
496
- if (__getOwnPropSymbols$G)
497
- for (var prop of __getOwnPropSymbols$G(b)) {
498
- if (__propIsEnum$G.call(b, prop))
499
- __defNormalProp$G(a, prop, b[prop]);
497
+ if (__hasOwnProp$J.call(b, prop))
498
+ __defNormalProp$J(a, prop, b[prop]);
499
+ if (__getOwnPropSymbols$J)
500
+ for (var prop of __getOwnPropSymbols$J(b)) {
501
+ if (__propIsEnum$J.call(b, prop))
502
+ __defNormalProp$J(a, prop, b[prop]);
500
503
  }
501
504
  return a;
502
505
  };
@@ -505,7 +508,7 @@ function cloneSceneObject(sceneObject, withState) {
505
508
  return new sceneObject.constructor(clonedState);
506
509
  }
507
510
  function cloneSceneObjectState(sceneState, withState) {
508
- const clonedState = __spreadValues$G({}, sceneState);
511
+ const clonedState = __spreadValues$J({}, sceneState);
509
512
  for (const key in clonedState) {
510
513
  const propValue = clonedState[key];
511
514
  if (propValue instanceof SceneObjectBase) {
@@ -602,25 +605,25 @@ function lookupVariable(name, sceneObject) {
602
605
  return null;
603
606
  }
604
607
 
605
- var __defProp$F = Object.defineProperty;
606
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
607
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
608
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
609
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
610
- var __spreadValues$F = (a, b) => {
608
+ var __defProp$I = Object.defineProperty;
609
+ var __getOwnPropSymbols$I = Object.getOwnPropertySymbols;
610
+ var __hasOwnProp$I = Object.prototype.hasOwnProperty;
611
+ var __propIsEnum$I = Object.prototype.propertyIsEnumerable;
612
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
613
+ var __spreadValues$I = (a, b) => {
611
614
  for (var prop in b || (b = {}))
612
- if (__hasOwnProp$F.call(b, prop))
613
- __defNormalProp$F(a, prop, b[prop]);
614
- if (__getOwnPropSymbols$F)
615
- for (var prop of __getOwnPropSymbols$F(b)) {
616
- if (__propIsEnum$F.call(b, prop))
617
- __defNormalProp$F(a, prop, b[prop]);
615
+ if (__hasOwnProp$I.call(b, prop))
616
+ __defNormalProp$I(a, prop, b[prop]);
617
+ if (__getOwnPropSymbols$I)
618
+ for (var prop of __getOwnPropSymbols$I(b)) {
619
+ if (__propIsEnum$I.call(b, prop))
620
+ __defNormalProp$I(a, prop, b[prop]);
618
621
  }
619
622
  return a;
620
623
  };
621
624
  class SceneDataNode extends SceneObjectBase {
622
625
  constructor(state) {
623
- super(__spreadValues$F({
626
+ super(__spreadValues$I({
624
627
  data: emptyPanelData
625
628
  }, state));
626
629
  }
@@ -701,19 +704,19 @@ function evaluateTimeRange(from, to, timeZone, fiscalYearStartMonth, delay) {
701
704
  };
702
705
  }
703
706
 
704
- var __defProp$E = Object.defineProperty;
705
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
706
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
707
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
708
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
709
- var __spreadValues$E = (a, b) => {
707
+ var __defProp$H = Object.defineProperty;
708
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
709
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
710
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
711
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
712
+ var __spreadValues$H = (a, b) => {
710
713
  for (var prop in b || (b = {}))
711
- if (__hasOwnProp$E.call(b, prop))
712
- __defNormalProp$E(a, prop, b[prop]);
713
- if (__getOwnPropSymbols$E)
714
- for (var prop of __getOwnPropSymbols$E(b)) {
715
- if (__propIsEnum$E.call(b, prop))
716
- __defNormalProp$E(a, prop, b[prop]);
714
+ if (__hasOwnProp$H.call(b, prop))
715
+ __defNormalProp$H(a, prop, b[prop]);
716
+ if (__getOwnPropSymbols$H)
717
+ for (var prop of __getOwnPropSymbols$H(b)) {
718
+ if (__propIsEnum$H.call(b, prop))
719
+ __defNormalProp$H(a, prop, b[prop]);
717
720
  }
718
721
  return a;
719
722
  };
@@ -731,7 +734,7 @@ class SceneTimeRange extends SceneObjectBase {
731
734
  state.UNSAFE_nowDelay
732
735
  );
733
736
  const refreshOnActivate = (_c = state.refreshOnActivate) != null ? _c : { percent: 10 };
734
- super(__spreadValues$E({ from, to, timeZone, value, refreshOnActivate }, state));
737
+ super(__spreadValues$H({ from, to, timeZone, value, refreshOnActivate }, state));
735
738
  this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["from", "to", "timezone"] });
736
739
  this.onTimeRangeChange = (timeRange) => {
737
740
  const update = {};
@@ -1398,25 +1401,25 @@ function collectAllVariables(sceneObject, record = {}) {
1398
1401
  return record;
1399
1402
  }
1400
1403
 
1401
- var __defProp$D = Object.defineProperty;
1402
- var __defProps$r = Object.defineProperties;
1403
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
1404
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
1405
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
1406
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
1407
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1408
- var __spreadValues$D = (a, b) => {
1404
+ var __defProp$G = Object.defineProperty;
1405
+ var __defProps$t = Object.defineProperties;
1406
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
1407
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
1408
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
1409
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
1410
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1411
+ var __spreadValues$G = (a, b) => {
1409
1412
  for (var prop in b || (b = {}))
1410
- if (__hasOwnProp$D.call(b, prop))
1411
- __defNormalProp$D(a, prop, b[prop]);
1412
- if (__getOwnPropSymbols$D)
1413
- for (var prop of __getOwnPropSymbols$D(b)) {
1414
- if (__propIsEnum$D.call(b, prop))
1415
- __defNormalProp$D(a, prop, b[prop]);
1413
+ if (__hasOwnProp$G.call(b, prop))
1414
+ __defNormalProp$G(a, prop, b[prop]);
1415
+ if (__getOwnPropSymbols$G)
1416
+ for (var prop of __getOwnPropSymbols$G(b)) {
1417
+ if (__propIsEnum$G.call(b, prop))
1418
+ __defNormalProp$G(a, prop, b[prop]);
1416
1419
  }
1417
1420
  return a;
1418
1421
  };
1419
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
1422
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
1420
1423
  function getTemplateProxyForField(field, frame, frames) {
1421
1424
  return new Proxy(
1422
1425
  {},
@@ -1432,7 +1435,7 @@ function getTemplateProxyForField(field, frame, frames) {
1432
1435
  if (!field.labels) {
1433
1436
  return "";
1434
1437
  }
1435
- return __spreadProps$r(__spreadValues$D({}, field.labels), {
1438
+ return __spreadProps$t(__spreadValues$G({}, field.labels), {
1436
1439
  __values: Object.values(field.labels).sort().join(", "),
1437
1440
  toString: () => {
1438
1441
  return data.formatLabels(field.labels, "", true);
@@ -1929,25 +1932,25 @@ function isExtraQueryProvider(obj) {
1929
1932
  return typeof obj === "object" && "getExtraQueries" in obj;
1930
1933
  }
1931
1934
 
1932
- var __defProp$C = Object.defineProperty;
1933
- var __defProps$q = Object.defineProperties;
1934
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1935
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
1936
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
1937
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
1938
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1939
- var __spreadValues$C = (a, b) => {
1935
+ var __defProp$F = Object.defineProperty;
1936
+ var __defProps$s = Object.defineProperties;
1937
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
1938
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
1939
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
1940
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
1941
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1942
+ var __spreadValues$F = (a, b) => {
1940
1943
  for (var prop in b || (b = {}))
1941
- if (__hasOwnProp$C.call(b, prop))
1942
- __defNormalProp$C(a, prop, b[prop]);
1943
- if (__getOwnPropSymbols$C)
1944
- for (var prop of __getOwnPropSymbols$C(b)) {
1945
- if (__propIsEnum$C.call(b, prop))
1946
- __defNormalProp$C(a, prop, b[prop]);
1944
+ if (__hasOwnProp$F.call(b, prop))
1945
+ __defNormalProp$F(a, prop, b[prop]);
1946
+ if (__getOwnPropSymbols$F)
1947
+ for (var prop of __getOwnPropSymbols$F(b)) {
1948
+ if (__propIsEnum$F.call(b, prop))
1949
+ __defNormalProp$F(a, prop, b[prop]);
1947
1950
  }
1948
1951
  return a;
1949
1952
  };
1950
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1953
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
1951
1954
  const passthroughProcessor = (_, secondary) => rxjs.of(secondary);
1952
1955
  const extraQueryProcessingOperator = (processors) => (data) => {
1953
1956
  return data.pipe(
@@ -1960,7 +1963,7 @@ const extraQueryProcessingOperator = (processors) => (data) => {
1960
1963
  }),
1961
1964
  rxjs.map(([primary, ...processedSecondaries]) => {
1962
1965
  var _a;
1963
- return __spreadProps$q(__spreadValues$C({}, primary), {
1966
+ return __spreadProps$s(__spreadValues$F({}, primary), {
1964
1967
  series: [...primary.series, ...processedSecondaries.flatMap((s) => s.series)],
1965
1968
  annotations: [...(_a = primary.annotations) != null ? _a : [], ...processedSecondaries.flatMap((s) => {
1966
1969
  var _a2;
@@ -1971,25 +1974,25 @@ const extraQueryProcessingOperator = (processors) => (data) => {
1971
1974
  );
1972
1975
  };
1973
1976
 
1974
- var __defProp$B = Object.defineProperty;
1975
- var __defProps$p = Object.defineProperties;
1976
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
1977
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
1978
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
1979
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
1980
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1981
- var __spreadValues$B = (a, b) => {
1977
+ var __defProp$E = Object.defineProperty;
1978
+ var __defProps$r = Object.defineProperties;
1979
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
1980
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
1981
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
1982
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
1983
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1984
+ var __spreadValues$E = (a, b) => {
1982
1985
  for (var prop in b || (b = {}))
1983
- if (__hasOwnProp$B.call(b, prop))
1984
- __defNormalProp$B(a, prop, b[prop]);
1985
- if (__getOwnPropSymbols$B)
1986
- for (var prop of __getOwnPropSymbols$B(b)) {
1987
- if (__propIsEnum$B.call(b, prop))
1988
- __defNormalProp$B(a, prop, b[prop]);
1986
+ if (__hasOwnProp$E.call(b, prop))
1987
+ __defNormalProp$E(a, prop, b[prop]);
1988
+ if (__getOwnPropSymbols$E)
1989
+ for (var prop of __getOwnPropSymbols$E(b)) {
1990
+ if (__propIsEnum$E.call(b, prop))
1991
+ __defNormalProp$E(a, prop, b[prop]);
1989
1992
  }
1990
1993
  return a;
1991
1994
  };
1992
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
1995
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
1993
1996
  function filterAnnotations(data, filters) {
1994
1997
  var _a;
1995
1998
  if (!Array.isArray(data) || data.length === 0) {
@@ -2040,11 +2043,11 @@ function filterAnnotations(data, filters) {
2040
2043
  continue;
2041
2044
  }
2042
2045
  }
2043
- fields.push(__spreadProps$p(__spreadValues$B({}, field), {
2046
+ fields.push(__spreadProps$r(__spreadValues$E({}, field), {
2044
2047
  values: buffer
2045
2048
  }));
2046
2049
  }
2047
- processed.push(__spreadProps$p(__spreadValues$B({}, frame), {
2050
+ processed.push(__spreadProps$r(__spreadValues$E({}, frame), {
2048
2051
  fields,
2049
2052
  length: frameLength
2050
2053
  }));
@@ -2475,33 +2478,33 @@ function getOptionSearcher(options, includeAll) {
2475
2478
  };
2476
2479
  }
2477
2480
 
2478
- var __defProp$A = Object.defineProperty;
2479
- var __defProps$o = Object.defineProperties;
2480
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
2481
- var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
2482
- var __hasOwnProp$A = Object.prototype.hasOwnProperty;
2483
- var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
2484
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2485
- var __spreadValues$A = (a, b) => {
2481
+ var __defProp$D = Object.defineProperty;
2482
+ var __defProps$q = Object.defineProperties;
2483
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
2484
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
2485
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
2486
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
2487
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2488
+ var __spreadValues$D = (a, b) => {
2486
2489
  for (var prop in b || (b = {}))
2487
- if (__hasOwnProp$A.call(b, prop))
2488
- __defNormalProp$A(a, prop, b[prop]);
2489
- if (__getOwnPropSymbols$A)
2490
- for (var prop of __getOwnPropSymbols$A(b)) {
2491
- if (__propIsEnum$A.call(b, prop))
2492
- __defNormalProp$A(a, prop, b[prop]);
2493
- }
2494
- return a;
2495
- };
2496
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
2497
- var __objRest$3 = (source, exclude) => {
2490
+ if (__hasOwnProp$D.call(b, prop))
2491
+ __defNormalProp$D(a, prop, b[prop]);
2492
+ if (__getOwnPropSymbols$D)
2493
+ for (var prop of __getOwnPropSymbols$D(b)) {
2494
+ if (__propIsEnum$D.call(b, prop))
2495
+ __defNormalProp$D(a, prop, b[prop]);
2496
+ }
2497
+ return a;
2498
+ };
2499
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
2500
+ var __objRest$4 = (source, exclude) => {
2498
2501
  var target = {};
2499
2502
  for (var prop in source)
2500
- if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
2503
+ if (__hasOwnProp$D.call(source, prop) && exclude.indexOf(prop) < 0)
2501
2504
  target[prop] = source[prop];
2502
- if (source != null && __getOwnPropSymbols$A)
2503
- for (var prop of __getOwnPropSymbols$A(source)) {
2504
- if (exclude.indexOf(prop) < 0 && __propIsEnum$A.call(source, prop))
2505
+ if (source != null && __getOwnPropSymbols$D)
2506
+ for (var prop of __getOwnPropSymbols$D(source)) {
2507
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$D.call(source, prop))
2505
2508
  target[prop] = source[prop];
2506
2509
  }
2507
2510
  return target;
@@ -2629,11 +2632,11 @@ const OptionWithCheckbox = ({
2629
2632
  renderOptionLabel
2630
2633
  }) => {
2631
2634
  var _b;
2632
- const _a = innerProps, rest = __objRest$3(_a, ["onMouseMove", "onMouseOver"]);
2635
+ const _a = innerProps, rest = __objRest$4(_a, ["onMouseMove", "onMouseOver"]);
2633
2636
  const theme = ui.useTheme2();
2634
2637
  const selectStyles = ui.getSelectStyles(theme);
2635
2638
  const optionStyles = ui.useStyles2(getOptionStyles);
2636
- return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({
2639
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$q(__spreadValues$D({
2637
2640
  ref: innerRef,
2638
2641
  className: css.cx(selectStyles.option, isFocused && selectStyles.optionFocused)
2639
2642
  }, rest), {
@@ -2797,28 +2800,28 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
2797
2800
  return { value: sceneObject, text: "__sceneObject" };
2798
2801
  }
2799
2802
 
2800
- var __defProp$z = Object.defineProperty;
2801
- var __defProps$n = Object.defineProperties;
2802
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
2803
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
2804
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
2805
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
2806
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2807
- var __spreadValues$z = (a, b) => {
2803
+ var __defProp$C = Object.defineProperty;
2804
+ var __defProps$p = Object.defineProperties;
2805
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2806
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
2807
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
2808
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
2809
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2810
+ var __spreadValues$C = (a, b) => {
2808
2811
  for (var prop in b || (b = {}))
2809
- if (__hasOwnProp$z.call(b, prop))
2810
- __defNormalProp$z(a, prop, b[prop]);
2811
- if (__getOwnPropSymbols$z)
2812
- for (var prop of __getOwnPropSymbols$z(b)) {
2813
- if (__propIsEnum$z.call(b, prop))
2814
- __defNormalProp$z(a, prop, b[prop]);
2812
+ if (__hasOwnProp$C.call(b, prop))
2813
+ __defNormalProp$C(a, prop, b[prop]);
2814
+ if (__getOwnPropSymbols$C)
2815
+ for (var prop of __getOwnPropSymbols$C(b)) {
2816
+ if (__propIsEnum$C.call(b, prop))
2817
+ __defNormalProp$C(a, prop, b[prop]);
2815
2818
  }
2816
2819
  return a;
2817
2820
  };
2818
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
2821
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2819
2822
  class GroupByVariable extends MultiValueVariable {
2820
2823
  constructor(initialState) {
2821
- super(__spreadProps$n(__spreadValues$z({
2824
+ super(__spreadProps$p(__spreadValues$C({
2822
2825
  isMulti: true,
2823
2826
  name: "",
2824
2827
  value: [],
@@ -2849,7 +2852,7 @@ class GroupByVariable extends MultiValueVariable {
2849
2852
  const queries = getQueriesForVariables(this);
2850
2853
  const otherFilters = this.state.baseFilters || [];
2851
2854
  const timeRange = sceneGraph.getTimeRange(this).state.value;
2852
- const response = await ds.getTagKeys(__spreadValues$z({
2855
+ const response = await ds.getTagKeys(__spreadValues$C({
2853
2856
  filters: otherFilters,
2854
2857
  queries,
2855
2858
  timeRange
@@ -3044,7 +3047,7 @@ function LoadingIndicator(props) {
3044
3047
  }
3045
3048
 
3046
3049
  function ControlsLabel(props) {
3047
- const styles = ui.useStyles2(getStyles$a);
3050
+ const styles = ui.useStyles2(getStyles$c);
3048
3051
  const theme = ui.useTheme2();
3049
3052
  const isVertical = props.layout === "vertical";
3050
3053
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3107,7 +3110,7 @@ function ControlsLabel(props) {
3107
3110
  }
3108
3111
  return labelElement;
3109
3112
  }
3110
- const getStyles$a = (theme) => ({
3113
+ const getStyles$c = (theme) => ({
3111
3114
  horizontalLabel: css.css({
3112
3115
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3113
3116
  display: `flex`,
@@ -3187,7 +3190,7 @@ function keyLabelToOption(key, label) {
3187
3190
  const filterNoOp = () => true;
3188
3191
  function AdHocFilterRenderer({ filter, model }) {
3189
3192
  var _a, _b;
3190
- const styles = ui.useStyles2(getStyles$9);
3193
+ const styles = ui.useStyles2(getStyles$b);
3191
3194
  const [keys, setKeys] = React.useState([]);
3192
3195
  const [values, setValues] = React.useState([]);
3193
3196
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3329,7 +3332,7 @@ function AdHocFilterRenderer({ filter, model }) {
3329
3332
  onClick: () => model._removeFilter(filter)
3330
3333
  }));
3331
3334
  }
3332
- const getStyles$9 = (theme) => ({
3335
+ const getStyles$b = (theme) => ({
3333
3336
  field: css.css({
3334
3337
  marginBottom: 0
3335
3338
  }),
@@ -3467,6 +3470,616 @@ function isFilter(filter) {
3467
3470
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3468
3471
  }
3469
3472
 
3473
+ var __defProp$B = Object.defineProperty;
3474
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3475
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3476
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3477
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3478
+ var __spreadValues$B = (a, b) => {
3479
+ for (var prop in b || (b = {}))
3480
+ if (__hasOwnProp$B.call(b, prop))
3481
+ __defNormalProp$B(a, prop, b[prop]);
3482
+ if (__getOwnPropSymbols$B)
3483
+ for (var prop of __getOwnPropSymbols$B(b)) {
3484
+ if (__propIsEnum$B.call(b, prop))
3485
+ __defNormalProp$B(a, prop, b[prop]);
3486
+ }
3487
+ return a;
3488
+ };
3489
+ var __objRest$3 = (source, exclude) => {
3490
+ var target = {};
3491
+ for (var prop in source)
3492
+ if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
3493
+ target[prop] = source[prop];
3494
+ if (source != null && __getOwnPropSymbols$B)
3495
+ for (var prop of __getOwnPropSymbols$B(source)) {
3496
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
3497
+ target[prop] = source[prop];
3498
+ }
3499
+ return target;
3500
+ };
3501
+ const DropdownItem = React.forwardRef(
3502
+ function DropdownItem2(_a, ref) {
3503
+ var _b = _a, { children, active } = _b, rest = __objRest$3(_b, ["children", "active"]);
3504
+ const theme = ui.useTheme2();
3505
+ const selectStyles = ui.getSelectStyles(theme);
3506
+ const id = React.useId();
3507
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
3508
+ ref,
3509
+ role: "option",
3510
+ id,
3511
+ "aria-selected": active,
3512
+ className: css.cx(selectStyles.option, active && selectStyles.optionFocused)
3513
+ }, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
3514
+ className: selectStyles.optionBody,
3515
+ "data-testid": `data-testid ad hoc filter option value ${children}`
3516
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
3517
+ }
3518
+ );
3519
+
3520
+ var __defProp$A = Object.defineProperty;
3521
+ var __defProps$o = Object.defineProperties;
3522
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
3523
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
3524
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
3525
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
3526
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3527
+ var __spreadValues$A = (a, b) => {
3528
+ for (var prop in b || (b = {}))
3529
+ if (__hasOwnProp$A.call(b, prop))
3530
+ __defNormalProp$A(a, prop, b[prop]);
3531
+ if (__getOwnPropSymbols$A)
3532
+ for (var prop of __getOwnPropSymbols$A(b)) {
3533
+ if (__propIsEnum$A.call(b, prop))
3534
+ __defNormalProp$A(a, prop, b[prop]);
3535
+ }
3536
+ return a;
3537
+ };
3538
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
3539
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
3540
+ var _a;
3541
+ const [open, setOpen] = React.useState(false);
3542
+ const [options, setOptions] = React.useState([]);
3543
+ const [optionsLoading, setOptionsLoading] = React.useState(false);
3544
+ const [optionsError, setOptionsError] = React.useState(false);
3545
+ const [inputValue, setInputValue] = React.useState("");
3546
+ const [activeIndex, setActiveIndex] = React.useState(null);
3547
+ const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
3548
+ const styles = ui.useStyles2(getStyles2);
3549
+ const listRef = React.useRef([]);
3550
+ const handleResetWip = React.useCallback(() => {
3551
+ if (isAlwaysWip) {
3552
+ model._addWip();
3553
+ setInputType("key");
3554
+ setInputValue("");
3555
+ }
3556
+ }, [model, isAlwaysWip]);
3557
+ const onOpenChange = React.useCallback(
3558
+ (nextOpen, _, reason) => {
3559
+ setOpen(nextOpen);
3560
+ if (["outside-press", "escape-key"].includes(reason || "")) {
3561
+ handleResetWip();
3562
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3563
+ }
3564
+ },
3565
+ [handleChangeViewMode, handleResetWip]
3566
+ );
3567
+ const operatorIdentifier = `${(_a = filter == null ? void 0 : filter.key) != null ? _a : ""}-operator`;
3568
+ const { refs, floatingStyles, context } = react.useFloating({
3569
+ whileElementsMounted: react.autoUpdate,
3570
+ open,
3571
+ onOpenChange,
3572
+ placement: "bottom-start",
3573
+ middleware: [
3574
+ react.offset(10),
3575
+ react.flip({ padding: 10 }),
3576
+ react.size({
3577
+ apply({ availableHeight, elements }) {
3578
+ elements.floating.style.maxHeight = `${availableHeight > 300 ? 300 : availableHeight}px`;
3579
+ },
3580
+ padding: 10
3581
+ })
3582
+ ]
3583
+ });
3584
+ const role = react.useRole(context, { role: "listbox" });
3585
+ const dismiss = react.useDismiss(context, {
3586
+ outsidePress: (event) => {
3587
+ return !event.currentTarget.classList.contains(
3588
+ operatorIdentifier
3589
+ );
3590
+ }
3591
+ });
3592
+ const listNav = react.useListNavigation(context, {
3593
+ listRef,
3594
+ activeIndex,
3595
+ onNavigate: setActiveIndex,
3596
+ virtual: true,
3597
+ loop: true
3598
+ });
3599
+ const { getReferenceProps, getFloatingProps, getItemProps } = react.useInteractions([role, dismiss, listNav]);
3600
+ React.useImperativeHandle(parentRef, () => () => {
3601
+ var _a2;
3602
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3603
+ }, [refs.domReference]);
3604
+ function onChange(event) {
3605
+ const value = event.target.value;
3606
+ setInputValue(value);
3607
+ setActiveIndex(0);
3608
+ }
3609
+ const filteredDropDownItems = options.filter(
3610
+ (item) => {
3611
+ var _a2, _b;
3612
+ return (_b = (_a2 = item.label) != null ? _a2 : item.value) == null ? void 0 : _b.toLocaleLowerCase().startsWith(inputValue.toLowerCase());
3613
+ }
3614
+ );
3615
+ const flushSyncInputType = React.useCallback((inputType) => {
3616
+ reactDom.flushSync(() => {
3617
+ setInputType(inputType);
3618
+ });
3619
+ }, []);
3620
+ React.useEffect(() => {
3621
+ if (!isAlwaysWip && refs.domReference.current) {
3622
+ setInputType("value");
3623
+ setInputValue("");
3624
+ refs.domReference.current.focus();
3625
+ }
3626
+ }, []);
3627
+ const handleFetchOptions = React.useCallback(
3628
+ async (inputType) => {
3629
+ setOptionsError(false);
3630
+ setOptionsLoading(true);
3631
+ setOptions([]);
3632
+ let options2 = [];
3633
+ try {
3634
+ if (inputType === "key") {
3635
+ options2 = await model._getKeys(null);
3636
+ } else if (inputType === "operator") {
3637
+ options2 = model._getOperators();
3638
+ } else if (inputType === "value") {
3639
+ options2 = await model._getValuesFor(filter);
3640
+ }
3641
+ setOptions(options2);
3642
+ } catch (e) {
3643
+ setOptionsError(true);
3644
+ }
3645
+ setOptionsLoading(false);
3646
+ },
3647
+ [filter, model]
3648
+ );
3649
+ const handleBackspaceInput = React.useCallback(
3650
+ (event) => {
3651
+ if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
3652
+ model._removeLastFilter();
3653
+ handleFetchOptions(filterInputType);
3654
+ }
3655
+ },
3656
+ [inputValue, filterInputType]
3657
+ );
3658
+ const handleTabInput = React.useCallback((event) => {
3659
+ if (event.key === "Tab" && !event.shiftKey) {
3660
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3661
+ handleResetWip();
3662
+ }
3663
+ }, []);
3664
+ const handleShiftTabInput = React.useCallback((event) => {
3665
+ if (event.key === "Tab" && event.shiftKey) {
3666
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3667
+ handleResetWip();
3668
+ }
3669
+ }, []);
3670
+ const handleEnterInput = React.useCallback(
3671
+ (event) => {
3672
+ var _a2;
3673
+ if (event.key === "Enter" && activeIndex != null) {
3674
+ if (filterInputType !== "value" && !filteredDropDownItems[activeIndex]) {
3675
+ return;
3676
+ }
3677
+ let dropdownItem = filteredDropDownItems[activeIndex];
3678
+ if (filterInputType === "value" && !filteredDropDownItems[activeIndex]) {
3679
+ if (!inputValue.trim()) {
3680
+ return;
3681
+ }
3682
+ dropdownItem = { value: inputValue };
3683
+ }
3684
+ model._updateFilter(filter, filterInputType, dropdownItem);
3685
+ setInputValue("");
3686
+ setActiveIndex(0);
3687
+ if (filterInputType === "key") {
3688
+ flushSyncInputType("operator");
3689
+ } else if (filterInputType === "operator") {
3690
+ flushSyncInputType("value");
3691
+ } else if (filterInputType === "value") {
3692
+ flushSyncInputType("key");
3693
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3694
+ }
3695
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3696
+ }
3697
+ },
3698
+ [activeIndex, filter, filterInputType, filteredDropDownItems, model]
3699
+ );
3700
+ React.useEffect(() => {
3701
+ if (open) {
3702
+ handleFetchOptions(filterInputType);
3703
+ }
3704
+ }, [open, filterInputType]);
3705
+ const rowVirtualizer = reactVirtual.useVirtualizer({
3706
+ count: filteredDropDownItems.length,
3707
+ getScrollElement: () => refs.floating.current,
3708
+ estimateSize: () => 38,
3709
+ overscan: 5
3710
+ });
3711
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3712
+ className: styles.comboboxWrapper
3713
+ }, filter ? /* @__PURE__ */ React__default["default"].createElement("div", {
3714
+ className: styles.pillWrapper
3715
+ }, (filter == null ? void 0 : filter.key) ? /* @__PURE__ */ React__default["default"].createElement("div", {
3716
+ className: css.cx(styles.basePill, styles.keyPill)
3717
+ }, filter.key) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && filterInputType !== "operator" ? /* @__PURE__ */ React__default["default"].createElement("div", {
3718
+ className: css.cx(styles.basePill, styles.operatorPill, operatorIdentifier),
3719
+ role: "button",
3720
+ "aria-label": "Edit filter operator",
3721
+ tabIndex: 0,
3722
+ onClick: (event) => {
3723
+ var _a2;
3724
+ event.stopPropagation();
3725
+ flushSyncInputType("operator");
3726
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3727
+ },
3728
+ onKeyDown: (event) => {
3729
+ var _a2;
3730
+ handleShiftTabInput(event);
3731
+ if (event.key === "Enter") {
3732
+ flushSyncInputType("operator");
3733
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3734
+ }
3735
+ }
3736
+ }, filter.operator) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && (filter == null ? void 0 : filter.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
3737
+ className: css.cx(styles.basePill, styles.valuePill)
3738
+ }, filter.value) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
3739
+ ref: refs.setReference,
3740
+ onChange,
3741
+ value: inputValue,
3742
+ placeholder: !isAlwaysWip ? filterInputType === "operator" ? `${filter[filterInputType]} ${filter.value || ""}` : filter[filterInputType] : "Filter by label values",
3743
+ "aria-autocomplete": "list",
3744
+ onKeyDown(event) {
3745
+ if (!open) {
3746
+ setOpen(true);
3747
+ return;
3748
+ }
3749
+ if (filterInputType === "operator") {
3750
+ handleShiftTabInput(event);
3751
+ }
3752
+ handleBackspaceInput(event);
3753
+ handleTabInput(event);
3754
+ handleEnterInput(event);
3755
+ }
3756
+ })), {
3757
+ className: styles.inputStyle,
3758
+ onClick: (event) => {
3759
+ event.stopPropagation();
3760
+ setOpen(true);
3761
+ },
3762
+ onFocus: () => {
3763
+ setActiveIndex(0);
3764
+ setOpen(true);
3765
+ }
3766
+ })), /* @__PURE__ */ React__default["default"].createElement(react.FloatingPortal, null, open && /* @__PURE__ */ React__default["default"].createElement(react.FloatingFocusManager, {
3767
+ context,
3768
+ initialFocus: -1,
3769
+ visuallyHiddenDismiss: true
3770
+ }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({}, getFloatingProps({
3771
+ ref: refs.setFloating,
3772
+ style: __spreadProps$o(__spreadValues$A({}, floatingStyles), {
3773
+ overflowY: "auto",
3774
+ zIndex: 1
3775
+ })
3776
+ })), {
3777
+ className: styles.dropdownWrapper
3778
+ }), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React__default["default"].createElement(OptionsErrorPlaceholder, {
3779
+ handleFetchOptions: () => handleFetchOptions(filterInputType)
3780
+ }) : !filteredDropDownItems.length && filterInputType !== "value" ? /* @__PURE__ */ React__default["default"].createElement(NoOptionsPlaceholder, null) : /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, rowVirtualizer.getVirtualItems().map((virtualItem) => {
3781
+ var _a2;
3782
+ const item = filteredDropDownItems[virtualItem.index];
3783
+ const index = virtualItem.index;
3784
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$o(__spreadValues$A({}, getItemProps({
3785
+ key: `${item.value}-${index}`,
3786
+ ref(node) {
3787
+ listRef.current[index] = node;
3788
+ },
3789
+ onClick(event) {
3790
+ var _a3;
3791
+ if (filterInputType !== "value") {
3792
+ event.stopPropagation();
3793
+ }
3794
+ model._updateFilter(filter, filterInputType, item);
3795
+ setInputValue("");
3796
+ if (filterInputType === "key") {
3797
+ flushSyncInputType("operator");
3798
+ } else if (filterInputType === "operator") {
3799
+ flushSyncInputType("value");
3800
+ } else if (filterInputType === "value") {
3801
+ flushSyncInputType("key");
3802
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3803
+ }
3804
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
3805
+ }
3806
+ })), {
3807
+ active: activeIndex === index
3808
+ }), (_a2 = item.label) != null ? _a2 : item.value);
3809
+ }), filterInputType === "value" && inputValue ? /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$o(__spreadValues$A({}, getItemProps({
3810
+ key: "__custom_value_list_item",
3811
+ ref(node) {
3812
+ listRef.current[filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0] = node;
3813
+ },
3814
+ onClick() {
3815
+ var _a2;
3816
+ model._updateFilter(filter, filterInputType, { value: inputValue });
3817
+ setInputValue("");
3818
+ flushSyncInputType("key");
3819
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3820
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3821
+ }
3822
+ })), {
3823
+ active: activeIndex === (filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0)
3824
+ }), "Use custom value: ", inputValue) : null)))));
3825
+ });
3826
+ const LoadingOptionsPlaceholder = () => {
3827
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3828
+ active: false
3829
+ }, "Loading options...");
3830
+ };
3831
+ const NoOptionsPlaceholder = () => {
3832
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3833
+ active: false
3834
+ }, "No options found");
3835
+ };
3836
+ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3837
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3838
+ active: false,
3839
+ onClick: handleFetchOptions
3840
+ }, "Error. Click to try again!");
3841
+ };
3842
+ const getStyles2 = (theme) => ({
3843
+ comboboxWrapper: css.css({
3844
+ display: "flex",
3845
+ flexWrap: "nowrap"
3846
+ }),
3847
+ pillWrapper: css.css({
3848
+ display: "flex",
3849
+ alignItems: "center",
3850
+ whiteSpace: "nowrap"
3851
+ }),
3852
+ basePill: css.css(__spreadProps$o(__spreadValues$A({
3853
+ display: "flex",
3854
+ alignItems: "center",
3855
+ background: theme.colors.action.disabledBackground,
3856
+ border: `1px solid ${theme.colors.border.weak}`,
3857
+ padding: theme.spacing(0.125, 1, 0.125, 1),
3858
+ color: theme.colors.text.primary,
3859
+ overflow: "hidden",
3860
+ whiteSpace: "nowrap",
3861
+ minHeight: "22px"
3862
+ }, theme.typography.bodySmall), {
3863
+ cursor: "pointer"
3864
+ })),
3865
+ keyPill: css.css({
3866
+ fontWeight: theme.typography.fontWeightBold,
3867
+ cursor: "default"
3868
+ }),
3869
+ operatorPill: css.css({
3870
+ "&:hover": {
3871
+ background: theme.colors.action.hover
3872
+ }
3873
+ }),
3874
+ valuePill: css.css({
3875
+ background: theme.colors.action.selected
3876
+ }),
3877
+ dropdownWrapper: css.css({
3878
+ backgroundColor: theme.colors.background.primary,
3879
+ color: theme.colors.text.primary,
3880
+ boxShadow: theme.shadows.z2
3881
+ }),
3882
+ inputStyle: css.css({
3883
+ paddingBlock: 0,
3884
+ "&:focus": {
3885
+ outline: "none"
3886
+ }
3887
+ })
3888
+ });
3889
+
3890
+ var __defProp$z = Object.defineProperty;
3891
+ var __defProps$n = Object.defineProperties;
3892
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
3893
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
3894
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
3895
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
3896
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3897
+ var __spreadValues$z = (a, b) => {
3898
+ for (var prop in b || (b = {}))
3899
+ if (__hasOwnProp$z.call(b, prop))
3900
+ __defNormalProp$z(a, prop, b[prop]);
3901
+ if (__getOwnPropSymbols$z)
3902
+ for (var prop of __getOwnPropSymbols$z(b)) {
3903
+ if (__propIsEnum$z.call(b, prop))
3904
+ __defNormalProp$z(a, prop, b[prop]);
3905
+ }
3906
+ return a;
3907
+ };
3908
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
3909
+ function AdHocFiltersComboboxEditSwitch({
3910
+ filter,
3911
+ model,
3912
+ readOnly
3913
+ }) {
3914
+ const styles = ui.useStyles2(getStyles$a);
3915
+ const [viewMode, setViewMode] = React.useState(true);
3916
+ const pillWrapperRef = React.useRef(null);
3917
+ const handleChangeViewMode = React.useCallback(
3918
+ (event) => {
3919
+ var _a;
3920
+ event == null ? void 0 : event.stopPropagation();
3921
+ if (readOnly) {
3922
+ return;
3923
+ }
3924
+ let viewMode2 = false;
3925
+ reactDom.flushSync(() => {
3926
+ setViewMode((mode) => {
3927
+ viewMode2 = mode;
3928
+ return !mode;
3929
+ });
3930
+ });
3931
+ if (!viewMode2) {
3932
+ (_a = pillWrapperRef.current) == null ? void 0 : _a.focus();
3933
+ }
3934
+ },
3935
+ [readOnly]
3936
+ );
3937
+ if (viewMode) {
3938
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3939
+ className: `${styles.combinedFilterPill} ${readOnly ? styles.readOnlyCombinedFilter : ""}`,
3940
+ onClick: handleChangeViewMode,
3941
+ onKeyDown: (e) => {
3942
+ if (e.key === "Enter") {
3943
+ handleChangeViewMode();
3944
+ }
3945
+ },
3946
+ role: "button",
3947
+ "aria-label": `Edit filter with key ${filter.key}`,
3948
+ tabIndex: 0,
3949
+ ref: pillWrapperRef
3950
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, filter.key, " ", filter.operator, " ", filter.value), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
3951
+ onClick: (e) => {
3952
+ e.stopPropagation();
3953
+ model._removeFilter(filter);
3954
+ },
3955
+ onKeyDownCapture: (e) => {
3956
+ if (e.key === "Enter") {
3957
+ e.preventDefault();
3958
+ e.stopPropagation();
3959
+ model._removeFilter(filter);
3960
+ }
3961
+ },
3962
+ name: "times",
3963
+ size: "md",
3964
+ className: styles.removeButton,
3965
+ tooltip: `Remove filter with key ${filter.key}`
3966
+ }) : null);
3967
+ }
3968
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
3969
+ filter,
3970
+ model,
3971
+ handleChangeViewMode
3972
+ });
3973
+ }
3974
+ const getStyles$a = (theme) => ({
3975
+ combinedFilterPill: css.css(__spreadProps$n(__spreadValues$z({
3976
+ display: "flex",
3977
+ alignItems: "center",
3978
+ background: theme.colors.action.selected,
3979
+ borderRadius: theme.shape.radius.default,
3980
+ border: `1px solid ${theme.colors.border.weak}`,
3981
+ padding: theme.spacing(0.125, 0, 0.125, 1),
3982
+ color: theme.colors.text.primary,
3983
+ overflow: "hidden",
3984
+ whiteSpace: "nowrap",
3985
+ minHeight: "22px"
3986
+ }, theme.typography.bodySmall), {
3987
+ fontWeight: theme.typography.fontWeightBold,
3988
+ cursor: "pointer",
3989
+ "&:hover": {
3990
+ background: theme.colors.action.hover
3991
+ }
3992
+ })),
3993
+ readOnlyCombinedFilter: css.css({
3994
+ paddingRight: theme.spacing(1),
3995
+ cursor: "text",
3996
+ "&:hover": {
3997
+ background: theme.colors.action.selected
3998
+ }
3999
+ }),
4000
+ removeButton: css.css({
4001
+ marginInline: theme.spacing(0.5),
4002
+ cursor: "pointer",
4003
+ "&:hover": {
4004
+ color: theme.colors.text.primary
4005
+ }
4006
+ })
4007
+ });
4008
+
4009
+ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({
4010
+ model
4011
+ }, parentRef) {
4012
+ const { _wip } = model.useState();
4013
+ React.useLayoutEffect(() => {
4014
+ if (!_wip) {
4015
+ model._addWip();
4016
+ }
4017
+ }, [_wip]);
4018
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
4019
+ model,
4020
+ filter: _wip,
4021
+ isAlwaysWip: true,
4022
+ ref: parentRef
4023
+ });
4024
+ });
4025
+
4026
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({
4027
+ model
4028
+ }) {
4029
+ const { filters, readOnly } = model.useState();
4030
+ const styles = ui.useStyles2(getStyles$9);
4031
+ const focusOnInputRef = React.useRef();
4032
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4033
+ className: `${styles.comboboxWrapper} ${!readOnly ? styles.comboboxFocusOutline : ""}`,
4034
+ onClick: () => {
4035
+ var _a;
4036
+ (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
4037
+ }
4038
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4039
+ name: "filter",
4040
+ className: styles.filterIcon,
4041
+ size: "lg"
4042
+ }), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxEditSwitch, {
4043
+ key: index,
4044
+ filter,
4045
+ model,
4046
+ readOnly
4047
+ })), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersAlwaysWipCombobox, {
4048
+ model,
4049
+ ref: focusOnInputRef
4050
+ }) : null);
4051
+ });
4052
+ const getStyles$9 = (theme) => ({
4053
+ comboboxWrapper: css.css({
4054
+ display: "flex",
4055
+ flexWrap: "wrap",
4056
+ alignItems: "center",
4057
+ columnGap: theme.spacing(1),
4058
+ rowGap: theme.spacing(0.5),
4059
+ minHeight: theme.spacing(4),
4060
+ backgroundColor: theme.components.input.background,
4061
+ border: `1px solid ${theme.colors.border.strong}`,
4062
+ borderRadius: theme.shape.radius.default,
4063
+ paddingInline: theme.spacing(1),
4064
+ paddingBlock: theme.spacing(0.5),
4065
+ flexGrow: 1
4066
+ }),
4067
+ comboboxFocusOutline: css.css({
4068
+ "&:focus-within": {
4069
+ outline: "2px dotted transparent",
4070
+ outlineOffset: "2px",
4071
+ boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,
4072
+ transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,
4073
+ transitionDuration: "0.2s",
4074
+ transitionProperty: "outline, outline-offset, box-shadow"
4075
+ }
4076
+ }),
4077
+ filterIcon: css.css({
4078
+ color: theme.colors.text.secondary,
4079
+ alignSelf: "center"
4080
+ })
4081
+ });
4082
+
3470
4083
  var __defProp$y = Object.defineProperty;
3471
4084
  var __defProps$m = Object.defineProperties;
3472
4085
  var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
@@ -3552,6 +4165,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
3552
4165
  }
3553
4166
  this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
3554
4167
  }
4168
+ _removeLastFilter() {
4169
+ const filterToRemove = this.state.filters.at(-1);
4170
+ if (filterToRemove) {
4171
+ this._removeFilter(filterToRemove);
4172
+ }
4173
+ }
3555
4174
  async _getKeys(currentKey) {
3556
4175
  var _a, _b, _c;
3557
4176
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
@@ -3633,6 +4252,11 @@ function renderExpression(builder, filters) {
3633
4252
  function AdHocFiltersVariableRenderer({ model }) {
3634
4253
  const { filters, readOnly, addFilterButtonText } = model.useState();
3635
4254
  const styles = ui.useStyles2(getStyles$8);
4255
+ if (model.state.layout === "combobox") {
4256
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
4257
+ model
4258
+ });
4259
+ }
3636
4260
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3637
4261
  className: styles.wrapper
3638
4262
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3653,10 +4277,6 @@ const getStyles$8 = (theme) => ({
3653
4277
  alignItems: "flex-end",
3654
4278
  columnGap: theme.spacing(2),
3655
4279
  rowGap: theme.spacing(1)
3656
- }),
3657
- filterIcon: css.css({
3658
- color: theme.colors.text.secondary,
3659
- paddingRight: theme.spacing(0.5)
3660
4280
  })
3661
4281
  });
3662
4282
  function toSelectableValue(input) {