@grafana/scenes 5.23.4--canary.964.11745806385.0 → 5.24.0--canary.960.11775742614.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1467,9 +1467,7 @@ class MultiValueVariable extends SceneObjectBase {
1467
1467
  return stateUpdate;
1468
1468
  }
1469
1469
  if (this.hasAllValue()) {
1470
- if (this.state.includeAll) {
1471
- stateUpdate.text = ALL_VARIABLE_TEXT;
1472
- } else {
1470
+ if (!this.state.includeAll) {
1473
1471
  stateUpdate.value = options[0].value;
1474
1472
  stateUpdate.text = options[0].label;
1475
1473
  if (this.state.isMulti) {
@@ -2343,7 +2341,6 @@ var __spreadValues$G = (a, b) => {
2343
2341
  return a;
2344
2342
  };
2345
2343
  var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2346
- const GLOBAL_ANNOTATION_ID = 0;
2347
2344
  function filterAnnotations(data, filters) {
2348
2345
  var _a;
2349
2346
  if (!Array.isArray(data) || data.length === 0) {
@@ -2361,11 +2358,11 @@ function filterAnnotations(data, filters) {
2361
2358
  const sourceField = frame.fields.find((f) => f.name === "source");
2362
2359
  if (sourceField) {
2363
2360
  if (panelIdField && sourceField.values[index].type === "dashboard") {
2364
- matching = [filters.panelId, GLOBAL_ANNOTATION_ID].includes(panelIdField.values[index]);
2361
+ matching = panelIdField.values[index] === filters.panelId;
2365
2362
  }
2366
2363
  const sourceFilter = sourceField.values[index].filter;
2367
2364
  if (sourceFilter) {
2368
- const includes = [...(_a = sourceFilter.ids) != null ? _a : [], GLOBAL_ANNOTATION_ID].includes(filters.panelId);
2365
+ const includes = ((_a = sourceFilter.ids) != null ? _a : []).includes(filters.panelId);
2369
2366
  if (sourceFilter.exclude) {
2370
2367
  if (includes) {
2371
2368
  matching = false;
@@ -2597,7 +2594,7 @@ function toSelectableValue$2(value, label) {
2597
2594
  };
2598
2595
  }
2599
2596
  function VariableValueSelect({ model }) {
2600
- const { value, text, key, options, includeAll, isReadOnly } = model.useState();
2597
+ const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();
2601
2598
  const [inputValue, setInputValue] = React.useState("");
2602
2599
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2603
2600
  const selectValue = toSelectableValue$2(value, String(text));
@@ -2629,7 +2626,7 @@ function VariableValueSelect({ model }) {
2629
2626
  disabled: isReadOnly,
2630
2627
  value: selectValue,
2631
2628
  inputValue,
2632
- allowCustomValue: true,
2629
+ allowCustomValue: allowCustomValue != null ? allowCustomValue : true,
2633
2630
  virtualized: true,
2634
2631
  filterOption: filterNoOp$2,
2635
2632
  tabSelectsValue: false,
@@ -2647,7 +2644,7 @@ function VariableValueSelect({ model }) {
2647
2644
  });
2648
2645
  }
2649
2646
  function VariableValueSelectMulti({ model }) {
2650
- const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly } = model.useState();
2647
+ const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();
2651
2648
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2652
2649
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2653
2650
  const [inputValue, setInputValue] = React.useState("");
@@ -2682,7 +2679,7 @@ function VariableValueSelectMulti({ model }) {
2682
2679
  maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
2683
2680
  tabSelectsValue: false,
2684
2681
  virtualized: true,
2685
- allowCustomValue: true,
2682
+ allowCustomValue: allowCustomValue != null ? allowCustomValue : true,
2686
2683
  toggleAllOptions: {
2687
2684
  enabled: true,
2688
2685
  optionsFilter: filterAll,
@@ -3068,7 +3065,6 @@ function GroupByVariableRenderer({ model }) {
3068
3065
  id: key,
3069
3066
  placeholder: "Select value",
3070
3067
  width: "auto",
3071
- allowCustomValue: true,
3072
3068
  inputValue,
3073
3069
  value: uncommittedValue,
3074
3070
  noMultiValueWrap: true,
@@ -3298,7 +3294,7 @@ function keyLabelToOption(key, label) {
3298
3294
  }
3299
3295
  const filterNoOp = () => true;
3300
3296
  function AdHocFilterRenderer({ filter, model }) {
3301
- var _a, _b, _c;
3297
+ var _a, _b, _c, _d, _e;
3302
3298
  const styles = ui.useStyles2(getStyles$e);
3303
3299
  const [keys, setKeys] = React.useState([]);
3304
3300
  const [values, setValues] = React.useState([]);
@@ -3372,7 +3368,7 @@ function AdHocFilterRenderer({ filter, model }) {
3372
3368
  };
3373
3369
  const valueSelect = /* @__PURE__ */ React__default["default"].createElement(ui.Select, __spreadValues$D({
3374
3370
  virtualized: true,
3375
- allowCustomValue: true,
3371
+ allowCustomValue: (_b = model.state.allowCustomValue) != null ? _b : true,
3376
3372
  isValidNewOption: (inputValue) => inputValue.trim().length > 0,
3377
3373
  allowCreateWhileLoading: true,
3378
3374
  formatCreateLabel: (inputValue) => `Use custom value: ${inputValue}`,
@@ -3418,7 +3414,7 @@ function AdHocFilterRenderer({ filter, model }) {
3418
3414
  disabled: model.state.readOnly,
3419
3415
  className: css.cx(styles.key, isKeysOpen ? styles.widthWhenOpen : void 0),
3420
3416
  width: "auto",
3421
- allowCustomValue: true,
3417
+ allowCustomValue: (_c = model.state.allowCustomValue) != null ? _c : true,
3422
3418
  value: keyValue,
3423
3419
  placeholder: "Select label",
3424
3420
  options: handleOptionGroups(keys),
@@ -3471,7 +3467,7 @@ function AdHocFilterRenderer({ filter, model }) {
3471
3467
  if (filter.key) {
3472
3468
  const label = /* @__PURE__ */ React__default["default"].createElement(ControlsLabel, {
3473
3469
  layout: "vertical",
3474
- label: (_b = filter.key) != null ? _b : "",
3470
+ label: (_d = filter.key) != null ? _d : "",
3475
3471
  onRemove: () => model._removeFilter(filter)
3476
3472
  });
3477
3473
  return /* @__PURE__ */ React__default["default"].createElement(ui.Field, {
@@ -3498,7 +3494,7 @@ function AdHocFilterRenderer({ filter, model }) {
3498
3494
  title: "Remove filter",
3499
3495
  className: styles.removeButton,
3500
3496
  icon: "times",
3501
- "data-testid": `AdHocFilter-remove-${(_c = filter.key) != null ? _c : ""}`,
3497
+ "data-testid": `AdHocFilter-remove-${(_e = filter.key) != null ? _e : ""}`,
3502
3498
  onClick: () => model._removeFilter(filter)
3503
3499
  }));
3504
3500
  }
@@ -4161,7 +4157,7 @@ var __spreadValues$A = (a, b) => {
4161
4157
  };
4162
4158
  var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
4163
4159
  const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode, focusOnWipInputRef, populateInputOnEdit }, parentRef) {
4164
- var _a, _b, _c;
4160
+ var _a, _b, _c, _d;
4165
4161
  const [open, setOpen] = React.useState(false);
4166
4162
  const [options, setOptions] = React.useState([]);
4167
4163
  const [optionsLoading, setOptionsLoading] = React.useState(false);
@@ -4172,6 +4168,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4172
4168
  const styles = ui.useStyles2(getStyles$b);
4173
4169
  const [filterMultiValues, setFilterMultiValues] = React.useState([]);
4174
4170
  const [_, setForceRefresh] = React.useState({});
4171
+ const allowCustomValue = (_a = model.state.allowCustomValue) != null ? _a : true;
4175
4172
  const multiValuePillWrapperRef = React.useRef(null);
4176
4173
  const hasMultiValueOperator = isMultiValueOperator((filter == null ? void 0 : filter.operator) || "");
4177
4174
  const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
@@ -4284,7 +4281,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4284
4281
  [refs.domReference]
4285
4282
  );
4286
4283
  const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));
4287
- if (filterInputType !== "operator" && inputValue) {
4284
+ if (allowCustomValue && filterInputType !== "operator" && inputValue) {
4288
4285
  filteredDropDownItems.push({
4289
4286
  value: inputValue.trim(),
4290
4287
  label: inputValue.trim(),
@@ -4503,7 +4500,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4503
4500
  rowVirtualizer.scrollToIndex(activeIndex);
4504
4501
  }
4505
4502
  }, [activeIndex, rowVirtualizer]);
4506
- const keyLabel = (_a = filter == null ? void 0 : filter.keyLabel) != null ? _a : filter == null ? void 0 : filter.key;
4503
+ const keyLabel = (_b = filter == null ? void 0 : filter.keyLabel) != null ? _b : filter == null ? void 0 : filter.key;
4507
4504
  return /* @__PURE__ */ React__default["default"].createElement("div", {
4508
4505
  className: styles.comboboxWrapper
4509
4506
  }, filter ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -4575,7 +4572,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4575
4572
  }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4576
4573
  style: __spreadProps$o(__spreadValues$A({}, floatingStyles), {
4577
4574
  width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,
4578
- 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
4575
+ 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
4579
4576
  }),
4580
4577
  ref: refs.setFloating,
4581
4578
  className: styles.dropdownWrapper,
@@ -4588,7 +4585,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4588
4585
  tabIndex: -1
4589
4586
  }), optionsLoading ? /* @__PURE__ */ React__default["default"].createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React__default["default"].createElement(OptionsErrorPlaceholder, {
4590
4587
  handleFetchOptions: () => handleFetchOptions(filterInputType)
4591
- }) : !filteredDropDownItems.length && (filterInputType === "operator" || !inputValue) ? /* @__PURE__ */ React__default["default"].createElement(NoOptionsPlaceholder, null) : rowVirtualizer.getVirtualItems().map((virtualItem) => {
4588
+ }) : !filteredDropDownItems.length && (!allowCustomValue || filterInputType === "operator" || !inputValue) ? /* @__PURE__ */ React__default["default"].createElement(NoOptionsPlaceholder, null) : rowVirtualizer.getVirtualItems().map((virtualItem) => {
4592
4589
  var _a2;
4593
4590
  const item = filteredDropDownItems[virtualItem.index];
4594
4591
  const index = virtualItem.index;
@@ -8834,13 +8831,13 @@ function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel })
8834
8831
  }));
8835
8832
  }
8836
8833
  function VariableLabel({ variable, layout, hideLabel }) {
8837
- var _a;
8834
+ var _a, _b;
8838
8835
  const { state } = variable;
8839
8836
  if (variable.state.hide === data.VariableHide.hideLabel || hideLabel) {
8840
8837
  return null;
8841
8838
  }
8842
8839
  const elementId = `var-${state.key}`;
8843
- const labelOrName = state.label || state.name;
8840
+ const labelOrName = (_a = state.label) != null ? _a : state.name;
8844
8841
  return /* @__PURE__ */ React__default["default"].createElement(ControlsLabel, {
8845
8842
  htmlFor: elementId,
8846
8843
  isLoading: state.loading,
@@ -8851,7 +8848,7 @@ function VariableLabel({ variable, layout, hideLabel }) {
8851
8848
  label: labelOrName,
8852
8849
  error: state.error,
8853
8850
  layout,
8854
- description: (_a = state.description) != null ? _a : void 0
8851
+ description: (_b = state.description) != null ? _b : void 0
8855
8852
  });
8856
8853
  }
8857
8854
  const containerStyle = css.css({ display: "flex" });