@grafana/scenes 6.40.0--canary.1272.18407272616.0 → 6.40.0--canary.1277.18545717336.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/esm/behaviors/SceneRenderProfiler.js +0 -6
  3. package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -1
  4. package/dist/esm/components/SceneTimeRangeCompare.js +17 -14
  5. package/dist/esm/components/SceneTimeRangeCompare.js.map +1 -1
  6. package/dist/esm/index.js +0 -2
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/querying/SceneDataTransformer.js +23 -16
  9. package/dist/esm/querying/SceneDataTransformer.js.map +1 -1
  10. package/dist/esm/variables/adhoc/AdHocFilterBuilder.js +13 -2
  11. package/dist/esm/variables/adhoc/AdHocFilterBuilder.js.map +1 -1
  12. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js +6 -0
  13. package/dist/esm/variables/adhoc/AdHocFilterRenderer.js.map +1 -1
  14. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +10 -10
  15. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
  16. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersAlwaysWipCombobox.js +6 -6
  17. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersAlwaysWipCombobox.js.map +1 -1
  18. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +54 -56
  19. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
  20. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js +5 -5
  21. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js.map +1 -1
  22. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +4 -4
  23. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
  24. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +2 -4
  25. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  26. package/dist/index.d.ts +6 -121
  27. package/dist/index.js +141 -188
  28. package/dist/index.js.map +1 -1
  29. package/package.json +2 -2
  30. package/dist/esm/variables/adhoc/controller/VariableBackedAdHocFiltersController.js +0 -65
  31. package/dist/esm/variables/adhoc/controller/VariableBackedAdHocFiltersController.js.map +0 -1
package/dist/index.js CHANGED
@@ -1061,7 +1061,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1061
1061
  var _profileInProgress, _interactionInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans, _longFrameDetector, _longFramesCount, _longFramesTotalTime, _visibilityChangeHandler, _onInteractionComplete;
1062
1062
  const POST_STORM_WINDOW = 2e3;
1063
1063
  const DEFAULT_LONG_FRAME_THRESHOLD = 30;
1064
- const TAB_INACTIVE_THRESHOLD = 1e3;
1065
1064
  class SceneRenderProfiler {
1066
1065
  constructor(queryController) {
1067
1066
  this.queryController = queryController;
@@ -1081,11 +1080,6 @@ class SceneRenderProfiler {
1081
1080
  var _a, _b, _c, _d;
1082
1081
  const currentFrameTime = performance.now();
1083
1082
  const frameLength = currentFrameTime - lastFrameTime;
1084
- if (frameLength > TAB_INACTIVE_THRESHOLD) {
1085
- writeSceneLog("SceneRenderProfiler", "Tab was inactive, cancelling profile measurement");
1086
- this.cancelProfile();
1087
- return;
1088
- }
1089
1083
  __privateGet$2(this, _recordedTrailingSpans).push(frameLength);
1090
1084
  if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
1091
1085
  if (__privateGet$2(this, _profileInProgress)) {
@@ -3603,7 +3597,7 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
3603
3597
  function DefaultGroupByCustomIndicatorContainer(props) {
3604
3598
  const { model } = props;
3605
3599
  const theme = ui.useTheme2();
3606
- const styles = getStyles$i(theme);
3600
+ const styles = getStyles$j(theme);
3607
3601
  const inputStyles = ui.getInputStyles({ theme, invalid: false });
3608
3602
  const value = lodash.isArray(model.state.value) ? model.state.value : model.state.value ? [model.state.value] : [];
3609
3603
  let buttons = [];
@@ -3685,7 +3679,7 @@ function DefaultGroupByCustomIndicatorContainer(props) {
3685
3679
  buttons
3686
3680
  );
3687
3681
  }
3688
- const getStyles$i = (theme) => ({
3682
+ const getStyles$j = (theme) => ({
3689
3683
  clearIcon: css.css({
3690
3684
  color: theme.colors.action.disabledText,
3691
3685
  cursor: "pointer",
@@ -4206,7 +4200,7 @@ function LoadingIndicator(props) {
4206
4200
  }
4207
4201
 
4208
4202
  function ControlsLabel(props) {
4209
- const styles = ui.useStyles2(getStyles$h);
4203
+ const styles = ui.useStyles2(getStyles$i);
4210
4204
  const theme = ui.useTheme2();
4211
4205
  const isVertical = props.layout === "vertical";
4212
4206
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default.default.createElement(
@@ -4253,7 +4247,7 @@ function ControlsLabel(props) {
4253
4247
  }
4254
4248
  return labelElement;
4255
4249
  }
4256
- const getStyles$h = (theme) => ({
4250
+ const getStyles$i = (theme) => ({
4257
4251
  horizontalLabel: css.css({
4258
4252
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
4259
4253
  display: `flex`,
@@ -4306,7 +4300,7 @@ function keyLabelToOption(key, label) {
4306
4300
  const filterNoOp = () => true;
4307
4301
  function AdHocFilterRenderer({ filter, model }) {
4308
4302
  var _a, _b, _c, _d, _e;
4309
- const styles = ui.useStyles2(getStyles$g);
4303
+ const styles = ui.useStyles2(getStyles$h);
4310
4304
  const [keys, setKeys] = React.useState([]);
4311
4305
  const [values, setValues] = React.useState([]);
4312
4306
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -4533,12 +4527,18 @@ function AdHocFilterRenderer({ filter, model }) {
4533
4527
  }
4534
4528
  ));
4535
4529
  }
4536
- const getStyles$g = (theme) => ({
4530
+ const getStyles$h = (theme) => ({
4537
4531
  field: css.css({
4538
4532
  marginBottom: 0
4539
4533
  }),
4540
4534
  wrapper: css.css({
4541
4535
  display: "flex",
4536
+ "&:first-child": {
4537
+ "> :first-child": {
4538
+ borderBottomLeftRadius: 0,
4539
+ borderTopLeftRadius: 0
4540
+ }
4541
+ },
4542
4542
  "> *": {
4543
4543
  "&:not(:first-child)": {
4544
4544
  // Negative margin hides the double-border on adjacent selects
@@ -4600,6 +4600,7 @@ const getStyles$g = (theme) => ({
4600
4600
 
4601
4601
  function AdHocFilterBuilder({ model, addFilterButtonText }) {
4602
4602
  const { _wip } = model.useState();
4603
+ const styles = ui.useStyles2(getStyles$g);
4603
4604
  if (!_wip) {
4604
4605
  return /* @__PURE__ */ React__default.default.createElement(
4605
4606
  ui.Button,
@@ -4609,13 +4610,22 @@ function AdHocFilterBuilder({ model, addFilterButtonText }) {
4609
4610
  title: i18n.t("grafana-scenes.variables.ad-hoc-filter-builder.title-add-filter", "Add filter"),
4610
4611
  "aria-label": i18n.t("grafana-scenes.variables.ad-hoc-filter-builder.aria-label-add-filter", "Add filter"),
4611
4612
  "data-testid": `AdHocFilter-add`,
4612
- onClick: () => model._addWip()
4613
+ onClick: () => model._addWip(),
4614
+ className: styles.addButton
4613
4615
  },
4614
4616
  addFilterButtonText
4615
4617
  );
4616
4618
  }
4617
4619
  return /* @__PURE__ */ React__default.default.createElement(AdHocFilterRenderer, { filter: _wip, model });
4618
4620
  }
4621
+ const getStyles$g = (theme) => ({
4622
+ addButton: css.css({
4623
+ "&:first-child": {
4624
+ borderBottomLeftRadius: 0,
4625
+ borderTopLeftRadius: 0
4626
+ }
4627
+ })
4628
+ });
4619
4629
 
4620
4630
  class AdHocFiltersVariableUrlSyncHandler {
4621
4631
  constructor(_variable) {
@@ -4939,11 +4949,11 @@ const generateFilterUpdatePayload = ({
4939
4949
  [filterInputType]: item.value
4940
4950
  };
4941
4951
  };
4942
- const INPUT_PLACEHOLDER_DEFAULT = "Filter by label values";
4943
- const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlwaysWip, inputPlaceholder) => {
4952
+ const INPUT_PLACEHOLDER = "Filter by label values";
4953
+ const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlwaysWip) => {
4944
4954
  var _a;
4945
4955
  if (filterInputType === "key") {
4946
- return inputPlaceholder || INPUT_PLACEHOLDER_DEFAULT;
4956
+ return INPUT_PLACEHOLDER;
4947
4957
  }
4948
4958
  if (filterInputType === "value") {
4949
4959
  if (isMultiValueEdit) {
@@ -4951,7 +4961,7 @@ const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlways
4951
4961
  }
4952
4962
  return ((_a = filter.valueLabels) == null ? void 0 : _a[0]) || "";
4953
4963
  }
4954
- return filter[filterInputType] && !isAlwaysWip ? `${filter[filterInputType]}` : inputPlaceholder || INPUT_PLACEHOLDER_DEFAULT;
4964
+ return filter[filterInputType] && !isAlwaysWip ? `${filter[filterInputType]}` : INPUT_PLACEHOLDER;
4955
4965
  };
4956
4966
  const populateInputValueOnInputTypeSwitch = ({
4957
4967
  populateInputOnEdit,
@@ -5133,15 +5143,8 @@ const getStyles$e = (theme) => ({
5133
5143
  })
5134
5144
  });
5135
5145
 
5136
- const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5137
- filter,
5138
- controller,
5139
- isAlwaysWip,
5140
- handleChangeViewMode,
5141
- focusOnWipInputRef,
5142
- populateInputOnEdit
5143
- }, parentRef) {
5144
- var _a, _b, _c;
5146
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef, populateInputOnEdit }, parentRef) {
5147
+ var _a, _b, _c, _d;
5145
5148
  const [open, setOpen] = React.useState(false);
5146
5149
  const [options, setOptions] = React.useState([]);
5147
5150
  const [optionsLoading, setOptionsLoading] = React.useState(false);
@@ -5153,7 +5156,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5153
5156
  const styles = ui.useStyles2(getStyles$d);
5154
5157
  const [filterMultiValues, setFilterMultiValues] = React.useState([]);
5155
5158
  const [_, setForceRefresh] = React.useState({});
5156
- const { allowCustomValue = true, onAddCustomValue, filters, inputPlaceholder } = controller.useState();
5159
+ const allowCustomValue = (_a = model.state.allowCustomValue) != null ? _a : true;
5157
5160
  const multiValuePillWrapperRef = React.useRef(null);
5158
5161
  const hasMultiValueOperator = isMultiValueOperator((filter == null ? void 0 : filter.operator) || "");
5159
5162
  const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
@@ -5166,30 +5169,29 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5166
5169
  if (isAlwaysWip) {
5167
5170
  return false;
5168
5171
  }
5169
- if (filters.at(-1) === filter) {
5172
+ if (model.state.filters.at(-1) === filter) {
5170
5173
  return true;
5171
5174
  }
5172
5175
  return false;
5173
- }, [filter, isAlwaysWip, filters]);
5176
+ }, [filter, isAlwaysWip, model.state.filters]);
5174
5177
  const handleResetWip = React.useCallback(() => {
5175
5178
  if (isAlwaysWip) {
5176
- controller.addWip();
5179
+ model._addWip();
5177
5180
  setInputType("key");
5178
5181
  setInputValue("");
5179
5182
  }
5180
- }, [controller, isAlwaysWip]);
5183
+ }, [model, isAlwaysWip]);
5181
5184
  const handleMultiValueFilterCommit = React.useCallback(
5182
- (controller2, filter2, filterMultiValues2, preventFocus) => {
5183
- var _a2;
5185
+ (model2, filter2, filterMultiValues2, preventFocus) => {
5184
5186
  if (!filterMultiValues2.length && filter2.origin) {
5185
- controller2.updateToMatchAll(filter2);
5187
+ model2.updateToMatchAll(filter2);
5186
5188
  }
5187
5189
  if (filterMultiValues2.length) {
5188
5190
  const valueLabels = [];
5189
5191
  const values = [];
5190
5192
  filterMultiValues2.forEach((item) => {
5191
- var _a3;
5192
- valueLabels.push((_a3 = item.label) != null ? _a3 : item.value);
5193
+ var _a2;
5194
+ valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
5193
5195
  values.push(item.value);
5194
5196
  });
5195
5197
  let shouldUpdate = true;
@@ -5197,15 +5199,16 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5197
5199
  shouldUpdate = !filter2.values.every((v, i) => v === values[i]);
5198
5200
  }
5199
5201
  if (shouldUpdate) {
5200
- (_a2 = controller2.startProfile) == null ? void 0 : _a2.call(controller2, FILTER_CHANGED_INTERACTION);
5202
+ const queryController = getQueryController(model2);
5203
+ queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
5201
5204
  }
5202
- controller2.updateFilter(filter2, { valueLabels, values, value: values[0] });
5205
+ model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
5203
5206
  setFilterMultiValues([]);
5204
5207
  }
5205
5208
  if (!preventFocus) {
5206
5209
  setTimeout(() => {
5207
- var _a3;
5208
- return (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
5210
+ var _a2;
5211
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
5209
5212
  });
5210
5213
  }
5211
5214
  },
@@ -5225,10 +5228,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5225
5228
  setOpen(nextOpen);
5226
5229
  if (reason && ["outside-press", "escape-key"].includes(reason)) {
5227
5230
  if (isMultiValueEdit) {
5228
- handleMultiValueFilterCommit(controller, filter, filterMultiValues);
5231
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
5229
5232
  } else {
5230
5233
  if (filter && filter.origin && inputValue === "") {
5231
- controller.updateToMatchAll(filter);
5234
+ model.updateToMatchAll(filter);
5232
5235
  }
5233
5236
  }
5234
5237
  handleResetWip();
@@ -5243,7 +5246,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5243
5246
  handleResetWip,
5244
5247
  inputValue,
5245
5248
  isMultiValueEdit,
5246
- controller
5249
+ model
5247
5250
  ]
5248
5251
  );
5249
5252
  const outsidePressIdsToIgnore = React.useMemo(() => {
@@ -5302,13 +5305,15 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5302
5305
  filteredDropDownItems.push(customOptionValue);
5303
5306
  }
5304
5307
  }
5308
+ const onAddCustomValue = model.state.onAddCustomValue;
5305
5309
  const maxOptionWidth = setupDropdownAccessibility(filteredDropDownItems, listRef, disabledIndicesRef);
5306
5310
  const handleFetchOptions = React.useCallback(
5307
5311
  async (inputType) => {
5308
- var _a2, _b2, _c2, _d;
5312
+ var _a2;
5313
+ const profiler = getInteractionTracker(model);
5309
5314
  const interactionName = inputType === "key" ? ADHOC_KEYS_DROPDOWN_INTERACTION : ADHOC_VALUES_DROPDOWN_INTERACTION;
5310
5315
  if (inputType !== "operator") {
5311
- (_a2 = controller.startInteraction) == null ? void 0 : _a2.call(controller, interactionName);
5316
+ profiler == null ? void 0 : profiler.startInteraction(interactionName);
5312
5317
  }
5313
5318
  setOptionsError(false);
5314
5319
  setOptionsLoading(true);
@@ -5316,18 +5321,18 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5316
5321
  let options2 = [];
5317
5322
  try {
5318
5323
  if (inputType === "key") {
5319
- options2 = await controller.getKeys(null);
5324
+ options2 = await model._getKeys(null);
5320
5325
  } else if (inputType === "operator") {
5321
- options2 = controller.getOperators();
5326
+ options2 = model._getOperators();
5322
5327
  } else if (inputType === "value") {
5323
- options2 = await controller.getValuesFor(filter);
5328
+ options2 = await model._getValuesFor(filter);
5324
5329
  }
5325
5330
  if (filterInputTypeRef.current !== inputType) {
5326
- (_b2 = controller.stopInteraction) == null ? void 0 : _b2.call(controller);
5331
+ profiler == null ? void 0 : profiler.stopInteraction();
5327
5332
  return;
5328
5333
  }
5329
5334
  setOptions(options2);
5330
- if ((_c2 = options2[0]) == null ? void 0 : _c2.group) {
5335
+ if ((_a2 = options2[0]) == null ? void 0 : _a2.group) {
5331
5336
  setActiveIndex(1);
5332
5337
  } else {
5333
5338
  setActiveIndex(0);
@@ -5336,9 +5341,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5336
5341
  setOptionsError(true);
5337
5342
  }
5338
5343
  setOptionsLoading(false);
5339
- (_d = controller.stopInteraction) == null ? void 0 : _d.call(controller);
5344
+ profiler == null ? void 0 : profiler.stopInteraction();
5340
5345
  },
5341
- [filter, controller]
5346
+ [filter, model]
5342
5347
  );
5343
5348
  const rowVirtualizer = reactVirtual.useVirtualizer({
5344
5349
  count: filteredDropDownItems.length,
@@ -5348,7 +5353,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5348
5353
  });
5349
5354
  const handleBackspaceInput = React.useCallback(
5350
5355
  (event, multiValueEdit) => {
5351
- var _a2;
5352
5356
  if (event.key === "Backspace" && !inputValue) {
5353
5357
  if (filterInputType === "value") {
5354
5358
  if (multiValueEdit) {
@@ -5369,9 +5373,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5369
5373
  }
5370
5374
  focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
5371
5375
  if (isFilterComplete(filter)) {
5372
- (_a2 = controller.startProfile) == null ? void 0 : _a2.call(controller, FILTER_REMOVED_INTERACTION);
5376
+ const queryController = getQueryController(model);
5377
+ queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
5373
5378
  }
5374
- controller.handleComboboxBackspace(filter);
5379
+ model._handleComboboxBackspace(filter);
5375
5380
  if (isAlwaysWip) {
5376
5381
  handleResetWip();
5377
5382
  }
@@ -5380,7 +5385,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5380
5385
  [
5381
5386
  inputValue,
5382
5387
  filterInputType,
5383
- controller,
5388
+ model,
5384
5389
  filter,
5385
5390
  isAlwaysWip,
5386
5391
  filterMultiValues.length,
@@ -5394,7 +5399,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5394
5399
  if (event.key === "Tab" && !event.shiftKey) {
5395
5400
  if (multiValueEdit) {
5396
5401
  event.preventDefault();
5397
- handleMultiValueFilterCommit(controller, filter, filterMultiValues);
5402
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
5398
5403
  (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
5399
5404
  }
5400
5405
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
@@ -5407,7 +5412,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5407
5412
  handleChangeViewMode,
5408
5413
  handleMultiValueFilterCommit,
5409
5414
  handleResetWip,
5410
- controller,
5415
+ model,
5411
5416
  refs.domReference
5412
5417
  ]
5413
5418
  );
@@ -5416,17 +5421,16 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5416
5421
  if (event.key === "Tab" && event.shiftKey) {
5417
5422
  if (multiValueEdit) {
5418
5423
  event.preventDefault();
5419
- handleMultiValueFilterCommit(controller, filter, filterMultiValues, true);
5424
+ handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
5420
5425
  }
5421
5426
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
5422
5427
  handleResetWip();
5423
5428
  }
5424
5429
  },
5425
- [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, controller]
5430
+ [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]
5426
5431
  );
5427
5432
  const handleEnterInput = React.useCallback(
5428
5433
  (event, multiValueEdit) => {
5429
- var _a2;
5430
5434
  if (event.key === "Enter" && activeIndex != null) {
5431
5435
  if (!filteredDropDownItems[activeIndex]) {
5432
5436
  return;
@@ -5444,9 +5448,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5444
5448
  onAddCustomValue
5445
5449
  });
5446
5450
  if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
5447
- (_a2 = controller.startProfile) == null ? void 0 : _a2.call(controller, FILTER_CHANGED_INTERACTION);
5451
+ const queryController = getQueryController(model);
5452
+ queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
5448
5453
  }
5449
- controller.updateFilter(filter, payload);
5454
+ model._updateFilter(filter, payload);
5450
5455
  populateInputValueOnInputTypeSwitch({
5451
5456
  populateInputOnEdit,
5452
5457
  item: selectedItem,
@@ -5473,7 +5478,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5473
5478
  activeIndex,
5474
5479
  filteredDropDownItems,
5475
5480
  handleLocalMultiValueChange,
5476
- controller,
5481
+ model,
5477
5482
  filter,
5478
5483
  filterInputType,
5479
5484
  populateInputOnEdit,
@@ -5505,7 +5510,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5505
5510
  }
5506
5511
  }, [open, filterInputType]);
5507
5512
  React.useEffect(() => {
5508
- var _a2, _b2, _c2, _d;
5513
+ var _a2, _b2, _c2, _d2;
5509
5514
  if (!isAlwaysWip) {
5510
5515
  if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
5511
5516
  const multiValueOptions = filter.values.reduce(
@@ -5530,7 +5535,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5530
5535
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.select();
5531
5536
  });
5532
5537
  }
5533
- (_d = refs.domReference.current) == null ? void 0 : _d.focus();
5538
+ (_d2 = refs.domReference.current) == null ? void 0 : _d2.focus();
5534
5539
  }
5535
5540
  }, []);
5536
5541
  React.useEffect(() => {
@@ -5549,7 +5554,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5549
5554
  rowVirtualizer.scrollToIndex(activeIndex);
5550
5555
  }
5551
5556
  }, [activeIndex, rowVirtualizer]);
5552
- const keyLabel = (_a = filter == null ? void 0 : filter.keyLabel) != null ? _a : filter == null ? void 0 : filter.key;
5557
+ const keyLabel = (_b = filter == null ? void 0 : filter.keyLabel) != null ? _b : filter == null ? void 0 : filter.key;
5553
5558
  return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.comboboxWrapper }, filter ? /* @__PURE__ */ React__default.default.createElement("div", { className: styles.pillWrapper }, (filter == null ? void 0 : filter.key) ? /* @__PURE__ */ React__default.default.createElement("div", { className: css.cx(styles.basePill, styles.keyPill) }, keyLabel) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && filterInputType !== "operator" ? /* @__PURE__ */ React__default.default.createElement(
5554
5559
  "div",
5555
5560
  {
@@ -5604,7 +5609,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5604
5609
  onChange,
5605
5610
  value: inputValue,
5606
5611
  // dynamic placeholder to display operator and/or value in filter edit mode
5607
- placeholder: generatePlaceholder(filter, filterInputType, isMultiValueEdit, isAlwaysWip, inputPlaceholder),
5612
+ placeholder: generatePlaceholder(filter, filterInputType, isMultiValueEdit, isAlwaysWip),
5608
5613
  "aria-autocomplete": "list",
5609
5614
  onKeyDown(event) {
5610
5615
  if (!open) {
@@ -5634,7 +5639,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5634
5639
  style: {
5635
5640
  ...floatingStyles,
5636
5641
  width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,
5637
- transform: isMultiValueEdit ? `translate(${((_b = multiValuePillWrapperRef.current) == null ? void 0 : _b.getBoundingClientRect().left) || 0}px, ${(((_c = refs.domReference.current) == null ? void 0 : _c.getBoundingClientRect().bottom) || 0) + 10}px )` : floatingStyles.transform
5642
+ transform: isMultiValueEdit ? `translate(${((_c = multiValuePillWrapperRef.current) == null ? void 0 : _c.getBoundingClientRect().left) || 0}px, ${(((_d = refs.domReference.current) == null ? void 0 : _d.getBoundingClientRect().bottom) || 0) + 10}px )` : floatingStyles.transform
5638
5643
  },
5639
5644
  ref: refs.setFloating,
5640
5645
  className: styles.dropdownWrapper,
@@ -5683,7 +5688,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5683
5688
  listRef.current[index] = node;
5684
5689
  },
5685
5690
  onClick(event) {
5686
- var _a3, _b2;
5691
+ var _a3;
5687
5692
  if (filterInputType !== "value") {
5688
5693
  event.stopPropagation();
5689
5694
  }
@@ -5702,9 +5707,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5702
5707
  onAddCustomValue
5703
5708
  });
5704
5709
  if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
5705
- (_b2 = controller.startProfile) == null ? void 0 : _b2.call(controller, FILTER_CHANGED_INTERACTION);
5710
+ const queryController = getQueryController(model);
5711
+ queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
5706
5712
  }
5707
- controller.updateFilter(filter, payload);
5713
+ model._updateFilter(filter, payload);
5708
5714
  populateInputValueOnInputTypeSwitch({
5709
5715
  populateInputOnEdit,
5710
5716
  item,
@@ -5748,7 +5754,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
5748
5754
  MultiValueApplyButton,
5749
5755
  {
5750
5756
  onApply: () => {
5751
- handleMultiValueFilterCommit(controller, filter, filterMultiValues);
5757
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
5752
5758
  },
5753
5759
  floatingElement: refs.floating.current,
5754
5760
  maxOptionWidth,
@@ -5828,7 +5834,7 @@ const getStyles$d = (theme) => ({
5828
5834
  });
5829
5835
 
5830
5836
  const LABEL_MAX_VISIBLE_LENGTH = 20;
5831
- function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
5837
+ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
5832
5838
  var _a, _b, _c, _d;
5833
5839
  const styles = ui.useStyles2(getStyles$c);
5834
5840
  const [viewMode, setViewMode] = React.useState(true);
@@ -5858,9 +5864,9 @@ function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
5858
5864
  React.useEffect(() => {
5859
5865
  if (filter.forceEdit && viewMode) {
5860
5866
  setViewMode(false);
5861
- controller.updateFilter(filter, { forceEdit: void 0 });
5867
+ model._updateFilter(filter, { forceEdit: void 0 });
5862
5868
  }
5863
- }, [filter, controller, viewMode]);
5869
+ }, [filter, model, viewMode]);
5864
5870
  React.useEffect(() => {
5865
5871
  if (viewMode) {
5866
5872
  setPopulateInputOnEdit((prevValue) => prevValue ? false : prevValue);
@@ -5926,9 +5932,9 @@ function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
5926
5932
  onClick: (e) => {
5927
5933
  e.stopPropagation();
5928
5934
  if (filter.origin && filter.origin === "dashboard") {
5929
- controller.updateToMatchAll(filter);
5935
+ model.updateToMatchAll(filter);
5930
5936
  } else {
5931
- controller.removeFilter(filter);
5937
+ model._removeFilter(filter);
5932
5938
  }
5933
5939
  setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
5934
5940
  },
@@ -5937,9 +5943,9 @@ function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
5937
5943
  e.preventDefault();
5938
5944
  e.stopPropagation();
5939
5945
  if (filter.origin && filter.origin === "dashboard") {
5940
- controller.updateToMatchAll(filter);
5946
+ model.updateToMatchAll(filter);
5941
5947
  } else {
5942
- controller.removeFilter(filter);
5948
+ model._removeFilter(filter);
5943
5949
  }
5944
5950
  setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
5945
5951
  }
@@ -5972,13 +5978,13 @@ function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
5972
5978
  {
5973
5979
  onClick: (e) => {
5974
5980
  e.stopPropagation();
5975
- controller.restoreOriginalFilter(filter);
5981
+ model.restoreOriginalFilter(filter);
5976
5982
  },
5977
5983
  onKeyDownCapture: (e) => {
5978
5984
  if (e.key === "Enter") {
5979
5985
  e.preventDefault();
5980
5986
  e.stopPropagation();
5981
- controller.restoreOriginalFilter(filter);
5987
+ model.restoreOriginalFilter(filter);
5982
5988
  }
5983
5989
  },
5984
5990
  name: "history",
@@ -6001,7 +6007,7 @@ function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
6001
6007
  AdHocCombobox,
6002
6008
  {
6003
6009
  filter,
6004
- controller,
6010
+ model,
6005
6011
  handleChangeViewMode,
6006
6012
  focusOnWipInputRef,
6007
6013
  populateInputOnEdit
@@ -6080,18 +6086,18 @@ const getStyles$c = (theme) => ({
6080
6086
  ...getNonApplicablePillStyles(theme)
6081
6087
  });
6082
6088
 
6083
- const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({ controller }, parentRef) {
6084
- const { wip } = controller.useState();
6089
+ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({ model }, parentRef) {
6090
+ const { _wip } = model.useState();
6085
6091
  React.useLayoutEffect(() => {
6086
- if (!wip) {
6087
- controller.addWip();
6092
+ if (!_wip) {
6093
+ model._addWip();
6088
6094
  }
6089
- }, [wip]);
6090
- return /* @__PURE__ */ React__default.default.createElement(AdHocCombobox, { controller, filter: wip, isAlwaysWip: true, ref: parentRef });
6095
+ }, [_wip]);
6096
+ return /* @__PURE__ */ React__default.default.createElement(AdHocCombobox, { model, filter: _wip, isAlwaysWip: true, ref: parentRef });
6091
6097
  });
6092
6098
 
6093
- const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ controller }) {
6094
- const { originFilters, filters, readOnly } = controller.useState();
6099
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
6100
+ const { originFilters, filters, readOnly } = model.useState();
6095
6101
  const styles = ui.useStyles2(getStyles$b);
6096
6102
  const focusOnWipInputRef = React.useRef();
6097
6103
  return /* @__PURE__ */ React__default.default.createElement(
@@ -6110,7 +6116,7 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
6110
6116
  {
6111
6117
  key: `${index}-${filter.key}`,
6112
6118
  filter,
6113
- controller,
6119
+ model,
6114
6120
  focusOnWipInputRef: focusOnWipInputRef.current
6115
6121
  }
6116
6122
  ) : null
@@ -6120,12 +6126,12 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
6120
6126
  {
6121
6127
  key: `${index}-${filter.key}`,
6122
6128
  filter,
6123
- controller,
6129
+ model,
6124
6130
  readOnly: readOnly || filter.readOnly,
6125
6131
  focusOnWipInputRef: focusOnWipInputRef.current
6126
6132
  }
6127
6133
  )),
6128
- !readOnly ? /* @__PURE__ */ React__default.default.createElement(AdHocFiltersAlwaysWipCombobox, { controller, ref: focusOnWipInputRef }) : null
6134
+ !readOnly ? /* @__PURE__ */ React__default.default.createElement(AdHocFiltersAlwaysWipCombobox, { model, ref: focusOnWipInputRef }) : null
6129
6135
  );
6130
6136
  });
6131
6137
  const getStyles$b = (theme) => ({
@@ -6247,66 +6253,6 @@ function hasSameOperators(scopeConvertedOperator, filterOperator) {
6247
6253
  return true;
6248
6254
  }
6249
6255
 
6250
- class VariableBackedAdHocFiltersController {
6251
- constructor(model) {
6252
- this.model = model;
6253
- }
6254
- useState() {
6255
- const state = this.model.useState();
6256
- return {
6257
- filters: state.filters,
6258
- originFilters: state.originFilters,
6259
- readOnly: state.readOnly,
6260
- allowCustomValue: state.allowCustomValue,
6261
- supportsMultiValueOperators: state.supportsMultiValueOperators,
6262
- onAddCustomValue: state.onAddCustomValue,
6263
- wip: state._wip
6264
- };
6265
- }
6266
- async getKeys(currentKey) {
6267
- return this.model._getKeys(currentKey);
6268
- }
6269
- async getValuesFor(filter) {
6270
- return this.model._getValuesFor(filter);
6271
- }
6272
- getOperators() {
6273
- return this.model._getOperators();
6274
- }
6275
- updateFilter(filter, update) {
6276
- this.model._updateFilter(filter, update);
6277
- }
6278
- updateToMatchAll(filter) {
6279
- this.model.updateToMatchAll(filter);
6280
- }
6281
- removeFilter(filter) {
6282
- this.model._removeFilter(filter);
6283
- }
6284
- removeLastFilter() {
6285
- this.model._removeLastFilter();
6286
- }
6287
- handleComboboxBackspace(filter) {
6288
- this.model._handleComboboxBackspace(filter);
6289
- }
6290
- addWip() {
6291
- this.model._addWip();
6292
- }
6293
- restoreOriginalFilter(filter) {
6294
- this.model.restoreOriginalFilter(filter);
6295
- }
6296
- startProfile(name) {
6297
- const queryController = getQueryController(this.model);
6298
- queryController == null ? void 0 : queryController.startProfile(name);
6299
- }
6300
- startInteraction(name) {
6301
- const interactionTracker = getInteractionTracker(this.model);
6302
- interactionTracker == null ? void 0 : interactionTracker.startInteraction(name);
6303
- }
6304
- stopInteraction() {
6305
- const interactionTracker = getInteractionTracker(this.model);
6306
- interactionTracker == null ? void 0 : interactionTracker.stopInteraction();
6307
- }
6308
- }
6309
-
6310
6256
  const OPERATORS = [
6311
6257
  {
6312
6258
  value: "=",
@@ -6782,9 +6728,8 @@ function renderExpression(builder, filters) {
6782
6728
  function AdHocFiltersVariableRenderer({ model }) {
6783
6729
  const { filters, readOnly, addFilterButtonText } = model.useState();
6784
6730
  const styles = ui.useStyles2(getStyles$a);
6785
- const controller = React.useMemo(() => new VariableBackedAdHocFiltersController(model), [model]);
6786
6731
  if (model.state.layout === "combobox") {
6787
- return /* @__PURE__ */ React__default.default.createElement(AdHocFiltersComboboxRenderer, { controller });
6732
+ return /* @__PURE__ */ React__default.default.createElement(AdHocFiltersComboboxRenderer, { model });
6788
6733
  }
6789
6734
  return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.wrapper }, filters.filter((filter) => !filter.hidden).map((filter, index) => /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, { key: index }, /* @__PURE__ */ React__default.default.createElement(AdHocFilterRenderer, { filter, model }))), !readOnly && /* @__PURE__ */ React__default.default.createElement(AdHocFilterBuilder, { model, key: "'builder", addFilterButtonText }));
6790
6735
  }
@@ -9514,19 +9459,25 @@ class SceneDataTransformer extends SceneObjectBase {
9514
9459
  if (!force && this.haveAlreadyTransformedData(data$1)) {
9515
9460
  return;
9516
9461
  }
9517
- let interpolatedTransformations = this._interpolateVariablesInTransformationConfigs(data$1);
9518
- const seriesTransformations = interpolatedTransformations.filter((transformation) => {
9519
- if ("options" in transformation || "topic" in transformation) {
9520
- return transformation.topic == null || transformation.topic === data.DataTopic.Series;
9462
+ const interpolatedTransformations = this._interpolateVariablesInTransformationConfigs(data$1);
9463
+ const seriesTransformations = this._filterAndPrepareTransformationsByTopic(
9464
+ interpolatedTransformations,
9465
+ (transformation) => {
9466
+ if ("options" in transformation || "topic" in transformation) {
9467
+ return transformation.topic == null || transformation.topic === data.DataTopic.Series;
9468
+ }
9469
+ return true;
9521
9470
  }
9522
- return true;
9523
- }).map((transformation) => "operator" in transformation ? transformation.operator : transformation);
9524
- const annotationsTransformations = interpolatedTransformations.filter((transformation) => {
9525
- if ("options" in transformation || "topic" in transformation) {
9526
- return transformation.topic === data.DataTopic.Annotations;
9471
+ );
9472
+ const annotationsTransformations = this._filterAndPrepareTransformationsByTopic(
9473
+ interpolatedTransformations,
9474
+ (transformation) => {
9475
+ if ("options" in transformation || "topic" in transformation) {
9476
+ return transformation.topic === data.DataTopic.Annotations;
9477
+ }
9478
+ return false;
9527
9479
  }
9528
- return false;
9529
- }).map((transformation) => "operator" in transformation ? transformation.operator : transformation);
9480
+ );
9530
9481
  if (this._transformSub) {
9531
9482
  this._transformSub.unsubscribe();
9532
9483
  }
@@ -9536,13 +9487,11 @@ class SceneDataTransformer extends SceneObjectBase {
9536
9487
  return sceneGraph.interpolate(this, value, { ...(_a2 = data$1.request) == null ? void 0 : _a2.scopedVars, ...scopedVars });
9537
9488
  }
9538
9489
  };
9539
- let streams = [data.transformDataFrame(seriesTransformations, data$1.series, ctx)];
9540
- if (data$1.annotations && data$1.annotations.length > 0 && annotationsTransformations.length > 0) {
9541
- streams.push(data.transformDataFrame(annotationsTransformations, (_a = data$1.annotations) != null ? _a : []));
9542
- }
9490
+ const seriesStream = data.transformDataFrame(seriesTransformations, data$1.series, ctx);
9491
+ const annotationsStream = data.transformDataFrame(annotationsTransformations, (_a = data$1.annotations) != null ? _a : []);
9543
9492
  let series = [];
9544
9493
  let annotations = [];
9545
- this._transformSub = rxjs.forkJoin(streams).pipe(
9494
+ this._transformSub = rxjs.forkJoin([seriesStream, annotationsStream]).pipe(
9546
9495
  rxjs.map((results) => {
9547
9496
  results.forEach((frames) => {
9548
9497
  var _a2;
@@ -9591,6 +9540,9 @@ class SceneDataTransformer extends SceneObjectBase {
9591
9540
  return typeof t === "object" ? JSON.parse(sceneGraph.interpolate(this, JSON.stringify(t), (_a2 = data.request) == null ? void 0 : _a2.scopedVars)) : t;
9592
9541
  });
9593
9542
  }
9543
+ _filterAndPrepareTransformationsByTopic(interpolatedTransformations, transformationFilter) {
9544
+ return interpolatedTransformations.filter(transformationFilter).map((transformation) => "operator" in transformation ? transformation.operator : transformation);
9545
+ }
9594
9546
  }
9595
9547
 
9596
9548
  class VizPanel extends SceneObjectBase {
@@ -13194,9 +13146,15 @@ const DEFAULT_COMPARE_OPTIONS = [
13194
13146
  { label: "Month before", value: "1M" }
13195
13147
  ];
13196
13148
  class SceneTimeRangeCompare extends SceneObjectBase {
13197
- constructor(state) {
13198
- super({ compareOptions: DEFAULT_COMPARE_OPTIONS, ...state });
13199
- this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["compareWith"] });
13149
+ constructor(state = {}) {
13150
+ super({
13151
+ key: state.key || "compareWith",
13152
+ compareOptions: DEFAULT_COMPARE_OPTIONS,
13153
+ ...state
13154
+ });
13155
+ this._urlSync = new SceneObjectUrlSyncConfig(this, {
13156
+ keys: () => [this.state.key || "compareWith"]
13157
+ });
13200
13158
  this._onActivate = () => {
13201
13159
  const sceneTimeRange = sceneGraph.getTimeRange(this);
13202
13160
  this.setState({ compareOptions: this.getCompareOptions(sceneTimeRange.state.value) });
@@ -13283,25 +13241,22 @@ class SceneTimeRangeCompare extends SceneObjectBase {
13283
13241
  return void 0;
13284
13242
  }
13285
13243
  getUrlState() {
13286
- return {
13287
- compareWith: this.state.compareWith
13288
- };
13244
+ const key = this.state.key || "compareWith";
13245
+ return { [key]: this.state.compareWith };
13289
13246
  }
13290
13247
  updateFromUrl(values) {
13291
- if (!values.compareWith) {
13248
+ const key = this.state.key || "compareWith";
13249
+ if (values[key] === PREVIOUS_PERIOD_VALUE) {
13250
+ this.setState({ compareWith: PREVIOUS_PERIOD_VALUE });
13292
13251
  return;
13293
13252
  }
13294
- const compareWith = parseUrlParam(values.compareWith);
13253
+ const compareWith = parseUrlParam(values[key]);
13295
13254
  if (compareWith) {
13296
13255
  const compareOptions = this.getCompareOptions(sceneGraph.getTimeRange(this).state.value);
13297
13256
  if (compareOptions.find(({ value }) => value === compareWith)) {
13298
- this.setState({
13299
- compareWith
13300
- });
13257
+ this.setState({ compareWith });
13301
13258
  } else {
13302
- this.setState({
13303
- compareWith: "__previousPeriod"
13304
- });
13259
+ this.setState({ compareWith: PREVIOUS_PERIOD_VALUE });
13305
13260
  }
13306
13261
  }
13307
13262
  }
@@ -15493,7 +15448,6 @@ const sceneUtils = {
15493
15448
  buildPathIdFor
15494
15449
  };
15495
15450
 
15496
- exports.AdHocFiltersComboboxRenderer = AdHocFiltersComboboxRenderer;
15497
15451
  exports.AdHocFiltersVariable = AdHocFiltersVariable;
15498
15452
  exports.ConstantVariable = ConstantVariable;
15499
15453
  exports.ControlsLabel = ControlsLabel;
@@ -15564,7 +15518,6 @@ exports.TextBoxVariable = TextBoxVariable;
15564
15518
  exports.UrlSyncContextProvider = UrlSyncContextProvider;
15565
15519
  exports.UrlSyncManager = UrlSyncManager;
15566
15520
  exports.UserActionEvent = UserActionEvent;
15567
- exports.VariableBackedAdHocFiltersController = VariableBackedAdHocFiltersController;
15568
15521
  exports.VariableDependencyConfig = VariableDependencyConfig;
15569
15522
  exports.VariableValueControl = VariableValueControl;
15570
15523
  exports.VariableValueSelectWrapper = VariableValueSelectWrapper;