@grafana/scenes 6.41.1--canary.1289.18910649091.0 → 6.42.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 (26) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/esm/core/types.js.map +1 -1
  3. package/dist/esm/index.js +2 -0
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/querying/layers/SceneDataLayerControls.js +20 -10
  6. package/dist/esm/querying/layers/SceneDataLayerControls.js.map +1 -1
  7. package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js +3 -17
  8. package/dist/esm/querying/layers/annotations/AnnotationsDataLayer.js.map +1 -1
  9. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +10 -10
  10. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
  11. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersAlwaysWipCombobox.js +6 -6
  12. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersAlwaysWipCombobox.js.map +1 -1
  13. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +56 -54
  14. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
  15. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js +5 -5
  16. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.js.map +1 -1
  17. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +4 -4
  18. package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
  19. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +8 -3
  20. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  21. package/dist/esm/variables/adhoc/controller/AdHocFiltersVariableController.js +65 -0
  22. package/dist/esm/variables/adhoc/controller/AdHocFiltersVariableController.js.map +1 -0
  23. package/dist/index.d.ts +120 -4
  24. package/dist/index.js +198 -132
  25. package/dist/index.js.map +1 -1
  26. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -6441,11 +6441,11 @@ const generateFilterUpdatePayload = ({
6441
6441
  [filterInputType]: item.value
6442
6442
  };
6443
6443
  };
6444
- const INPUT_PLACEHOLDER = "Filter by label values";
6445
- const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlwaysWip) => {
6444
+ const INPUT_PLACEHOLDER_DEFAULT = "Filter by label values";
6445
+ const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlwaysWip, inputPlaceholder) => {
6446
6446
  var _a;
6447
6447
  if (filterInputType === "key") {
6448
- return INPUT_PLACEHOLDER;
6448
+ return inputPlaceholder || INPUT_PLACEHOLDER_DEFAULT;
6449
6449
  }
6450
6450
  if (filterInputType === "value") {
6451
6451
  if (isMultiValueEdit) {
@@ -6453,7 +6453,7 @@ const generatePlaceholder = (filter, filterInputType, isMultiValueEdit, isAlways
6453
6453
  }
6454
6454
  return ((_a = filter.valueLabels) == null ? void 0 : _a[0]) || "";
6455
6455
  }
6456
- return filter[filterInputType] && !isAlwaysWip ? `${filter[filterInputType]}` : INPUT_PLACEHOLDER;
6456
+ return filter[filterInputType] && !isAlwaysWip ? `${filter[filterInputType]}` : inputPlaceholder || INPUT_PLACEHOLDER_DEFAULT;
6457
6457
  };
6458
6458
  const populateInputValueOnInputTypeSwitch = ({
6459
6459
  populateInputOnEdit,
@@ -6635,8 +6635,15 @@ const getStyles$c = (theme) => ({
6635
6635
  })
6636
6636
  });
6637
6637
 
6638
- const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef, populateInputOnEdit }, parentRef) {
6639
- var _a, _b, _c, _d;
6638
+ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({
6639
+ filter,
6640
+ controller,
6641
+ isAlwaysWip,
6642
+ handleChangeViewMode,
6643
+ focusOnWipInputRef,
6644
+ populateInputOnEdit
6645
+ }, parentRef) {
6646
+ var _a, _b, _c;
6640
6647
  const [open, setOpen] = React.useState(false);
6641
6648
  const [options, setOptions] = React.useState([]);
6642
6649
  const [optionsLoading, setOptionsLoading] = React.useState(false);
@@ -6648,7 +6655,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6648
6655
  const styles = ui.useStyles2(getStyles$b);
6649
6656
  const [filterMultiValues, setFilterMultiValues] = React.useState([]);
6650
6657
  const [_, setForceRefresh] = React.useState({});
6651
- const allowCustomValue = (_a = model.state.allowCustomValue) != null ? _a : true;
6658
+ const { allowCustomValue = true, onAddCustomValue, filters, inputPlaceholder } = controller.useState();
6652
6659
  const multiValuePillWrapperRef = React.useRef(null);
6653
6660
  const hasMultiValueOperator = isMultiValueOperator((filter == null ? void 0 : filter.operator) || "");
6654
6661
  const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
@@ -6661,29 +6668,30 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6661
6668
  if (isAlwaysWip) {
6662
6669
  return false;
6663
6670
  }
6664
- if (model.state.filters.at(-1) === filter) {
6671
+ if (filters.at(-1) === filter) {
6665
6672
  return true;
6666
6673
  }
6667
6674
  return false;
6668
- }, [filter, isAlwaysWip, model.state.filters]);
6675
+ }, [filter, isAlwaysWip, filters]);
6669
6676
  const handleResetWip = React.useCallback(() => {
6670
6677
  if (isAlwaysWip) {
6671
- model._addWip();
6678
+ controller.addWip();
6672
6679
  setInputType("key");
6673
6680
  setInputValue("");
6674
6681
  }
6675
- }, [model, isAlwaysWip]);
6682
+ }, [controller, isAlwaysWip]);
6676
6683
  const handleMultiValueFilterCommit = React.useCallback(
6677
- (model2, filter2, filterMultiValues2, preventFocus) => {
6684
+ (controller2, filter2, filterMultiValues2, preventFocus) => {
6685
+ var _a2;
6678
6686
  if (!filterMultiValues2.length && filter2.origin) {
6679
- model2.updateToMatchAll(filter2);
6687
+ controller2.updateToMatchAll(filter2);
6680
6688
  }
6681
6689
  if (filterMultiValues2.length) {
6682
6690
  const valueLabels = [];
6683
6691
  const values = [];
6684
6692
  filterMultiValues2.forEach((item) => {
6685
- var _a2;
6686
- valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
6693
+ var _a3;
6694
+ valueLabels.push((_a3 = item.label) != null ? _a3 : item.value);
6687
6695
  values.push(item.value);
6688
6696
  });
6689
6697
  let shouldUpdate = true;
@@ -6691,16 +6699,15 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6691
6699
  shouldUpdate = !filter2.values.every((v, i) => v === values[i]);
6692
6700
  }
6693
6701
  if (shouldUpdate) {
6694
- const queryController = getQueryController(model2);
6695
- queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
6702
+ (_a2 = controller2.startProfile) == null ? void 0 : _a2.call(controller2, FILTER_CHANGED_INTERACTION);
6696
6703
  }
6697
- model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
6704
+ controller2.updateFilter(filter2, { valueLabels, values, value: values[0] });
6698
6705
  setFilterMultiValues([]);
6699
6706
  }
6700
6707
  if (!preventFocus) {
6701
6708
  setTimeout(() => {
6702
- var _a2;
6703
- return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
6709
+ var _a3;
6710
+ return (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
6704
6711
  });
6705
6712
  }
6706
6713
  },
@@ -6720,10 +6727,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6720
6727
  setOpen(nextOpen);
6721
6728
  if (reason && ["outside-press", "escape-key"].includes(reason)) {
6722
6729
  if (isMultiValueEdit) {
6723
- handleMultiValueFilterCommit(model, filter, filterMultiValues);
6730
+ handleMultiValueFilterCommit(controller, filter, filterMultiValues);
6724
6731
  } else {
6725
6732
  if (filter && filter.origin && inputValue === "") {
6726
- model.updateToMatchAll(filter);
6733
+ controller.updateToMatchAll(filter);
6727
6734
  }
6728
6735
  }
6729
6736
  handleResetWip();
@@ -6738,7 +6745,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6738
6745
  handleResetWip,
6739
6746
  inputValue,
6740
6747
  isMultiValueEdit,
6741
- model
6748
+ controller
6742
6749
  ]
6743
6750
  );
6744
6751
  const outsidePressIdsToIgnore = React.useMemo(() => {
@@ -6797,15 +6804,13 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6797
6804
  filteredDropDownItems.push(customOptionValue);
6798
6805
  }
6799
6806
  }
6800
- const onAddCustomValue = model.state.onAddCustomValue;
6801
6807
  const maxOptionWidth = setupDropdownAccessibility(filteredDropDownItems, listRef, disabledIndicesRef);
6802
6808
  const handleFetchOptions = React.useCallback(
6803
6809
  async (inputType) => {
6804
- var _a2;
6805
- const profiler = getInteractionTracker(model);
6810
+ var _a2, _b2, _c2, _d;
6806
6811
  const interactionName = inputType === "key" ? ADHOC_KEYS_DROPDOWN_INTERACTION : ADHOC_VALUES_DROPDOWN_INTERACTION;
6807
6812
  if (inputType !== "operator") {
6808
- profiler == null ? void 0 : profiler.startInteraction(interactionName);
6813
+ (_a2 = controller.startInteraction) == null ? void 0 : _a2.call(controller, interactionName);
6809
6814
  }
6810
6815
  setOptionsError(false);
6811
6816
  setOptionsLoading(true);
@@ -6813,18 +6818,18 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6813
6818
  let options2 = [];
6814
6819
  try {
6815
6820
  if (inputType === "key") {
6816
- options2 = await model._getKeys(null);
6821
+ options2 = await controller.getKeys(null);
6817
6822
  } else if (inputType === "operator") {
6818
- options2 = model._getOperators();
6823
+ options2 = controller.getOperators();
6819
6824
  } else if (inputType === "value") {
6820
- options2 = await model._getValuesFor(filter);
6825
+ options2 = await controller.getValuesFor(filter);
6821
6826
  }
6822
6827
  if (filterInputTypeRef.current !== inputType) {
6823
- profiler == null ? void 0 : profiler.stopInteraction();
6828
+ (_b2 = controller.stopInteraction) == null ? void 0 : _b2.call(controller);
6824
6829
  return;
6825
6830
  }
6826
6831
  setOptions(options2);
6827
- if ((_a2 = options2[0]) == null ? void 0 : _a2.group) {
6832
+ if ((_c2 = options2[0]) == null ? void 0 : _c2.group) {
6828
6833
  setActiveIndex(1);
6829
6834
  } else {
6830
6835
  setActiveIndex(0);
@@ -6833,9 +6838,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6833
6838
  setOptionsError(true);
6834
6839
  }
6835
6840
  setOptionsLoading(false);
6836
- profiler == null ? void 0 : profiler.stopInteraction();
6841
+ (_d = controller.stopInteraction) == null ? void 0 : _d.call(controller);
6837
6842
  },
6838
- [filter, model]
6843
+ [filter, controller]
6839
6844
  );
6840
6845
  const rowVirtualizer = reactVirtual.useVirtualizer({
6841
6846
  count: filteredDropDownItems.length,
@@ -6845,6 +6850,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6845
6850
  });
6846
6851
  const handleBackspaceInput = React.useCallback(
6847
6852
  (event, multiValueEdit) => {
6853
+ var _a2;
6848
6854
  if (event.key === "Backspace" && !inputValue) {
6849
6855
  if (filterInputType === "value") {
6850
6856
  if (multiValueEdit) {
@@ -6865,10 +6871,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6865
6871
  }
6866
6872
  focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
6867
6873
  if (isFilterComplete(filter)) {
6868
- const queryController = getQueryController(model);
6869
- queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
6874
+ (_a2 = controller.startProfile) == null ? void 0 : _a2.call(controller, FILTER_REMOVED_INTERACTION);
6870
6875
  }
6871
- model._handleComboboxBackspace(filter);
6876
+ controller.handleComboboxBackspace(filter);
6872
6877
  if (isAlwaysWip) {
6873
6878
  handleResetWip();
6874
6879
  }
@@ -6877,7 +6882,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6877
6882
  [
6878
6883
  inputValue,
6879
6884
  filterInputType,
6880
- model,
6885
+ controller,
6881
6886
  filter,
6882
6887
  isAlwaysWip,
6883
6888
  filterMultiValues.length,
@@ -6891,7 +6896,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6891
6896
  if (event.key === "Tab" && !event.shiftKey) {
6892
6897
  if (multiValueEdit) {
6893
6898
  event.preventDefault();
6894
- handleMultiValueFilterCommit(model, filter, filterMultiValues);
6899
+ handleMultiValueFilterCommit(controller, filter, filterMultiValues);
6895
6900
  (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
6896
6901
  }
6897
6902
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
@@ -6904,7 +6909,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6904
6909
  handleChangeViewMode,
6905
6910
  handleMultiValueFilterCommit,
6906
6911
  handleResetWip,
6907
- model,
6912
+ controller,
6908
6913
  refs.domReference
6909
6914
  ]
6910
6915
  );
@@ -6913,16 +6918,17 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6913
6918
  if (event.key === "Tab" && event.shiftKey) {
6914
6919
  if (multiValueEdit) {
6915
6920
  event.preventDefault();
6916
- handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
6921
+ handleMultiValueFilterCommit(controller, filter, filterMultiValues, true);
6917
6922
  }
6918
6923
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
6919
6924
  handleResetWip();
6920
6925
  }
6921
6926
  },
6922
- [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]
6927
+ [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, controller]
6923
6928
  );
6924
6929
  const handleEnterInput = React.useCallback(
6925
6930
  (event, multiValueEdit) => {
6931
+ var _a2;
6926
6932
  if (event.key === "Enter" && activeIndex != null) {
6927
6933
  if (!filteredDropDownItems[activeIndex]) {
6928
6934
  return;
@@ -6940,10 +6946,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6940
6946
  onAddCustomValue
6941
6947
  });
6942
6948
  if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
6943
- const queryController = getQueryController(model);
6944
- queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
6949
+ (_a2 = controller.startProfile) == null ? void 0 : _a2.call(controller, FILTER_CHANGED_INTERACTION);
6945
6950
  }
6946
- model._updateFilter(filter, payload);
6951
+ controller.updateFilter(filter, payload);
6947
6952
  populateInputValueOnInputTypeSwitch({
6948
6953
  populateInputOnEdit,
6949
6954
  item: selectedItem,
@@ -6970,7 +6975,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
6970
6975
  activeIndex,
6971
6976
  filteredDropDownItems,
6972
6977
  handleLocalMultiValueChange,
6973
- model,
6978
+ controller,
6974
6979
  filter,
6975
6980
  filterInputType,
6976
6981
  populateInputOnEdit,
@@ -7002,7 +7007,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7002
7007
  }
7003
7008
  }, [open, filterInputType]);
7004
7009
  React.useEffect(() => {
7005
- var _a2, _b2, _c2, _d2;
7010
+ var _a2, _b2, _c2, _d;
7006
7011
  if (!isAlwaysWip) {
7007
7012
  if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
7008
7013
  const multiValueOptions = filter.values.reduce(
@@ -7027,7 +7032,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7027
7032
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.select();
7028
7033
  });
7029
7034
  }
7030
- (_d2 = refs.domReference.current) == null ? void 0 : _d2.focus();
7035
+ (_d = refs.domReference.current) == null ? void 0 : _d.focus();
7031
7036
  }
7032
7037
  }, []);
7033
7038
  React.useEffect(() => {
@@ -7046,7 +7051,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7046
7051
  rowVirtualizer.scrollToIndex(activeIndex);
7047
7052
  }
7048
7053
  }, [activeIndex, rowVirtualizer]);
7049
- const keyLabel = (_b = filter == null ? void 0 : filter.keyLabel) != null ? _b : filter == null ? void 0 : filter.key;
7054
+ const keyLabel = (_a = filter == null ? void 0 : filter.keyLabel) != null ? _a : filter == null ? void 0 : filter.key;
7050
7055
  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(
7051
7056
  "div",
7052
7057
  {
@@ -7101,7 +7106,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7101
7106
  onChange,
7102
7107
  value: inputValue,
7103
7108
  // dynamic placeholder to display operator and/or value in filter edit mode
7104
- placeholder: generatePlaceholder(filter, filterInputType, isMultiValueEdit, isAlwaysWip),
7109
+ placeholder: generatePlaceholder(filter, filterInputType, isMultiValueEdit, isAlwaysWip, inputPlaceholder),
7105
7110
  "aria-autocomplete": "list",
7106
7111
  onKeyDown(event) {
7107
7112
  if (!open) {
@@ -7131,7 +7136,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7131
7136
  style: {
7132
7137
  ...floatingStyles,
7133
7138
  width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,
7134
- 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
7139
+ 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
7135
7140
  },
7136
7141
  ref: refs.setFloating,
7137
7142
  className: styles.dropdownWrapper,
@@ -7180,7 +7185,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7180
7185
  listRef.current[index] = node;
7181
7186
  },
7182
7187
  onClick(event) {
7183
- var _a3;
7188
+ var _a3, _b2;
7184
7189
  if (filterInputType !== "value") {
7185
7190
  event.stopPropagation();
7186
7191
  }
@@ -7199,10 +7204,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7199
7204
  onAddCustomValue
7200
7205
  });
7201
7206
  if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
7202
- const queryController = getQueryController(model);
7203
- queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
7207
+ (_b2 = controller.startProfile) == null ? void 0 : _b2.call(controller, FILTER_CHANGED_INTERACTION);
7204
7208
  }
7205
- model._updateFilter(filter, payload);
7209
+ controller.updateFilter(filter, payload);
7206
7210
  populateInputValueOnInputTypeSwitch({
7207
7211
  populateInputOnEdit,
7208
7212
  item,
@@ -7246,7 +7250,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
7246
7250
  MultiValueApplyButton,
7247
7251
  {
7248
7252
  onApply: () => {
7249
- handleMultiValueFilterCommit(model, filter, filterMultiValues);
7253
+ handleMultiValueFilterCommit(controller, filter, filterMultiValues);
7250
7254
  },
7251
7255
  floatingElement: refs.floating.current,
7252
7256
  maxOptionWidth,
@@ -7326,7 +7330,7 @@ const getStyles$b = (theme) => ({
7326
7330
  });
7327
7331
 
7328
7332
  const LABEL_MAX_VISIBLE_LENGTH = 20;
7329
- function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
7333
+ function AdHocFilterPill({ filter, controller, readOnly, focusOnWipInputRef }) {
7330
7334
  var _a, _b, _c, _d;
7331
7335
  const styles = ui.useStyles2(getStyles$a);
7332
7336
  const [viewMode, setViewMode] = React.useState(true);
@@ -7356,9 +7360,9 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
7356
7360
  React.useEffect(() => {
7357
7361
  if (filter.forceEdit && viewMode) {
7358
7362
  setViewMode(false);
7359
- model._updateFilter(filter, { forceEdit: void 0 });
7363
+ controller.updateFilter(filter, { forceEdit: void 0 });
7360
7364
  }
7361
- }, [filter, model, viewMode]);
7365
+ }, [filter, controller, viewMode]);
7362
7366
  React.useEffect(() => {
7363
7367
  if (viewMode) {
7364
7368
  setPopulateInputOnEdit((prevValue) => prevValue ? false : prevValue);
@@ -7424,9 +7428,9 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
7424
7428
  onClick: (e) => {
7425
7429
  e.stopPropagation();
7426
7430
  if (filter.origin && filter.origin === "dashboard") {
7427
- model.updateToMatchAll(filter);
7431
+ controller.updateToMatchAll(filter);
7428
7432
  } else {
7429
- model._removeFilter(filter);
7433
+ controller.removeFilter(filter);
7430
7434
  }
7431
7435
  setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
7432
7436
  },
@@ -7435,9 +7439,9 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
7435
7439
  e.preventDefault();
7436
7440
  e.stopPropagation();
7437
7441
  if (filter.origin && filter.origin === "dashboard") {
7438
- model.updateToMatchAll(filter);
7442
+ controller.updateToMatchAll(filter);
7439
7443
  } else {
7440
- model._removeFilter(filter);
7444
+ controller.removeFilter(filter);
7441
7445
  }
7442
7446
  setTimeout(() => focusOnWipInputRef == null ? void 0 : focusOnWipInputRef());
7443
7447
  }
@@ -7470,13 +7474,13 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
7470
7474
  {
7471
7475
  onClick: (e) => {
7472
7476
  e.stopPropagation();
7473
- model.restoreOriginalFilter(filter);
7477
+ controller.restoreOriginalFilter(filter);
7474
7478
  },
7475
7479
  onKeyDownCapture: (e) => {
7476
7480
  if (e.key === "Enter") {
7477
7481
  e.preventDefault();
7478
7482
  e.stopPropagation();
7479
- model.restoreOriginalFilter(filter);
7483
+ controller.restoreOriginalFilter(filter);
7480
7484
  }
7481
7485
  },
7482
7486
  name: "history",
@@ -7499,7 +7503,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
7499
7503
  AdHocCombobox,
7500
7504
  {
7501
7505
  filter,
7502
- model,
7506
+ controller,
7503
7507
  handleChangeViewMode,
7504
7508
  focusOnWipInputRef,
7505
7509
  populateInputOnEdit
@@ -7578,18 +7582,18 @@ const getStyles$a = (theme) => ({
7578
7582
  ...getNonApplicablePillStyles(theme)
7579
7583
  });
7580
7584
 
7581
- const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({ model }, parentRef) {
7582
- const { _wip } = model.useState();
7585
+ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwaysWipCombobox2({ controller }, parentRef) {
7586
+ const { wip } = controller.useState();
7583
7587
  React.useLayoutEffect(() => {
7584
- if (!_wip) {
7585
- model._addWip();
7588
+ if (!wip) {
7589
+ controller.addWip();
7586
7590
  }
7587
- }, [_wip]);
7588
- return /* @__PURE__ */ React__default.default.createElement(AdHocCombobox, { model, filter: _wip, isAlwaysWip: true, ref: parentRef });
7591
+ }, [wip]);
7592
+ return /* @__PURE__ */ React__default.default.createElement(AdHocCombobox, { controller, filter: wip, isAlwaysWip: true, ref: parentRef });
7589
7593
  });
7590
7594
 
7591
- const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
7592
- const { originFilters, filters, readOnly } = model.useState();
7595
+ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ controller }) {
7596
+ const { originFilters, filters, readOnly } = controller.useState();
7593
7597
  const styles = ui.useStyles2(getStyles$9);
7594
7598
  const focusOnWipInputRef = React.useRef();
7595
7599
  return /* @__PURE__ */ React__default.default.createElement(
@@ -7608,7 +7612,7 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
7608
7612
  {
7609
7613
  key: `${index}-${filter.key}`,
7610
7614
  filter,
7611
- model,
7615
+ controller,
7612
7616
  focusOnWipInputRef: focusOnWipInputRef.current
7613
7617
  }
7614
7618
  ) : null
@@ -7618,12 +7622,12 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
7618
7622
  {
7619
7623
  key: `${index}-${filter.key}`,
7620
7624
  filter,
7621
- model,
7625
+ controller,
7622
7626
  readOnly: readOnly || filter.readOnly,
7623
7627
  focusOnWipInputRef: focusOnWipInputRef.current
7624
7628
  }
7625
7629
  )),
7626
- !readOnly ? /* @__PURE__ */ React__default.default.createElement(AdHocFiltersAlwaysWipCombobox, { model, ref: focusOnWipInputRef }) : null
7630
+ !readOnly ? /* @__PURE__ */ React__default.default.createElement(AdHocFiltersAlwaysWipCombobox, { controller, ref: focusOnWipInputRef }) : null
7627
7631
  );
7628
7632
  });
7629
7633
  const getStyles$9 = (theme) => ({
@@ -7745,6 +7749,66 @@ function hasSameOperators(scopeConvertedOperator, filterOperator) {
7745
7749
  return true;
7746
7750
  }
7747
7751
 
7752
+ class AdHocFiltersVariableController {
7753
+ constructor(model) {
7754
+ this.model = model;
7755
+ }
7756
+ useState() {
7757
+ const state = this.model.useState();
7758
+ return {
7759
+ filters: state.filters,
7760
+ originFilters: state.originFilters,
7761
+ readOnly: state.readOnly,
7762
+ allowCustomValue: state.allowCustomValue,
7763
+ supportsMultiValueOperators: state.supportsMultiValueOperators,
7764
+ onAddCustomValue: state.onAddCustomValue,
7765
+ wip: state._wip
7766
+ };
7767
+ }
7768
+ async getKeys(currentKey) {
7769
+ return this.model._getKeys(currentKey);
7770
+ }
7771
+ async getValuesFor(filter) {
7772
+ return this.model._getValuesFor(filter);
7773
+ }
7774
+ getOperators() {
7775
+ return this.model._getOperators();
7776
+ }
7777
+ updateFilter(filter, update) {
7778
+ this.model._updateFilter(filter, update);
7779
+ }
7780
+ updateToMatchAll(filter) {
7781
+ this.model.updateToMatchAll(filter);
7782
+ }
7783
+ removeFilter(filter) {
7784
+ this.model._removeFilter(filter);
7785
+ }
7786
+ removeLastFilter() {
7787
+ this.model._removeLastFilter();
7788
+ }
7789
+ handleComboboxBackspace(filter) {
7790
+ this.model._handleComboboxBackspace(filter);
7791
+ }
7792
+ addWip() {
7793
+ this.model._addWip();
7794
+ }
7795
+ restoreOriginalFilter(filter) {
7796
+ this.model.restoreOriginalFilter(filter);
7797
+ }
7798
+ startProfile(name) {
7799
+ const queryController = getQueryController(this.model);
7800
+ queryController == null ? void 0 : queryController.startProfile(name);
7801
+ }
7802
+ startInteraction(name) {
7803
+ const interactionTracker = getInteractionTracker(this.model);
7804
+ interactionTracker == null ? void 0 : interactionTracker.startInteraction(name);
7805
+ }
7806
+ stopInteraction() {
7807
+ const interactionTracker = getInteractionTracker(this.model);
7808
+ interactionTracker == null ? void 0 : interactionTracker.stopInteraction();
7809
+ }
7810
+ }
7811
+
7748
7812
  const OPERATORS = [
7749
7813
  {
7750
7814
  value: "=",
@@ -8220,8 +8284,12 @@ function renderExpression(builder, filters) {
8220
8284
  function AdHocFiltersVariableRenderer({ model }) {
8221
8285
  const { filters, readOnly, addFilterButtonText } = model.useState();
8222
8286
  const styles = ui.useStyles2(getStyles$8);
8223
- if (model.state.layout === "combobox") {
8224
- return /* @__PURE__ */ React__default.default.createElement(AdHocFiltersComboboxRenderer, { model });
8287
+ const controller = React.useMemo(
8288
+ () => model.state.layout === "combobox" ? new AdHocFiltersVariableController(model) : void 0,
8289
+ [model]
8290
+ );
8291
+ if (controller) {
8292
+ return /* @__PURE__ */ React__default.default.createElement(AdHocFiltersComboboxRenderer, { controller });
8225
8293
  }
8226
8294
  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 }));
8227
8295
  }
@@ -10705,6 +10773,53 @@ class SceneDataLayerBase extends SceneObjectBase {
10705
10773
  }
10706
10774
  }
10707
10775
 
10776
+ class SceneDataLayerControls extends SceneObjectBase {
10777
+ constructor() {
10778
+ super({});
10779
+ }
10780
+ }
10781
+ SceneDataLayerControls.Component = SceneDataLayerControlsRenderer;
10782
+ function SceneDataLayerControlsRenderer({ model }) {
10783
+ const layers = sceneGraph.getDataLayers(model, true);
10784
+ if (layers.length === 0) {
10785
+ return null;
10786
+ }
10787
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, layers.map((layer) => /* @__PURE__ */ React__default.default.createElement(layer.Component, { model: layer, key: layer.state.key })));
10788
+ }
10789
+ function DataLayerControlSwitch({ layer }) {
10790
+ var _a, _b;
10791
+ const elementId = `data-layer-${layer.state.key}`;
10792
+ const { data, isEnabled } = layer.useState();
10793
+ const showLoading = Boolean(data && data.state === schema.LoadingState.Loading);
10794
+ return /* @__PURE__ */ React__default.default.createElement("div", { className: containerStyle$1 }, /* @__PURE__ */ React__default.default.createElement(
10795
+ ControlsLabel,
10796
+ {
10797
+ htmlFor: elementId,
10798
+ isLoading: showLoading,
10799
+ onCancel: () => {
10800
+ var _a2;
10801
+ return (_a2 = layer.cancelQuery) == null ? void 0 : _a2.call(layer);
10802
+ },
10803
+ label: layer.state.name,
10804
+ description: layer.state.description,
10805
+ error: (_b = (_a = layer.state.data) == null ? void 0 : _a.errors) == null ? void 0 : _b[0].message
10806
+ }
10807
+ ), /* @__PURE__ */ React__default.default.createElement(
10808
+ ui.InlineSwitch,
10809
+ {
10810
+ className: switchStyle,
10811
+ id: elementId,
10812
+ value: isEnabled,
10813
+ onChange: () => layer.setState({ isEnabled: !isEnabled })
10814
+ }
10815
+ ));
10816
+ }
10817
+ const containerStyle$1 = css.css({ display: "flex" });
10818
+ const switchStyle = css.css({
10819
+ borderBottomLeftRadius: 0,
10820
+ borderTopLeftRadius: 0
10821
+ });
10822
+
10708
10823
  const standardAnnotationSupport = {
10709
10824
  /**
10710
10825
  * Assume the stored value is standard model.
@@ -11158,25 +11273,12 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
11158
11273
  }
11159
11274
  AnnotationsDataLayer.Component = AnnotationsDataLayerRenderer;
11160
11275
  function AnnotationsDataLayerRenderer({ model }) {
11161
- const { isEnabled, isHidden } = model.useState();
11162
- const elementId = `data-layer-${model.state.key}`;
11276
+ const { isHidden } = model.useState();
11163
11277
  if (isHidden) {
11164
11278
  return null;
11165
11279
  }
11166
- return /* @__PURE__ */ React__default.default.createElement(
11167
- ui.InlineSwitch,
11168
- {
11169
- className: switchStyle,
11170
- id: elementId,
11171
- value: isEnabled,
11172
- onChange: () => model.setState({ isEnabled: !isEnabled })
11173
- }
11174
- );
11280
+ return /* @__PURE__ */ React__default.default.createElement(DataLayerControlSwitch, { layer: model });
11175
11281
  }
11176
- const switchStyle = css.css({
11177
- borderBottomLeftRadius: 0,
11178
- borderTopLeftRadius: 0
11179
- });
11180
11282
 
11181
11283
  var index = /*#__PURE__*/Object.freeze({
11182
11284
  __proto__: null,
@@ -11290,44 +11392,6 @@ class DataProviderProxy extends SceneObjectBase {
11290
11392
  }
11291
11393
  }
11292
11394
 
11293
- class SceneDataLayerControls extends SceneObjectBase {
11294
- constructor() {
11295
- super({});
11296
- }
11297
- }
11298
- SceneDataLayerControls.Component = SceneDataLayerControlsRenderer;
11299
- function SceneDataLayerControlsRenderer({ model }) {
11300
- const layers = sceneGraph.getDataLayers(model, true);
11301
- if (layers.length === 0) {
11302
- return null;
11303
- }
11304
- return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, layers.map((layer) => /* @__PURE__ */ React__default.default.createElement(SceneDataLayerControlRenderer, { layer, key: layer.state.key })));
11305
- }
11306
- function SceneDataLayerControlRenderer({ layer }) {
11307
- var _a, _b;
11308
- const elementId = `data-layer-${layer.state.key}`;
11309
- const { data, isHidden } = layer.useState();
11310
- const showLoading = Boolean(data && data.state === schema.LoadingState.Loading);
11311
- if (isHidden) {
11312
- return null;
11313
- }
11314
- return /* @__PURE__ */ React__default.default.createElement("div", { className: containerStyle$1 }, /* @__PURE__ */ React__default.default.createElement(
11315
- ControlsLabel,
11316
- {
11317
- htmlFor: elementId,
11318
- isLoading: showLoading,
11319
- onCancel: () => {
11320
- var _a2;
11321
- return (_a2 = layer.cancelQuery) == null ? void 0 : _a2.call(layer);
11322
- },
11323
- label: layer.state.name,
11324
- description: layer.state.description,
11325
- error: (_b = (_a = layer.state.data) == null ? void 0 : _a.errors) == null ? void 0 : _b[0].message
11326
- }
11327
- ), /* @__PURE__ */ React__default.default.createElement(layer.Component, { model: layer }));
11328
- }
11329
- const containerStyle$1 = css.css({ display: "flex" });
11330
-
11331
11395
  class VariableValueSelectors extends SceneObjectBase {
11332
11396
  }
11333
11397
  VariableValueSelectors.Component = VariableValueSelectorsRenderer;
@@ -16024,7 +16088,9 @@ const sceneUtils = {
16024
16088
  buildPathIdFor
16025
16089
  };
16026
16090
 
16091
+ exports.AdHocFiltersComboboxRenderer = AdHocFiltersComboboxRenderer;
16027
16092
  exports.AdHocFiltersVariable = AdHocFiltersVariable;
16093
+ exports.AdHocFiltersVariableController = AdHocFiltersVariableController;
16028
16094
  exports.ConstantVariable = ConstantVariable;
16029
16095
  exports.ControlsLabel = ControlsLabel;
16030
16096
  exports.CustomVariable = CustomVariable;