@grafana/scenes 5.9.1 → 5.9.2--canary.830.10452071184.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 react = require('@floating-ui/react');
18
+ var reactDom = require('react-dom');
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), {
@@ -2772,28 +2775,28 @@ class SafeSerializableSceneObject {
2772
2775
  }
2773
2776
  _value = new WeakMap();
2774
2777
 
2775
- var __defProp$z = Object.defineProperty;
2776
- var __defProps$n = Object.defineProperties;
2777
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
2778
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
2779
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
2780
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
2781
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2782
- var __spreadValues$z = (a, b) => {
2778
+ var __defProp$C = Object.defineProperty;
2779
+ var __defProps$p = Object.defineProperties;
2780
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
2781
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
2782
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
2783
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
2784
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2785
+ var __spreadValues$C = (a, b) => {
2783
2786
  for (var prop in b || (b = {}))
2784
- if (__hasOwnProp$z.call(b, prop))
2785
- __defNormalProp$z(a, prop, b[prop]);
2786
- if (__getOwnPropSymbols$z)
2787
- for (var prop of __getOwnPropSymbols$z(b)) {
2788
- if (__propIsEnum$z.call(b, prop))
2789
- __defNormalProp$z(a, prop, b[prop]);
2787
+ if (__hasOwnProp$C.call(b, prop))
2788
+ __defNormalProp$C(a, prop, b[prop]);
2789
+ if (__getOwnPropSymbols$C)
2790
+ for (var prop of __getOwnPropSymbols$C(b)) {
2791
+ if (__propIsEnum$C.call(b, prop))
2792
+ __defNormalProp$C(a, prop, b[prop]);
2790
2793
  }
2791
2794
  return a;
2792
2795
  };
2793
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
2796
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
2794
2797
  class GroupByVariable extends MultiValueVariable {
2795
2798
  constructor(initialState) {
2796
- super(__spreadProps$n(__spreadValues$z({
2799
+ super(__spreadProps$p(__spreadValues$C({
2797
2800
  isMulti: true,
2798
2801
  name: "",
2799
2802
  value: [],
@@ -2824,7 +2827,7 @@ class GroupByVariable extends MultiValueVariable {
2824
2827
  const queries = getQueriesForVariables(this);
2825
2828
  const otherFilters = this.state.baseFilters || [];
2826
2829
  const timeRange = sceneGraph.getTimeRange(this).state.value;
2827
- const response = await ds.getTagKeys(__spreadValues$z({
2830
+ const response = await ds.getTagKeys(__spreadValues$C({
2828
2831
  filters: otherFilters,
2829
2832
  queries,
2830
2833
  timeRange
@@ -3019,7 +3022,7 @@ function LoadingIndicator(props) {
3019
3022
  }
3020
3023
 
3021
3024
  function ControlsLabel(props) {
3022
- const styles = ui.useStyles2(getStyles$a);
3025
+ const styles = ui.useStyles2(getStyles$c);
3023
3026
  const theme = ui.useTheme2();
3024
3027
  const isVertical = props.layout === "vertical";
3025
3028
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3082,7 +3085,7 @@ function ControlsLabel(props) {
3082
3085
  }
3083
3086
  return labelElement;
3084
3087
  }
3085
- const getStyles$a = (theme) => ({
3088
+ const getStyles$c = (theme) => ({
3086
3089
  horizontalLabel: css.css({
3087
3090
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3088
3091
  display: `flex`,
@@ -3162,7 +3165,7 @@ function keyLabelToOption(key, label) {
3162
3165
  const filterNoOp = () => true;
3163
3166
  function AdHocFilterRenderer({ filter, model }) {
3164
3167
  var _a, _b;
3165
- const styles = ui.useStyles2(getStyles$9);
3168
+ const styles = ui.useStyles2(getStyles$b);
3166
3169
  const [keys, setKeys] = React.useState([]);
3167
3170
  const [values, setValues] = React.useState([]);
3168
3171
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3304,7 +3307,7 @@ function AdHocFilterRenderer({ filter, model }) {
3304
3307
  onClick: () => model._removeFilter(filter)
3305
3308
  }));
3306
3309
  }
3307
- const getStyles$9 = (theme) => ({
3310
+ const getStyles$b = (theme) => ({
3308
3311
  field: css.css({
3309
3312
  marginBottom: 0
3310
3313
  }),
@@ -3442,6 +3445,590 @@ function isFilter(filter) {
3442
3445
  return filter !== null && typeof filter.key === "string" && typeof filter.value === "string";
3443
3446
  }
3444
3447
 
3448
+ var __defProp$B = Object.defineProperty;
3449
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
3450
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
3451
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
3452
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3453
+ var __spreadValues$B = (a, b) => {
3454
+ for (var prop in b || (b = {}))
3455
+ if (__hasOwnProp$B.call(b, prop))
3456
+ __defNormalProp$B(a, prop, b[prop]);
3457
+ if (__getOwnPropSymbols$B)
3458
+ for (var prop of __getOwnPropSymbols$B(b)) {
3459
+ if (__propIsEnum$B.call(b, prop))
3460
+ __defNormalProp$B(a, prop, b[prop]);
3461
+ }
3462
+ return a;
3463
+ };
3464
+ var __objRest$3 = (source, exclude) => {
3465
+ var target = {};
3466
+ for (var prop in source)
3467
+ if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
3468
+ target[prop] = source[prop];
3469
+ if (source != null && __getOwnPropSymbols$B)
3470
+ for (var prop of __getOwnPropSymbols$B(source)) {
3471
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
3472
+ target[prop] = source[prop];
3473
+ }
3474
+ return target;
3475
+ };
3476
+ const DropdownItem = React.forwardRef(
3477
+ function DropdownItem2(_a, ref) {
3478
+ var _b = _a, { children, active } = _b, rest = __objRest$3(_b, ["children", "active"]);
3479
+ const theme = ui.useTheme2();
3480
+ const selectStyles = ui.getSelectStyles(theme);
3481
+ const id = React.useId();
3482
+ return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
3483
+ ref,
3484
+ role: "option",
3485
+ id,
3486
+ "aria-selected": active,
3487
+ className: css.cx(selectStyles.option, active && selectStyles.optionFocused)
3488
+ }, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
3489
+ className: selectStyles.optionBody,
3490
+ "data-testid": `data-testid ad hoc filter option value ${children}`
3491
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
3492
+ }
3493
+ );
3494
+
3495
+ var __defProp$A = Object.defineProperty;
3496
+ var __defProps$o = Object.defineProperties;
3497
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
3498
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
3499
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
3500
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
3501
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3502
+ var __spreadValues$A = (a, b) => {
3503
+ for (var prop in b || (b = {}))
3504
+ if (__hasOwnProp$A.call(b, prop))
3505
+ __defNormalProp$A(a, prop, b[prop]);
3506
+ if (__getOwnPropSymbols$A)
3507
+ for (var prop of __getOwnPropSymbols$A(b)) {
3508
+ if (__propIsEnum$A.call(b, prop))
3509
+ __defNormalProp$A(a, prop, b[prop]);
3510
+ }
3511
+ return a;
3512
+ };
3513
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
3514
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
3515
+ var _a;
3516
+ const [open, setOpen] = React.useState(false);
3517
+ const [options, setOptions] = React.useState([]);
3518
+ const [optionsLoading, setOptionsLoading] = React.useState(false);
3519
+ const [optionsError, setOptionsError] = React.useState(false);
3520
+ const [inputValue, setInputValue] = React.useState("");
3521
+ const [activeIndex, setActiveIndex] = React.useState(null);
3522
+ const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
3523
+ const styles = ui.useStyles2(getStyles2);
3524
+ const listRef = React.useRef([]);
3525
+ const { _wip } = model.useState();
3526
+ const handleResetWip = React.useCallback(() => {
3527
+ if (isAlwaysWip) {
3528
+ model._addWip();
3529
+ setInputType("key");
3530
+ setInputValue("");
3531
+ }
3532
+ }, [model, isAlwaysWip]);
3533
+ const onOpenChange = React.useCallback(
3534
+ (nextOpen, _, reason) => {
3535
+ setOpen(nextOpen);
3536
+ if (["outside-press", "escape-key"].includes(reason || "")) {
3537
+ handleResetWip();
3538
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3539
+ }
3540
+ },
3541
+ [handleChangeViewMode, handleResetWip]
3542
+ );
3543
+ const filterToUse = filter || _wip;
3544
+ const operatorIdentifier = `${(_a = filterToUse == null ? void 0 : filterToUse.key) != null ? _a : ""}-operator`;
3545
+ const { refs, floatingStyles, context } = react.useFloating({
3546
+ whileElementsMounted: react.autoUpdate,
3547
+ open,
3548
+ onOpenChange,
3549
+ placement: "bottom-start",
3550
+ middleware: [
3551
+ react.offset(10),
3552
+ react.flip({ padding: 10 }),
3553
+ react.size({
3554
+ apply({ availableHeight, elements }) {
3555
+ elements.floating.style.maxHeight = `${availableHeight > 300 ? 300 : availableHeight}px`;
3556
+ },
3557
+ padding: 10
3558
+ })
3559
+ ]
3560
+ });
3561
+ const role = react.useRole(context, { role: "listbox" });
3562
+ const dismiss = react.useDismiss(context, {
3563
+ outsidePress: (event) => {
3564
+ return !event.currentTarget.classList.contains(
3565
+ operatorIdentifier
3566
+ );
3567
+ }
3568
+ });
3569
+ const listNav = react.useListNavigation(context, {
3570
+ listRef,
3571
+ activeIndex,
3572
+ onNavigate: setActiveIndex,
3573
+ virtual: true,
3574
+ loop: true
3575
+ });
3576
+ const { getReferenceProps, getFloatingProps, getItemProps } = react.useInteractions([role, dismiss, listNav]);
3577
+ React.useImperativeHandle(parentRef, () => () => {
3578
+ var _a2;
3579
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3580
+ }, [refs.domReference]);
3581
+ function onChange(event) {
3582
+ const value = event.target.value;
3583
+ setInputValue(value);
3584
+ setActiveIndex(0);
3585
+ }
3586
+ const filteredDropDownItems = options.filter(
3587
+ (item) => {
3588
+ var _a2, _b;
3589
+ return (_b = (_a2 = item.label) != null ? _a2 : item.value) == null ? void 0 : _b.toLocaleLowerCase().startsWith(inputValue.toLowerCase());
3590
+ }
3591
+ );
3592
+ const flushSyncInputType = React.useCallback((inputType) => {
3593
+ reactDom.flushSync(() => {
3594
+ setInputType(inputType);
3595
+ });
3596
+ }, []);
3597
+ React.useEffect(() => {
3598
+ if (isAlwaysWip && !_wip) {
3599
+ model._addWip();
3600
+ }
3601
+ }, [_wip]);
3602
+ React.useEffect(() => {
3603
+ if (!isAlwaysWip && refs.domReference.current) {
3604
+ setInputType("value");
3605
+ setInputValue("");
3606
+ refs.domReference.current.focus();
3607
+ }
3608
+ }, []);
3609
+ const handleFetchOptions = React.useCallback(
3610
+ async (inputType) => {
3611
+ setOptionsError(false);
3612
+ setOptionsLoading(true);
3613
+ setOptions([]);
3614
+ let options2 = [];
3615
+ try {
3616
+ if (inputType === "key") {
3617
+ options2 = await model._getKeys(null);
3618
+ } else if (inputType === "operator") {
3619
+ options2 = model._getOperators();
3620
+ } else if (inputType === "value") {
3621
+ options2 = await model._getValuesFor(filterToUse);
3622
+ }
3623
+ setOptions(options2);
3624
+ } catch (e) {
3625
+ setOptionsError(true);
3626
+ }
3627
+ setOptionsLoading(false);
3628
+ },
3629
+ [filterToUse, model]
3630
+ );
3631
+ const handleBackspaceInput = React.useCallback(
3632
+ (event) => {
3633
+ if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
3634
+ model._removeLastFilter();
3635
+ handleFetchOptions(filterInputType);
3636
+ }
3637
+ },
3638
+ [inputValue, filterInputType]
3639
+ );
3640
+ const handleTabInput = React.useCallback((event) => {
3641
+ if (event.key === "Tab" && !event.shiftKey) {
3642
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3643
+ handleResetWip();
3644
+ }
3645
+ }, []);
3646
+ const handleShiftTabInput = React.useCallback((event) => {
3647
+ if (event.key === "Tab" && event.shiftKey) {
3648
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3649
+ handleResetWip();
3650
+ }
3651
+ }, []);
3652
+ const handleEnterInput = React.useCallback(
3653
+ (event) => {
3654
+ var _a2;
3655
+ if (event.key === "Enter" && activeIndex != null) {
3656
+ if (filterInputType !== "value" && !filteredDropDownItems[activeIndex]) {
3657
+ return;
3658
+ }
3659
+ let dropdownItem = filteredDropDownItems[activeIndex];
3660
+ if (filterInputType === "value" && !filteredDropDownItems[activeIndex]) {
3661
+ if (!inputValue.trim()) {
3662
+ return;
3663
+ }
3664
+ dropdownItem = { value: inputValue };
3665
+ }
3666
+ model._updateFilter(filterToUse, filterInputType, dropdownItem);
3667
+ setInputValue("");
3668
+ setActiveIndex(0);
3669
+ if (filterInputType === "key") {
3670
+ flushSyncInputType("operator");
3671
+ } else if (filterInputType === "operator") {
3672
+ flushSyncInputType("value");
3673
+ } else if (filterInputType === "value") {
3674
+ flushSyncInputType("key");
3675
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3676
+ }
3677
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3678
+ }
3679
+ },
3680
+ [activeIndex, filterToUse, filterInputType, filteredDropDownItems, model]
3681
+ );
3682
+ React.useEffect(() => {
3683
+ if (open) {
3684
+ handleFetchOptions(filterInputType);
3685
+ }
3686
+ }, [open, filterInputType]);
3687
+ const rowVirtualizer = reactVirtual.useVirtualizer({
3688
+ count: filteredDropDownItems.length,
3689
+ getScrollElement: () => refs.floating.current,
3690
+ estimateSize: () => 38,
3691
+ overscan: 5
3692
+ });
3693
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3694
+ className: styles.comboboxWrapper
3695
+ }, filterToUse ? /* @__PURE__ */ React__default["default"].createElement("div", {
3696
+ className: styles.pillWrapper
3697
+ }, (filterToUse == null ? void 0 : filterToUse.key) ? /* @__PURE__ */ React__default["default"].createElement("div", {
3698
+ className: css.cx(styles.basePill, styles.keyPill)
3699
+ }, filterToUse.key) : null, (filterToUse == null ? void 0 : filterToUse.key) && (filterToUse == null ? void 0 : filterToUse.operator) && filterInputType !== "operator" ? /* @__PURE__ */ React__default["default"].createElement("div", {
3700
+ className: css.cx(styles.basePill, styles.operatorPill, operatorIdentifier),
3701
+ role: "button",
3702
+ "aria-label": "Edit filter operator",
3703
+ tabIndex: 0,
3704
+ onClick: (event) => {
3705
+ var _a2;
3706
+ event.stopPropagation();
3707
+ flushSyncInputType("operator");
3708
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3709
+ },
3710
+ onKeyDown: (event) => {
3711
+ var _a2;
3712
+ handleShiftTabInput(event);
3713
+ if (event.key === "Enter") {
3714
+ flushSyncInputType("operator");
3715
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3716
+ }
3717
+ }
3718
+ }, filterToUse.operator) : null, (filterToUse == null ? void 0 : filterToUse.key) && (filterToUse == null ? void 0 : filterToUse.operator) && (filterToUse == null ? void 0 : filterToUse.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
3719
+ className: css.cx(styles.basePill, styles.valuePill)
3720
+ }, filterToUse.value) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$o(__spreadValues$A({}, getReferenceProps({
3721
+ ref: refs.setReference,
3722
+ onChange,
3723
+ value: inputValue,
3724
+ placeholder: !isAlwaysWip ? filterInputType === "operator" ? `${filterToUse[filterInputType]} ${filterToUse.value || ""}` : filterToUse[filterInputType] : "Filter by label values",
3725
+ "aria-autocomplete": "list",
3726
+ onKeyDown(event) {
3727
+ if (!open) {
3728
+ setOpen(true);
3729
+ return;
3730
+ }
3731
+ if (filterInputType === "operator") {
3732
+ handleShiftTabInput(event);
3733
+ }
3734
+ handleBackspaceInput(event);
3735
+ handleTabInput(event);
3736
+ handleEnterInput(event);
3737
+ }
3738
+ })), {
3739
+ className: styles.inputStyle,
3740
+ onClick: (event) => {
3741
+ event.stopPropagation();
3742
+ setOpen(true);
3743
+ },
3744
+ onFocus: () => {
3745
+ setActiveIndex(0);
3746
+ setOpen(true);
3747
+ }
3748
+ })), /* @__PURE__ */ React__default["default"].createElement(react.FloatingPortal, null, open && /* @__PURE__ */ React__default["default"].createElement(react.FloatingFocusManager, {
3749
+ context,
3750
+ initialFocus: -1,
3751
+ visuallyHiddenDismiss: true
3752
+ }, /* @__PURE__ */ React__default["default"].createElement("div", __spreadProps$o(__spreadValues$A({}, getFloatingProps({
3753
+ ref: refs.setFloating,
3754
+ style: __spreadProps$o(__spreadValues$A({}, floatingStyles), {
3755
+ overflowY: "auto",
3756
+ zIndex: 1
3757
+ })
3758
+ })), {
3759
+ className: styles.dropdownWrapper
3760
+ }), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React__default["default"].createElement(OptionsErrorPlaceholder, {
3761
+ handleFetchOptions: () => handleFetchOptions(filterInputType)
3762
+ }) : !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) => {
3763
+ var _a2;
3764
+ const item = filteredDropDownItems[virtualItem.index];
3765
+ const index = virtualItem.index;
3766
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$o(__spreadValues$A({}, getItemProps({
3767
+ key: `${item.value}-${index}`,
3768
+ ref(node) {
3769
+ listRef.current[index] = node;
3770
+ },
3771
+ onClick(event) {
3772
+ var _a3;
3773
+ if (filterInputType !== "value") {
3774
+ event.stopPropagation();
3775
+ }
3776
+ model._updateFilter(filterToUse, filterInputType, item);
3777
+ setInputValue("");
3778
+ if (filterInputType === "key") {
3779
+ flushSyncInputType("operator");
3780
+ } else if (filterInputType === "operator") {
3781
+ flushSyncInputType("value");
3782
+ } else if (filterInputType === "value") {
3783
+ flushSyncInputType("key");
3784
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3785
+ }
3786
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
3787
+ }
3788
+ })), {
3789
+ active: activeIndex === index
3790
+ }), (_a2 = item.label) != null ? _a2 : item.value);
3791
+ }), filterInputType === "value" && inputValue ? /* @__PURE__ */ React__default["default"].createElement(DropdownItem, __spreadProps$o(__spreadValues$A({}, getItemProps({
3792
+ key: "__custom_value_list_item",
3793
+ ref(node) {
3794
+ listRef.current[filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0] = node;
3795
+ },
3796
+ onClick() {
3797
+ var _a2;
3798
+ model._updateFilter(filterToUse, filterInputType, { value: inputValue });
3799
+ setInputValue("");
3800
+ flushSyncInputType("key");
3801
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3802
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3803
+ }
3804
+ })), {
3805
+ active: activeIndex === (filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0)
3806
+ }), "Use custom value: ", inputValue) : null)))));
3807
+ });
3808
+ const LoadingOptionsPlaceholder = () => {
3809
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3810
+ active: false
3811
+ }, "Loading options...");
3812
+ };
3813
+ const NoOptionsPlaceholder = () => {
3814
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3815
+ active: false
3816
+ }, "No options found");
3817
+ };
3818
+ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3819
+ return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
3820
+ active: false,
3821
+ onClick: handleFetchOptions
3822
+ }, "Error. Click to try again!");
3823
+ };
3824
+ const getStyles2 = (theme) => ({
3825
+ comboboxWrapper: css.css({
3826
+ display: "flex",
3827
+ flexWrap: "nowrap"
3828
+ }),
3829
+ pillWrapper: css.css({
3830
+ display: "flex",
3831
+ alignItems: "center",
3832
+ whiteSpace: "nowrap"
3833
+ }),
3834
+ basePill: css.css(__spreadProps$o(__spreadValues$A({
3835
+ display: "flex",
3836
+ alignItems: "center",
3837
+ background: theme.colors.action.disabledBackground,
3838
+ border: `1px solid ${theme.colors.border.weak}`,
3839
+ padding: theme.spacing(0.125, 1, 0.125, 1),
3840
+ color: theme.colors.text.primary,
3841
+ overflow: "hidden",
3842
+ whiteSpace: "nowrap",
3843
+ minHeight: "22px"
3844
+ }, theme.typography.bodySmall), {
3845
+ cursor: "pointer"
3846
+ })),
3847
+ keyPill: css.css({
3848
+ fontWeight: theme.typography.fontWeightBold,
3849
+ cursor: "default"
3850
+ }),
3851
+ operatorPill: css.css({
3852
+ "&:hover": {
3853
+ background: theme.colors.action.hover
3854
+ }
3855
+ }),
3856
+ valuePill: css.css({
3857
+ background: theme.colors.action.selected
3858
+ }),
3859
+ dropdownWrapper: css.css({
3860
+ backgroundColor: theme.colors.background.primary,
3861
+ color: theme.colors.text.primary,
3862
+ boxShadow: theme.shadows.z2
3863
+ }),
3864
+ inputStyle: css.css({
3865
+ paddingBlock: 0,
3866
+ "&:focus": {
3867
+ outline: "none"
3868
+ }
3869
+ })
3870
+ });
3871
+
3872
+ var __defProp$z = Object.defineProperty;
3873
+ var __defProps$n = Object.defineProperties;
3874
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
3875
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
3876
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
3877
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
3878
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3879
+ var __spreadValues$z = (a, b) => {
3880
+ for (var prop in b || (b = {}))
3881
+ if (__hasOwnProp$z.call(b, prop))
3882
+ __defNormalProp$z(a, prop, b[prop]);
3883
+ if (__getOwnPropSymbols$z)
3884
+ for (var prop of __getOwnPropSymbols$z(b)) {
3885
+ if (__propIsEnum$z.call(b, prop))
3886
+ __defNormalProp$z(a, prop, b[prop]);
3887
+ }
3888
+ return a;
3889
+ };
3890
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
3891
+ function AdHocFiltersComboboxEditSwitch({
3892
+ filter,
3893
+ model
3894
+ }) {
3895
+ const styles = ui.useStyles2(getStyles$a);
3896
+ const [viewMode, setViewMode] = React.useState(true);
3897
+ const pillWrapperRef = React.useRef(null);
3898
+ const handleChangeViewMode = React.useCallback((event) => {
3899
+ var _a;
3900
+ event == null ? void 0 : event.stopPropagation();
3901
+ let viewMode2 = false;
3902
+ reactDom.flushSync(() => {
3903
+ setViewMode((mode) => {
3904
+ viewMode2 = mode;
3905
+ return !mode;
3906
+ });
3907
+ });
3908
+ if (!viewMode2) {
3909
+ (_a = pillWrapperRef.current) == null ? void 0 : _a.focus();
3910
+ }
3911
+ }, []);
3912
+ if (viewMode) {
3913
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3914
+ className: styles.combinedFilterPill,
3915
+ onClick: handleChangeViewMode,
3916
+ onKeyDown: (e) => {
3917
+ if (e.key === "Enter") {
3918
+ handleChangeViewMode();
3919
+ }
3920
+ },
3921
+ role: "button",
3922
+ "aria-label": `Edit filter with key ${filter.key}`,
3923
+ tabIndex: 0,
3924
+ ref: pillWrapperRef
3925
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, filter.key, " ", filter.operator, " ", filter.value), /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
3926
+ onClick: (e) => {
3927
+ e.stopPropagation();
3928
+ model._removeFilter(filter);
3929
+ },
3930
+ onKeyDownCapture: (e) => {
3931
+ if (e.key === "Enter") {
3932
+ e.preventDefault();
3933
+ e.stopPropagation();
3934
+ model._removeFilter(filter);
3935
+ }
3936
+ },
3937
+ name: "times",
3938
+ size: "md",
3939
+ className: styles.removeButton,
3940
+ tooltip: `Remove filter with key ${filter.key}`
3941
+ }));
3942
+ }
3943
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
3944
+ filter,
3945
+ model,
3946
+ handleChangeViewMode
3947
+ });
3948
+ }
3949
+ const getStyles$a = (theme) => ({
3950
+ combinedFilterPill: css.css(__spreadProps$n(__spreadValues$z({
3951
+ display: "flex",
3952
+ alignItems: "center",
3953
+ background: theme.colors.action.selected,
3954
+ borderRadius: theme.shape.radius.default,
3955
+ border: `1px solid ${theme.colors.border.weak}`,
3956
+ padding: theme.spacing(0.125, 0, 0.125, 1),
3957
+ color: theme.colors.text.primary,
3958
+ overflow: "hidden",
3959
+ whiteSpace: "nowrap",
3960
+ minHeight: "22px"
3961
+ }, theme.typography.bodySmall), {
3962
+ fontWeight: theme.typography.fontWeightBold,
3963
+ cursor: "pointer",
3964
+ "&:hover": {
3965
+ background: theme.colors.action.hover
3966
+ }
3967
+ })),
3968
+ removeButton: css.css({
3969
+ marginInline: theme.spacing(0.5),
3970
+ cursor: "pointer",
3971
+ "&:hover": {
3972
+ color: theme.colors.text.primary
3973
+ }
3974
+ })
3975
+ });
3976
+
3977
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({
3978
+ model
3979
+ }) {
3980
+ const { filters } = model.useState();
3981
+ const styles = ui.useStyles2(getStyles$9);
3982
+ const focusOnInputRef = React.useRef();
3983
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3984
+ className: styles.comboboxWrapper,
3985
+ onClick: () => {
3986
+ var _a;
3987
+ (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
3988
+ }
3989
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
3990
+ name: "filter",
3991
+ className: styles.filterIcon,
3992
+ size: "lg"
3993
+ }), filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxEditSwitch, {
3994
+ key: index,
3995
+ filter,
3996
+ model
3997
+ })), /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
3998
+ model,
3999
+ isAlwaysWip: true,
4000
+ ref: focusOnInputRef
4001
+ }));
4002
+ });
4003
+ const getStyles$9 = (theme) => ({
4004
+ comboboxWrapper: css.css({
4005
+ display: "flex",
4006
+ flexWrap: "wrap",
4007
+ alignItems: "center",
4008
+ columnGap: theme.spacing(1),
4009
+ rowGap: theme.spacing(0.5),
4010
+ minHeight: theme.spacing(4),
4011
+ backgroundColor: theme.components.input.background,
4012
+ border: `1px solid ${theme.colors.border.strong}`,
4013
+ borderRadius: theme.shape.radius.default,
4014
+ paddingInline: theme.spacing(1),
4015
+ paddingBlock: theme.spacing(0.5),
4016
+ flexGrow: 1,
4017
+ "&:focus-within": {
4018
+ outline: "2px dotted transparent",
4019
+ outlineOffset: "2px",
4020
+ boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,
4021
+ transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,
4022
+ transitionDuration: "0.2s",
4023
+ transitionProperty: "outline, outline-offset, box-shadow"
4024
+ }
4025
+ }),
4026
+ filterIcon: css.css({
4027
+ color: theme.colors.text.secondary,
4028
+ alignSelf: "center"
4029
+ })
4030
+ });
4031
+
3445
4032
  var __defProp$y = Object.defineProperty;
3446
4033
  var __defProps$m = Object.defineProperties;
3447
4034
  var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
@@ -3527,6 +4114,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
3527
4114
  }
3528
4115
  this.setState({ filters: this.state.filters.filter((f) => f !== filter) });
3529
4116
  }
4117
+ _removeLastFilter() {
4118
+ const filterToRemove = this.state.filters.at(-1);
4119
+ if (filterToRemove) {
4120
+ this._removeFilter(filterToRemove);
4121
+ }
4122
+ }
3530
4123
  async _getKeys(currentKey) {
3531
4124
  var _a, _b, _c;
3532
4125
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
@@ -3608,6 +4201,11 @@ function renderExpression(builder, filters) {
3608
4201
  function AdHocFiltersVariableRenderer({ model }) {
3609
4202
  const { filters, readOnly, addFilterButtonText } = model.useState();
3610
4203
  const styles = ui.useStyles2(getStyles$8);
4204
+ if (model.state.layout === "combobox") {
4205
+ return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
4206
+ model
4207
+ });
4208
+ }
3611
4209
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3612
4210
  className: styles.wrapper
3613
4211
  }, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
@@ -3628,10 +4226,6 @@ const getStyles$8 = (theme) => ({
3628
4226
  alignItems: "flex-end",
3629
4227
  columnGap: theme.spacing(2),
3630
4228
  rowGap: theme.spacing(1)
3631
- }),
3632
- filterIcon: css.css({
3633
- color: theme.colors.text.secondary,
3634
- paddingRight: theme.spacing(0.5)
3635
4229
  })
3636
4230
  });
3637
4231
  function toSelectableValue(input) {