@grafana/scenes 5.14.0 → 5.14.1--canary.889.10722729172.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -3636,7 +3636,7 @@ var __objRest$3 = (source, exclude) => {
3636
3636
  };
3637
3637
  const DropdownItem = React.forwardRef(
3638
3638
  function DropdownItem2(_a, ref) {
3639
- var _b = _a, { children, active, addGroupBottomBorder } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder"]);
3639
+ var _b = _a, { children, active, addGroupBottomBorder, isMultiValueEdit, checked } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder", "isMultiValueEdit", "checked"]);
3640
3640
  const styles = ui.useStyles2(getStyles$c);
3641
3641
  const id = React.useId();
3642
3642
  return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$B({
@@ -3648,7 +3648,11 @@ const DropdownItem = React.forwardRef(
3648
3648
  }, rest), /* @__PURE__ */ React__default["default"].createElement("div", {
3649
3649
  className: styles.optionBody,
3650
3650
  "data-testid": `data-testid ad hoc filter option value ${children}`
3651
- }, /* @__PURE__ */ React__default["default"].createElement("span", null, children)));
3651
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, isMultiValueEdit ? /* @__PURE__ */ React__default["default"].createElement(ui.Checkbox, {
3652
+ tabIndex: -1,
3653
+ checked,
3654
+ className: styles.checkbox
3655
+ }) : null, children)));
3652
3656
  }
3653
3657
  );
3654
3658
  const getStyles$c = (theme) => ({
@@ -3688,6 +3692,22 @@ const getStyles$c = (theme) => ({
3688
3692
  }),
3689
3693
  groupBottomBorder: css.css({
3690
3694
  borderBottom: `1px solid ${theme.colors.border.weak}`
3695
+ }),
3696
+ checkbox: css.css({
3697
+ paddingRight: theme.spacing(0.5)
3698
+ }),
3699
+ multiValueApply: css.css({
3700
+ position: "absolute",
3701
+ top: 0,
3702
+ left: 0,
3703
+ display: "flex"
3704
+ }),
3705
+ dropdownWrapper: css.css({
3706
+ backgroundColor: theme.colors.background.primary,
3707
+ color: theme.colors.text.primary,
3708
+ boxShadow: theme.shadows.z2,
3709
+ overflowY: "auto",
3710
+ zIndex: theme.zIndex.dropdown
3691
3711
  })
3692
3712
  });
3693
3713
  const LoadingOptionsPlaceholder = () => {
@@ -3705,11 +3725,28 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3705
3725
  onClick: handleFetchOptions
3706
3726
  }, "An error has occurred fetching labels. Click to retry");
3707
3727
  };
3728
+ const MultiValueApplyButton = ({ onClick, floatingElement, maxOptionWidth }) => {
3729
+ const styles = ui.useStyles2(getStyles$c);
3730
+ const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
3731
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
3732
+ className: css.cx(styles.dropdownWrapper, styles.multiValueApply),
3733
+ style: {
3734
+ width: `${maxOptionWidth}px`,
3735
+ transform: `translate(${floatingElementRect == null ? void 0 : floatingElementRect.left}px,${floatingElementRect == null ? void 0 : floatingElementRect.bottom}px)`
3736
+ }
3737
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
3738
+ onClick,
3739
+ fill: "text",
3740
+ fullWidth: true,
3741
+ tabIndex: -1
3742
+ }, "Apply"));
3743
+ };
3708
3744
 
3709
3745
  const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;
3710
3746
  const VIRTUAL_LIST_PADDING = 8;
3711
3747
  const VIRTUAL_LIST_OVERSCAN = 5;
3712
3748
  const VIRTUAL_LIST_ITEM_HEIGHT = 38;
3749
+ const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
3713
3750
  const ERROR_STATE_DROPDOWN_WIDTH = 366;
3714
3751
  function fuzzySearchOptions(options) {
3715
3752
  const ufuzzy = new uFuzzy__default["default"]();
@@ -3760,7 +3797,7 @@ function fuzzySearchOptions(options) {
3760
3797
  }
3761
3798
  const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
3762
3799
  const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
3763
- var _a, _b, _c;
3800
+ var _a, _b, _c, _d;
3764
3801
  let maxOptionWidth = 182;
3765
3802
  const listRefArr = [];
3766
3803
  const disabledIndices = [];
@@ -3770,6 +3807,9 @@ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
3770
3807
  disabledIndices.push(i);
3771
3808
  }
3772
3809
  let label = (_c = (_b = options[i].label) != null ? _b : options[i].value) != null ? _c : "";
3810
+ if (label.length < (((_d = options[i].description) == null ? void 0 : _d.length) || 0)) {
3811
+ label = options[i].description;
3812
+ }
3773
3813
  const widthEstimate = (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER + VIRTUAL_LIST_PADDING * 2;
3774
3814
  if (widthEstimate > maxOptionWidth) {
3775
3815
  maxOptionWidth = widthEstimate;
@@ -3819,7 +3859,7 @@ const useFloatingInteractions = ({
3819
3859
  onOpenChange,
3820
3860
  activeIndex,
3821
3861
  setActiveIndex,
3822
- operatorIdentifier,
3862
+ outsidePressIdsToIgnore,
3823
3863
  listRef,
3824
3864
  disabledIndicesRef
3825
3865
  }) => {
@@ -3843,7 +3883,13 @@ const useFloatingInteractions = ({
3843
3883
  const role = react.useRole(context, { role: "listbox" });
3844
3884
  const dismiss = react.useDismiss(context, {
3845
3885
  outsidePress: (event) => {
3846
- if (event.currentTarget instanceof HTMLElement && event.currentTarget.id === operatorIdentifier) {
3886
+ var _a;
3887
+ const target = event.currentTarget || event.target;
3888
+ let idToCompare = (target == null ? void 0 : target.id) || "";
3889
+ if ((target == null ? void 0 : target.nodeName) === "path") {
3890
+ idToCompare = ((_a = target.parentElement) == null ? void 0 : _a.id) || "";
3891
+ }
3892
+ if (outsidePressIdsToIgnore.includes(idToCompare)) {
3847
3893
  return false;
3848
3894
  }
3849
3895
  return true;
@@ -3897,6 +3943,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
3897
3943
  const [activeIndex, setActiveIndex] = React.useState(null);
3898
3944
  const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
3899
3945
  const styles = ui.useStyles2(getStyles$b);
3946
+ const [filterMultiValues, setFilterMultiValues] = React.useState([]);
3947
+ const [_, setForceRefresh] = React.useState({});
3948
+ const multiValueOperators = React.useMemo(
3949
+ () => OPERATORS.reduce((acc, operator) => operator.isMulti ? [...acc, operator.value] : acc, []),
3950
+ []
3951
+ );
3952
+ const hasMultiValueOperator = multiValueOperators.includes((filter == null ? void 0 : filter.operator) || "");
3953
+ const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
3900
3954
  const operatorIdentifier = React.useId();
3901
3955
  const listRef = React.useRef([]);
3902
3956
  const disabledIndicesRef = React.useRef([]);
@@ -3908,22 +3962,70 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
3908
3962
  setInputValue("");
3909
3963
  }
3910
3964
  }, [model, isAlwaysWip]);
3965
+ const handleMultiValueFilterCommit = React.useCallback(
3966
+ (model2, filter2, filterMultiValues2, preventFocus) => {
3967
+ if (filterMultiValues2.length) {
3968
+ const valueLabels = [];
3969
+ const values = [];
3970
+ filterMultiValues2.forEach((item) => {
3971
+ var _a2;
3972
+ valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
3973
+ values.push(item.value);
3974
+ });
3975
+ model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
3976
+ setFilterMultiValues([]);
3977
+ }
3978
+ if (!preventFocus) {
3979
+ setTimeout(() => {
3980
+ var _a2;
3981
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
3982
+ });
3983
+ }
3984
+ },
3985
+ []
3986
+ );
3987
+ const handleLocalMultiValueChange = React.useCallback((selectedItem) => {
3988
+ setFilterMultiValues((items) => {
3989
+ if (items.some((item) => item.value === selectedItem.value)) {
3990
+ return items.filter((item) => item.value !== selectedItem.value);
3991
+ }
3992
+ return [...items, selectedItem];
3993
+ });
3994
+ }, []);
3995
+ const handleRemoveMultiValue = React.useCallback(
3996
+ (item) => setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value)),
3997
+ []
3998
+ );
3911
3999
  const onOpenChange = React.useCallback(
3912
- (nextOpen, _, reason) => {
4000
+ (nextOpen, _2, reason) => {
3913
4001
  setOpen(nextOpen);
3914
4002
  if (reason && ["outside-press", "escape-key"].includes(reason)) {
4003
+ if (isMultiValueEdit) {
4004
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
4005
+ }
3915
4006
  handleResetWip();
3916
4007
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3917
4008
  }
3918
4009
  },
3919
- [handleChangeViewMode, handleResetWip]
4010
+ [
4011
+ filter,
4012
+ filterMultiValues,
4013
+ handleChangeViewMode,
4014
+ handleMultiValueFilterCommit,
4015
+ handleResetWip,
4016
+ isMultiValueEdit,
4017
+ model
4018
+ ]
3920
4019
  );
4020
+ const outsidePressIdsToIgnore = React.useMemo(() => {
4021
+ return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
4022
+ }, [operatorIdentifier, filterMultiValues]);
3921
4023
  const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
3922
4024
  open,
3923
4025
  onOpenChange,
3924
4026
  activeIndex,
3925
4027
  setActiveIndex,
3926
- operatorIdentifier,
4028
+ outsidePressIdsToIgnore,
3927
4029
  listRef,
3928
4030
  disabledIndicesRef
3929
4031
  });
@@ -3974,43 +4076,89 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
3974
4076
  const rowVirtualizer = reactVirtual.useVirtualizer({
3975
4077
  count: filteredDropDownItems.length,
3976
4078
  getScrollElement: () => refs.floating.current,
3977
- estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
4079
+ estimateSize: (index) => filteredDropDownItems[index].description ? VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION : VIRTUAL_LIST_ITEM_HEIGHT,
3978
4080
  overscan: VIRTUAL_LIST_OVERSCAN
3979
4081
  });
3980
4082
  const handleBackspaceInput = React.useCallback(
3981
- (event) => {
3982
- if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
3983
- model._removeLastFilter();
3984
- handleFetchOptions(filterInputType);
4083
+ (event, multiValueEdit) => {
4084
+ if (event.key === "Backspace" && !inputValue) {
4085
+ if (multiValueEdit) {
4086
+ setFilterMultiValues((items) => {
4087
+ const updated = [...items];
4088
+ updated.splice(-1, 1);
4089
+ return updated;
4090
+ });
4091
+ } else if (filterInputType === "key") {
4092
+ model._removeLastFilter();
4093
+ handleFetchOptions(filterInputType);
4094
+ }
3985
4095
  }
3986
4096
  },
3987
- [inputValue, filterInputType]
4097
+ [inputValue, filterInputType, model, handleFetchOptions]
4098
+ );
4099
+ const handleTabInput = React.useCallback(
4100
+ (event, multiValueEdit) => {
4101
+ var _a2;
4102
+ if (event.key === "Tab" && !event.shiftKey) {
4103
+ if (multiValueEdit) {
4104
+ event.preventDefault();
4105
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
4106
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
4107
+ }
4108
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
4109
+ handleResetWip();
4110
+ }
4111
+ },
4112
+ [
4113
+ filter,
4114
+ filterMultiValues,
4115
+ handleChangeViewMode,
4116
+ handleMultiValueFilterCommit,
4117
+ handleResetWip,
4118
+ model,
4119
+ refs.domReference
4120
+ ]
4121
+ );
4122
+ const handleShiftTabInput = React.useCallback(
4123
+ (event, multiValueEdit) => {
4124
+ if (event.key === "Tab" && event.shiftKey) {
4125
+ if (multiValueEdit) {
4126
+ event.preventDefault();
4127
+ handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
4128
+ }
4129
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
4130
+ handleResetWip();
4131
+ }
4132
+ },
4133
+ [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]
3988
4134
  );
3989
- const handleTabInput = React.useCallback((event) => {
3990
- if (event.key === "Tab" && !event.shiftKey) {
3991
- handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3992
- handleResetWip();
3993
- }
3994
- }, []);
3995
- const handleShiftTabInput = React.useCallback((event) => {
3996
- if (event.key === "Tab" && event.shiftKey) {
3997
- handleChangeViewMode == null ? void 0 : handleChangeViewMode();
3998
- handleResetWip();
3999
- }
4000
- }, []);
4001
4135
  const handleEnterInput = React.useCallback(
4002
- (event) => {
4136
+ (event, multiValueEdit) => {
4003
4137
  if (event.key === "Enter" && activeIndex != null) {
4004
4138
  if (!filteredDropDownItems[activeIndex]) {
4005
4139
  return;
4006
4140
  }
4007
- model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
4141
+ const selectedItem = filteredDropDownItems[activeIndex];
4142
+ if (multiValueEdit) {
4143
+ handleLocalMultiValueChange(selectedItem);
4144
+ } else {
4145
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
4146
+ switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
4147
+ setActiveIndex(0);
4148
+ }
4008
4149
  setInputValue("");
4009
- setActiveIndex(0);
4010
- switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
4011
4150
  }
4012
4151
  },
4013
- [activeIndex, filter, filterInputType, filteredDropDownItems, model]
4152
+ [
4153
+ activeIndex,
4154
+ filter,
4155
+ filterInputType,
4156
+ filteredDropDownItems,
4157
+ handleLocalMultiValueChange,
4158
+ handleChangeViewMode,
4159
+ model,
4160
+ refs.domReference
4161
+ ]
4014
4162
  );
4015
4163
  React.useEffect(() => {
4016
4164
  if (open) {
@@ -4018,13 +4166,34 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4018
4166
  }
4019
4167
  }, [open, filterInputType]);
4020
4168
  React.useEffect(() => {
4021
- var _a2;
4169
+ var _a2, _b2;
4022
4170
  if (!isAlwaysWip) {
4023
4171
  setInputType("value");
4024
4172
  setInputValue("");
4025
- (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
4173
+ if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
4174
+ const multiValueOptions = filter.values.reduce(
4175
+ (acc, value, i) => {
4176
+ var _a3;
4177
+ return [
4178
+ ...acc,
4179
+ {
4180
+ label: ((_a3 = filter.valueLabels) == null ? void 0 : _a3[i]) || value,
4181
+ value
4182
+ }
4183
+ ];
4184
+ },
4185
+ []
4186
+ );
4187
+ setFilterMultiValues(multiValueOptions);
4188
+ }
4189
+ (_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
4026
4190
  }
4027
4191
  }, []);
4192
+ React.useEffect(() => {
4193
+ if (isMultiValueEdit && filterMultiValues) {
4194
+ setTimeout(() => setForceRefresh({}));
4195
+ }
4196
+ }, [filterMultiValues, isMultiValueEdit]);
4028
4197
  React.useLayoutEffect(() => {
4029
4198
  var _a2, _b2;
4030
4199
  if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
@@ -4050,14 +4219,17 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4050
4219
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4051
4220
  },
4052
4221
  onKeyDown: (event) => {
4053
- handleShiftTabInput(event);
4222
+ handleShiftTabInput(event, hasMultiValueOperator);
4054
4223
  if (event.key === "Enter") {
4055
4224
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
4056
4225
  }
4057
4226
  }
4058
- }, filter.operator) : null, (filter == null ? void 0 : filter.key) && (filter == null ? void 0 : filter.operator) && (filter == null ? void 0 : filter.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React__default["default"].createElement("div", {
4059
- className: css.cx(styles.basePill, styles.valuePill)
4060
- }, valueLabel) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
4227
+ }, filter.operator) : null, isMultiValueEdit ? filterMultiValues.map((item, i) => /* @__PURE__ */ React__default["default"].createElement(MultiValuePill, {
4228
+ key: `${item.value}-${i}`,
4229
+ item,
4230
+ index: i,
4231
+ handleRemoveMultiValue
4232
+ })) : null) : null, /* @__PURE__ */ React__default["default"].createElement("input", __spreadProps$n(__spreadValues$A({}, getReferenceProps({
4061
4233
  ref: refs.setReference,
4062
4234
  onChange,
4063
4235
  value: inputValue,
@@ -4071,9 +4243,9 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4071
4243
  if (filterInputType === "operator") {
4072
4244
  handleShiftTabInput(event);
4073
4245
  }
4074
- handleBackspaceInput(event);
4075
- handleTabInput(event);
4076
- handleEnterInput(event);
4246
+ handleBackspaceInput(event, isMultiValueEdit);
4247
+ handleTabInput(event, isMultiValueEdit);
4248
+ handleEnterInput(event, isMultiValueEdit);
4077
4249
  }
4078
4250
  })), {
4079
4251
  className: css.cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
@@ -4093,7 +4265,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4093
4265
  initialFocus: -1,
4094
4266
  visuallyHiddenDismiss: true,
4095
4267
  modal: false
4096
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4268
+ }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4097
4269
  style: __spreadProps$n(__spreadValues$A({}, floatingStyles), {
4098
4270
  width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
4099
4271
  }),
@@ -4134,17 +4306,24 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4134
4306
  listRef.current[index] = node;
4135
4307
  },
4136
4308
  onClick(event) {
4309
+ var _a3;
4137
4310
  if (filterInputType !== "value") {
4138
4311
  event.stopPropagation();
4139
4312
  }
4140
- model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
4141
- setInputValue("");
4142
- switchToNextInputType(
4143
- filterInputType,
4144
- setInputType,
4145
- handleChangeViewMode,
4146
- refs.domReference.current
4147
- );
4313
+ if (isMultiValueEdit) {
4314
+ event.stopPropagation();
4315
+ handleLocalMultiValueChange(item);
4316
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
4317
+ } else {
4318
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
4319
+ setInputValue("");
4320
+ switchToNextInputType(
4321
+ filterInputType,
4322
+ setInputType,
4323
+ handleChangeViewMode,
4324
+ refs.domReference.current
4325
+ );
4326
+ }
4148
4327
  }
4149
4328
  })), {
4150
4329
  active: activeIndex === index,
@@ -4154,19 +4333,56 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4154
4333
  transform: `translateY(${virtualItem.start}px)`
4155
4334
  },
4156
4335
  "aria-setsize": filteredDropDownItems.length,
4157
- "aria-posinset": virtualItem.index + 1
4158
- }), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
4159
- }))))));
4336
+ "aria-posinset": virtualItem.index + 1,
4337
+ isMultiValueEdit,
4338
+ checked: filterMultiValues.some((val) => val.value === item.value)
4339
+ }), /* @__PURE__ */ React__default["default"].createElement("span", null, item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value), item.description ? /* @__PURE__ */ React__default["default"].createElement("div", {
4340
+ className: styles.descriptionText
4341
+ }, item.description) : null);
4342
+ }))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React__default["default"].createElement(MultiValueApplyButton, {
4343
+ onClick: () => handleMultiValueFilterCommit(model, filter, filterMultiValues),
4344
+ floatingElement: refs.floating.current,
4345
+ maxOptionWidth
4346
+ }) : null))));
4160
4347
  });
4348
+ const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
4349
+ var _a, _b;
4350
+ const styles = ui.useStyles2(getStyles$b);
4351
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
4352
+ className: css.cx(styles.basePill, styles.valuePill)
4353
+ }, /* @__PURE__ */ React__default["default"].createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
4354
+ onClick: (e) => {
4355
+ e.stopPropagation();
4356
+ e.preventDefault();
4357
+ handleRemoveMultiValue(item);
4358
+ },
4359
+ onKeyDownCapture: (e) => {
4360
+ if (e.key === "Enter") {
4361
+ e.preventDefault();
4362
+ e.stopPropagation();
4363
+ handleRemoveMultiValue(item);
4364
+ }
4365
+ },
4366
+ fill: "text",
4367
+ size: "sm",
4368
+ variant: "secondary",
4369
+ className: styles.removeButton,
4370
+ tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
4371
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
4372
+ name: "times",
4373
+ size: "md",
4374
+ id: `${item.value}-${index}`
4375
+ })));
4376
+ };
4161
4377
  const getStyles$b = (theme) => ({
4162
4378
  comboboxWrapper: css.css({
4163
4379
  display: "flex",
4164
- flexWrap: "nowrap"
4380
+ flexWrap: "wrap"
4165
4381
  }),
4166
4382
  pillWrapper: css.css({
4167
4383
  display: "flex",
4168
4384
  alignItems: "center",
4169
- whiteSpace: "nowrap"
4385
+ flexWrap: "wrap"
4170
4386
  }),
4171
4387
  basePill: css.css(__spreadProps$n(__spreadValues$A({
4172
4388
  display: "flex",
@@ -4191,7 +4407,8 @@ const getStyles$b = (theme) => ({
4191
4407
  }
4192
4408
  }),
4193
4409
  valuePill: css.css({
4194
- background: theme.colors.action.selected
4410
+ background: theme.colors.action.selected,
4411
+ padding: theme.spacing(0.125, 0, 0.125, 1)
4195
4412
  }),
4196
4413
  dropdownWrapper: css.css({
4197
4414
  backgroundColor: theme.colors.background.primary,
@@ -4224,6 +4441,25 @@ const getStyles$b = (theme) => ({
4224
4441
  "&:not(:first-child)": {
4225
4442
  borderTop: `1px solid ${theme.colors.border.weak}`
4226
4443
  }
4444
+ }),
4445
+ removeButton: css.css({
4446
+ marginInline: theme.spacing(0.5),
4447
+ height: "100%",
4448
+ padding: 0,
4449
+ cursor: "pointer",
4450
+ "&:hover": {
4451
+ color: theme.colors.text.primary
4452
+ }
4453
+ }),
4454
+ descriptionText: css.css(__spreadProps$n(__spreadValues$A({}, theme.typography.bodySmall), {
4455
+ color: theme.colors.text.secondary,
4456
+ paddingTop: theme.spacing(0.5)
4457
+ })),
4458
+ multiValueApply: css.css({
4459
+ position: "absolute",
4460
+ top: 0,
4461
+ left: 0,
4462
+ display: "flex"
4227
4463
  })
4228
4464
  });
4229
4465
 
@@ -4253,7 +4489,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
4253
4489
  const [shouldFocus, setShouldFocus] = React.useState(false);
4254
4490
  const pillWrapperRef = React.useRef(null);
4255
4491
  const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
4256
- const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
4492
+ const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b.join(", ")) || ((_c = filter.values) == null ? void 0 : _c.join(", ")) || filter.value;
4257
4493
  const handleChangeViewMode = React.useCallback(
4258
4494
  (event) => {
4259
4495
  event == null ? void 0 : event.stopPropagation();
@@ -4285,7 +4521,9 @@ function AdHocFilterPill({ filter, model, readOnly }) {
4285
4521
  "aria-label": `Edit filter with key ${keyLabel}`,
4286
4522
  tabIndex: 0,
4287
4523
  ref: pillWrapperRef
4288
- }, /* @__PURE__ */ React__default["default"].createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
4524
+ }, /* @__PURE__ */ React__default["default"].createElement("span", {
4525
+ className: styles.pillText
4526
+ }, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
4289
4527
  onClick: (e) => {
4290
4528
  e.stopPropagation();
4291
4529
  model._removeFilter(filter);
@@ -4341,6 +4579,9 @@ const getStyles$a = (theme) => ({
4341
4579
  "&:hover": {
4342
4580
  color: theme.colors.text.primary
4343
4581
  }
4582
+ }),
4583
+ pillText: css.css({
4584
+ whiteSpace: "break-spaces"
4344
4585
  })
4345
4586
  });
4346
4587
 
@@ -4606,7 +4847,7 @@ function renderExpression(builder, filters) {
4606
4847
  function AdHocFiltersVariableRenderer({ model }) {
4607
4848
  const { filters, readOnly, addFilterButtonText } = model.useState();
4608
4849
  const styles = ui.useStyles2(getStyles$8);
4609
- if (!model.state.supportsMultiValueOperators && model.state.layout === "combobox") {
4850
+ if (model.state.layout === "combobox") {
4610
4851
  return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
4611
4852
  model
4612
4853
  });