@grafana/scenes 5.14.1--canary.890.10722192103.0 → 5.14.2--canary.889.10727598270.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v5.14.1 (Thu Sep 05 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - TextBoxVariable: fixes issues with TextBox variable when being updated by URL [#890](https://github.com/grafana/scenes/pull/890) ([@torkelo](https://github.com/torkelo))
6
+
7
+ #### Authors: 1
8
+
9
+ - Torkel Ödegaard ([@torkelo](https://github.com/torkelo))
10
+
11
+ ---
12
+
1
13
  # v5.14.0 (Thu Sep 05 2024)
2
14
 
3
15
  #### 🚀 Enhancement
@@ -22,14 +22,14 @@ var __spreadValues = (a, b) => {
22
22
  return a;
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- function AdHocFilterPill({ filter, model, readOnly }) {
25
+ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
26
26
  var _a, _b, _c;
27
27
  const styles = useStyles2(getStyles);
28
28
  const [viewMode, setViewMode] = useState(true);
29
29
  const [shouldFocus, setShouldFocus] = useState(false);
30
30
  const pillWrapperRef = useRef(null);
31
31
  const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
32
- const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
32
+ const valueLabel = ((_b = filter.valueLabels) == null ? void 0 : _b.join(", ")) || ((_c = filter.values) == null ? void 0 : _c.join(", ")) || filter.value;
33
33
  const handleChangeViewMode = useCallback(
34
34
  (event) => {
35
35
  event == null ? void 0 : event.stopPropagation();
@@ -61,16 +61,20 @@ function AdHocFilterPill({ filter, model, readOnly }) {
61
61
  "aria-label": `Edit filter with key ${keyLabel}`,
62
62
  tabIndex: 0,
63
63
  ref: pillWrapperRef
64
- }, /* @__PURE__ */ React.createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
64
+ }, /* @__PURE__ */ React.createElement("span", {
65
+ className: styles.pillText
66
+ }, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
65
67
  onClick: (e) => {
66
68
  e.stopPropagation();
67
69
  model._removeFilter(filter);
70
+ setTimeout(() => focusOnInputRef == null ? void 0 : focusOnInputRef());
68
71
  },
69
72
  onKeyDownCapture: (e) => {
70
73
  if (e.key === "Enter") {
71
74
  e.preventDefault();
72
75
  e.stopPropagation();
73
76
  model._removeFilter(filter);
77
+ setTimeout(() => focusOnInputRef == null ? void 0 : focusOnInputRef());
74
78
  }
75
79
  },
76
80
  name: "times",
@@ -117,6 +121,9 @@ const getStyles = (theme) => ({
117
121
  "&:hover": {
118
122
  color: theme.colors.text.primary
119
123
  }
124
+ }),
125
+ pillText: css({
126
+ whiteSpace: "break-spaces"
120
127
  })
121
128
  });
122
129
 
@@ -1 +1 @@
1
- {"version":3,"file":"AdHocFilterPill.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2, IconButton } from '@grafana/ui';\nimport React, { useState, useRef, useCallback, useEffect } from 'react';\nimport { AdHocCombobox } from './AdHocFiltersCombobox';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\n\ninterface Props {\n filter: AdHocFilterWithLabels;\n model: AdHocFiltersVariable;\n readOnly?: boolean;\n}\n\nexport function AdHocFilterPill({ filter, model, readOnly }: Props) {\n const styles = useStyles2(getStyles);\n const [viewMode, setViewMode] = useState(true);\n const [shouldFocus, setShouldFocus] = useState(false);\n const pillWrapperRef = useRef<HTMLDivElement>(null);\n\n const keyLabel = filter.keyLabel ?? filter.key;\n const valueLabel = filter.valueLabels?.[0] ?? filter.value;\n\n const handleChangeViewMode = useCallback(\n (event?: React.MouseEvent) => {\n event?.stopPropagation();\n if (readOnly) {\n return;\n }\n\n setShouldFocus(!viewMode);\n setViewMode(!viewMode);\n },\n [readOnly, viewMode]\n );\n\n useEffect(() => {\n if (shouldFocus) {\n pillWrapperRef.current?.focus();\n setShouldFocus(false);\n }\n }, [shouldFocus]);\n\n if (viewMode) {\n return (\n <div\n className={cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly })}\n onClick={handleChangeViewMode}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleChangeViewMode();\n }\n }}\n role=\"button\"\n aria-label={`Edit filter with key ${keyLabel}`}\n tabIndex={0}\n ref={pillWrapperRef}\n >\n <span>\n {keyLabel} {filter.operator} {valueLabel}\n </span>\n {!readOnly ? (\n <IconButton\n onClick={(e) => {\n e.stopPropagation();\n model._removeFilter(filter);\n }}\n onKeyDownCapture={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n model._removeFilter(filter);\n }\n }}\n name=\"times\"\n size=\"md\"\n className={styles.removeButton}\n tooltip={`Remove filter with key ${keyLabel}`}\n />\n ) : null}\n </div>\n );\n }\n\n return <AdHocCombobox filter={filter} model={model} handleChangeViewMode={handleChangeViewMode} />;\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n combinedFilterPill: css({\n display: 'flex',\n alignItems: 'center',\n background: theme.colors.action.selected,\n borderRadius: theme.shape.radius.default,\n border: `1px solid ${theme.colors.border.weak}`,\n padding: theme.spacing(0.125, 0, 0.125, 1),\n color: theme.colors.text.primary,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n minHeight: theme.spacing(2.75),\n ...theme.typography.bodySmall,\n fontWeight: theme.typography.fontWeightBold,\n cursor: 'pointer',\n\n '&:hover': {\n background: theme.colors.action.hover,\n },\n }),\n readOnlyCombinedFilter: css({\n paddingRight: theme.spacing(1),\n cursor: 'text',\n '&:hover': {\n background: theme.colors.action.selected,\n },\n }),\n removeButton: css({\n marginInline: theme.spacing(0.5),\n cursor: 'pointer',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AA,IAC7B,MAAQ,EAAA,SAAA;AAAA,IAER,SAAW,EAAA;AAAA,MACT,UAAA,EAAY,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,KAAA;AAAA,KAClC;AAAA,GACD,CAAA,CAAA;AAAA,EACD,wBAAwB,GAAI,CAAA;AAAA,IAC1B,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC7B,MAAQ,EAAA,MAAA;AAAA,IACR,SAAW,EAAA;AAAA,MACT,UAAA,EAAY,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,QAAA;AAAA,KAClC;AAAA,GACD,CAAA;AAAA,EACD,cAAc,GAAI,CAAA;AAAA,IAChB,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC/B,MAAQ,EAAA,SAAA;AAAA,IACR,SAAW,EAAA;AAAA,MACT,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,OAAA;AAAA,KAC3B;AAAA,GACD,CAAA;AACH,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"AdHocFilterPill.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2, IconButton } from '@grafana/ui';\nimport React, { useState, useRef, useCallback, useEffect } from 'react';\nimport { AdHocCombobox } from './AdHocFiltersCombobox';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\n\ninterface Props {\n filter: AdHocFilterWithLabels;\n model: AdHocFiltersVariable;\n readOnly?: boolean;\n focusOnInputRef?: () => void;\n}\n\nexport function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }: Props) {\n const styles = useStyles2(getStyles);\n const [viewMode, setViewMode] = useState(true);\n const [shouldFocus, setShouldFocus] = useState(false);\n const pillWrapperRef = useRef<HTMLDivElement>(null);\n\n const keyLabel = filter.keyLabel ?? filter.key;\n // TODO remove when we're on the latest version of @grafana/data\n //@ts-expect-error\n const valueLabel = filter.valueLabels?.join(', ') || filter.values?.join(', ') || filter.value;\n\n const handleChangeViewMode = useCallback(\n (event?: React.MouseEvent) => {\n event?.stopPropagation();\n if (readOnly) {\n return;\n }\n\n setShouldFocus(!viewMode);\n setViewMode(!viewMode);\n },\n [readOnly, viewMode]\n );\n\n useEffect(() => {\n if (shouldFocus) {\n pillWrapperRef.current?.focus();\n setShouldFocus(false);\n }\n }, [shouldFocus]);\n\n if (viewMode) {\n return (\n <div\n className={cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly })}\n onClick={handleChangeViewMode}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleChangeViewMode();\n }\n }}\n role=\"button\"\n aria-label={`Edit filter with key ${keyLabel}`}\n tabIndex={0}\n ref={pillWrapperRef}\n >\n <span className={styles.pillText}>\n {keyLabel} {filter.operator} {valueLabel}\n </span>\n {!readOnly ? (\n <IconButton\n onClick={(e) => {\n e.stopPropagation();\n model._removeFilter(filter);\n setTimeout(() => focusOnInputRef?.());\n }}\n onKeyDownCapture={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n model._removeFilter(filter);\n setTimeout(() => focusOnInputRef?.());\n }\n }}\n name=\"times\"\n size=\"md\"\n className={styles.removeButton}\n tooltip={`Remove filter with key ${keyLabel}`}\n />\n ) : null}\n </div>\n );\n }\n\n return <AdHocCombobox filter={filter} model={model} handleChangeViewMode={handleChangeViewMode} />;\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n combinedFilterPill: css({\n display: 'flex',\n alignItems: 'center',\n background: theme.colors.action.selected,\n borderRadius: theme.shape.radius.default,\n border: `1px solid ${theme.colors.border.weak}`,\n padding: theme.spacing(0.125, 0, 0.125, 1),\n color: theme.colors.text.primary,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n minHeight: theme.spacing(2.75),\n ...theme.typography.bodySmall,\n fontWeight: theme.typography.fontWeightBold,\n cursor: 'pointer',\n\n '&:hover': {\n background: theme.colors.action.hover,\n },\n }),\n readOnlyCombinedFilter: css({\n paddingRight: theme.spacing(1),\n cursor: 'text',\n '&:hover': {\n background: theme.colors.action.selected,\n },\n }),\n removeButton: css({\n marginInline: theme.spacing(0.5),\n cursor: 'pointer',\n '&:hover': {\n color: theme.colors.text.primary,\n },\n }),\n pillText: css({\n whiteSpace: 'break-spaces',\n }),\n});\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,gBAAgB,EAAE,MAAA,EAAQ,KAAO,EAAA,QAAA,EAAU,iBAA0B,EAAA;AAdrF,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAeE,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,IAAI,CAAA,CAAA;AAC7C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACpD,EAAM,MAAA,cAAA,GAAiB,OAAuB,IAAI,CAAA,CAAA;AAElD,EAAA,MAAM,QAAW,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,QAAP,KAAA,IAAA,GAAA,EAAA,GAAmB,MAAO,CAAA,GAAA,CAAA;AAG3C,EAAM,MAAA,UAAA,GAAA,CAAA,CAAa,EAAO,GAAA,MAAA,CAAA,WAAA,KAAP,IAAoB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAK,IAAS,CAAA,MAAA,CAAA,EAAA,GAAA,MAAA,CAAO,MAAP,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAe,IAAK,CAAA,IAAA,CAAA,CAAA,IAAS,MAAO,CAAA,KAAA,CAAA;AAEzF,EAAA,MAAM,oBAAuB,GAAA,WAAA;AAAA,IAC3B,CAAC,KAA6B,K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3B;AAAA,GACD,CAAA;AAAA,EACD,UAAU,GAAI,CAAA;AAAA,IACZ,UAAY,EAAA,cAAA;AAAA,GACb,CAAA;AACH,CAAA,CAAA;;;;"}
@@ -1,10 +1,11 @@
1
- import React, { forwardRef, useState, useId, useRef, useMemo, useCallback, useImperativeHandle, useEffect, useLayoutEffect } from 'react';
1
+ import React, { forwardRef, useState, useMemo, useId, useRef, useCallback, useImperativeHandle, useEffect, useLayoutEffect } from 'react';
2
2
  import { FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
3
- import { useStyles2, Spinner, Text } from '@grafana/ui';
3
+ import { useStyles2, Spinner, Text, Button, Icon } from '@grafana/ui';
4
4
  import { cx, css } from '@emotion/css';
5
+ import { OPERATORS } from '../AdHocFiltersVariable.js';
5
6
  import { useVirtualizer } from '@tanstack/react-virtual';
6
- import { LoadingOptionsPlaceholder, OptionsErrorPlaceholder, NoOptionsPlaceholder, DropdownItem } from './DropdownItem.js';
7
- import { fuzzySearchOptions, flattenOptionGroups, setupDropdownAccessibility, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, generateFilterUpdatePayload, switchToNextInputType, switchInputType, ERROR_STATE_DROPDOWN_WIDTH } from './utils.js';
7
+ import { LoadingOptionsPlaceholder, OptionsErrorPlaceholder, NoOptionsPlaceholder, DropdownItem, MultiValueApplyButton } from './DropdownItem.js';
8
+ import { fuzzySearchOptions, flattenOptionGroups, setupDropdownAccessibility, VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, generateFilterUpdatePayload, switchToNextInputType, switchInputType, ERROR_STATE_DROPDOWN_WIDTH } from './utils.js';
8
9
  import { handleOptionGroups } from '../../utils.js';
9
10
  import { useFloatingInteractions } from './useFloatingInteractions.js';
10
11
 
@@ -37,6 +38,14 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
37
38
  const [activeIndex, setActiveIndex] = useState(null);
38
39
  const [filterInputType, setInputType] = useState(!isAlwaysWip ? "value" : "key");
39
40
  const styles = useStyles2(getStyles);
41
+ const [filterMultiValues, setFilterMultiValues] = useState([]);
42
+ const [_, setForceRefresh] = useState({});
43
+ const multiValueOperators = useMemo(
44
+ () => OPERATORS.reduce((acc, operator) => operator.isMulti ? [...acc, operator.value] : acc, []),
45
+ []
46
+ );
47
+ const hasMultiValueOperator = multiValueOperators.includes((filter == null ? void 0 : filter.operator) || "");
48
+ const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
40
49
  const operatorIdentifier = useId();
41
50
  const listRef = useRef([]);
42
51
  const disabledIndicesRef = useRef([]);
@@ -48,22 +57,66 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
48
57
  setInputValue("");
49
58
  }
50
59
  }, [model, isAlwaysWip]);
60
+ const handleMultiValueFilterCommit = useCallback(
61
+ (model2, filter2, filterMultiValues2, preventFocus) => {
62
+ if (filterMultiValues2.length) {
63
+ const valueLabels = [];
64
+ const values = [];
65
+ filterMultiValues2.forEach((item) => {
66
+ var _a2;
67
+ valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
68
+ values.push(item.value);
69
+ });
70
+ model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
71
+ setFilterMultiValues([]);
72
+ }
73
+ if (!preventFocus) {
74
+ setTimeout(() => {
75
+ var _a2;
76
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
77
+ });
78
+ }
79
+ },
80
+ []
81
+ );
82
+ const handleLocalMultiValueChange = useCallback((selectedItem) => {
83
+ setFilterMultiValues((items) => {
84
+ if (items.some((item) => item.value === selectedItem.value)) {
85
+ return items.filter((item) => item.value !== selectedItem.value);
86
+ }
87
+ return [...items, selectedItem];
88
+ });
89
+ }, []);
51
90
  const onOpenChange = useCallback(
52
- (nextOpen, _, reason) => {
91
+ (nextOpen, _2, reason) => {
53
92
  setOpen(nextOpen);
54
93
  if (reason && ["outside-press", "escape-key"].includes(reason)) {
94
+ if (isMultiValueEdit) {
95
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
96
+ }
55
97
  handleResetWip();
56
98
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
57
99
  }
58
100
  },
59
- [handleChangeViewMode, handleResetWip]
101
+ [
102
+ filter,
103
+ filterMultiValues,
104
+ handleChangeViewMode,
105
+ handleMultiValueFilterCommit,
106
+ handleResetWip,
107
+ isMultiValueEdit,
108
+ model
109
+ ]
60
110
  );
111
+ const outsidePressIdsToIgnore = useMemo(() => {
112
+ return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
113
+ }, [operatorIdentifier, filterMultiValues]);
61
114
  const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
62
115
  open,
63
116
  onOpenChange,
64
117
  activeIndex,
65
118
  setActiveIndex,
66
- operatorIdentifier,
119
+ outsidePressIdsToIgnore,
67
120
  listRef,
68
121
  disabledIndicesRef
69
122
  });
@@ -76,6 +129,16 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
76
129
  setInputValue(value);
77
130
  setActiveIndex(0);
78
131
  }
132
+ const handleRemoveMultiValue = useCallback(
133
+ (item) => {
134
+ setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value));
135
+ setTimeout(() => {
136
+ var _a2;
137
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
138
+ });
139
+ },
140
+ [refs.domReference]
141
+ );
79
142
  const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));
80
143
  if (filterInputType !== "operator" && inputValue) {
81
144
  filteredDropDownItems.push({
@@ -114,43 +177,89 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
114
177
  const rowVirtualizer = useVirtualizer({
115
178
  count: filteredDropDownItems.length,
116
179
  getScrollElement: () => refs.floating.current,
117
- estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
180
+ estimateSize: (index) => filteredDropDownItems[index].description ? VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION : VIRTUAL_LIST_ITEM_HEIGHT,
118
181
  overscan: VIRTUAL_LIST_OVERSCAN
119
182
  });
120
183
  const handleBackspaceInput = useCallback(
121
- (event) => {
122
- if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
123
- model._removeLastFilter();
124
- handleFetchOptions(filterInputType);
184
+ (event, multiValueEdit) => {
185
+ if (event.key === "Backspace" && !inputValue) {
186
+ if (multiValueEdit) {
187
+ setFilterMultiValues((items) => {
188
+ const updated = [...items];
189
+ updated.splice(-1, 1);
190
+ return updated;
191
+ });
192
+ } else if (filterInputType === "key") {
193
+ model._removeLastFilter();
194
+ handleFetchOptions(filterInputType);
195
+ }
125
196
  }
126
197
  },
127
- [inputValue, filterInputType]
198
+ [inputValue, filterInputType, model, handleFetchOptions]
199
+ );
200
+ const handleTabInput = useCallback(
201
+ (event, multiValueEdit) => {
202
+ var _a2;
203
+ if (event.key === "Tab" && !event.shiftKey) {
204
+ if (multiValueEdit) {
205
+ event.preventDefault();
206
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
207
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
208
+ }
209
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
210
+ handleResetWip();
211
+ }
212
+ },
213
+ [
214
+ filter,
215
+ filterMultiValues,
216
+ handleChangeViewMode,
217
+ handleMultiValueFilterCommit,
218
+ handleResetWip,
219
+ model,
220
+ refs.domReference
221
+ ]
222
+ );
223
+ const handleShiftTabInput = useCallback(
224
+ (event, multiValueEdit) => {
225
+ if (event.key === "Tab" && event.shiftKey) {
226
+ if (multiValueEdit) {
227
+ event.preventDefault();
228
+ handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
229
+ }
230
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
231
+ handleResetWip();
232
+ }
233
+ },
234
+ [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]
128
235
  );
129
- const handleTabInput = useCallback((event) => {
130
- if (event.key === "Tab" && !event.shiftKey) {
131
- handleChangeViewMode == null ? void 0 : handleChangeViewMode();
132
- handleResetWip();
133
- }
134
- }, []);
135
- const handleShiftTabInput = useCallback((event) => {
136
- if (event.key === "Tab" && event.shiftKey) {
137
- handleChangeViewMode == null ? void 0 : handleChangeViewMode();
138
- handleResetWip();
139
- }
140
- }, []);
141
236
  const handleEnterInput = useCallback(
142
- (event) => {
237
+ (event, multiValueEdit) => {
143
238
  if (event.key === "Enter" && activeIndex != null) {
144
239
  if (!filteredDropDownItems[activeIndex]) {
145
240
  return;
146
241
  }
147
- model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
242
+ const selectedItem = filteredDropDownItems[activeIndex];
243
+ if (multiValueEdit) {
244
+ handleLocalMultiValueChange(selectedItem);
245
+ } else {
246
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
247
+ switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
248
+ setActiveIndex(0);
249
+ }
148
250
  setInputValue("");
149
- setActiveIndex(0);
150
- switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
151
251
  }
152
252
  },
153
- [activeIndex, filter, filterInputType, filteredDropDownItems, model]
253
+ [
254
+ activeIndex,
255
+ filter,
256
+ filterInputType,
257
+ filteredDropDownItems,
258
+ handleLocalMultiValueChange,
259
+ handleChangeViewMode,
260
+ model,
261
+ refs.domReference
262
+ ]
154
263
  );
155
264
  useEffect(() => {
156
265
  if (open) {
@@ -158,13 +267,34 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
158
267
  }
159
268
  }, [open, filterInputType]);
160
269
  useEffect(() => {
161
- var _a2;
270
+ var _a2, _b2;
162
271
  if (!isAlwaysWip) {
163
272
  setInputType("value");
164
273
  setInputValue("");
165
- (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
274
+ if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
275
+ const multiValueOptions = filter.values.reduce(
276
+ (acc, value, i) => {
277
+ var _a3;
278
+ return [
279
+ ...acc,
280
+ {
281
+ label: ((_a3 = filter.valueLabels) == null ? void 0 : _a3[i]) || value,
282
+ value
283
+ }
284
+ ];
285
+ },
286
+ []
287
+ );
288
+ setFilterMultiValues(multiValueOptions);
289
+ }
290
+ (_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
166
291
  }
167
292
  }, []);
293
+ useEffect(() => {
294
+ if (isMultiValueEdit && filterMultiValues) {
295
+ setTimeout(() => setForceRefresh({}));
296
+ }
297
+ }, [filterMultiValues, isMultiValueEdit]);
168
298
  useLayoutEffect(() => {
169
299
  var _a2, _b2;
170
300
  if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
@@ -190,14 +320,17 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
190
320
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
191
321
  },
192
322
  onKeyDown: (event) => {
193
- handleShiftTabInput(event);
323
+ handleShiftTabInput(event, hasMultiValueOperator);
194
324
  if (event.key === "Enter") {
195
325
  switchInputType("operator", setInputType, void 0, refs.domReference.current);
196
326
  }
197
327
  }
198
- }, 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.createElement("div", {
199
- className: cx(styles.basePill, styles.valuePill)
200
- }, valueLabel) : null) : null, /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, getReferenceProps({
328
+ }, filter.operator) : null, isMultiValueEdit ? filterMultiValues.map((item, i) => /* @__PURE__ */ React.createElement(MultiValuePill, {
329
+ key: `${item.value}-${i}`,
330
+ item,
331
+ index: i,
332
+ handleRemoveMultiValue
333
+ })) : null) : null, /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, getReferenceProps({
201
334
  ref: refs.setReference,
202
335
  onChange,
203
336
  value: inputValue,
@@ -211,9 +344,9 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
211
344
  if (filterInputType === "operator") {
212
345
  handleShiftTabInput(event);
213
346
  }
214
- handleBackspaceInput(event);
215
- handleTabInput(event);
216
- handleEnterInput(event);
347
+ handleBackspaceInput(event, isMultiValueEdit);
348
+ handleTabInput(event, isMultiValueEdit);
349
+ handleEnterInput(event, isMultiValueEdit);
217
350
  }
218
351
  })), {
219
352
  className: cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
@@ -233,7 +366,7 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
233
366
  initialFocus: -1,
234
367
  visuallyHiddenDismiss: true,
235
368
  modal: false
236
- }, /* @__PURE__ */ React.createElement("div", {
369
+ }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
237
370
  style: __spreadProps(__spreadValues({}, floatingStyles), {
238
371
  width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
239
372
  }),
@@ -274,17 +407,25 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
274
407
  listRef.current[index] = node;
275
408
  },
276
409
  onClick(event) {
410
+ var _a3;
277
411
  if (filterInputType !== "value") {
278
412
  event.stopPropagation();
279
413
  }
280
- model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
281
- setInputValue("");
282
- switchToNextInputType(
283
- filterInputType,
284
- setInputType,
285
- handleChangeViewMode,
286
- refs.domReference.current
287
- );
414
+ if (isMultiValueEdit) {
415
+ event.preventDefault();
416
+ event.stopPropagation();
417
+ handleLocalMultiValueChange(item);
418
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
419
+ } else {
420
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
421
+ setInputValue("");
422
+ switchToNextInputType(
423
+ filterInputType,
424
+ setInputType,
425
+ handleChangeViewMode,
426
+ refs.domReference.current
427
+ );
428
+ }
288
429
  }
289
430
  })), {
290
431
  active: activeIndex === index,
@@ -294,19 +435,56 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
294
435
  transform: `translateY(${virtualItem.start}px)`
295
436
  },
296
437
  "aria-setsize": filteredDropDownItems.length,
297
- "aria-posinset": virtualItem.index + 1
298
- }), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
299
- }))))));
438
+ "aria-posinset": virtualItem.index + 1,
439
+ isMultiValueEdit,
440
+ checked: filterMultiValues.some((val) => val.value === item.value)
441
+ }), /* @__PURE__ */ React.createElement("span", null, item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value), item.description ? /* @__PURE__ */ React.createElement("div", {
442
+ className: styles.descriptionText
443
+ }, item.description) : null);
444
+ }))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React.createElement(MultiValueApplyButton, {
445
+ onClick: () => handleMultiValueFilterCommit(model, filter, filterMultiValues),
446
+ floatingElement: refs.floating.current,
447
+ maxOptionWidth
448
+ }) : null))));
300
449
  });
450
+ const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
451
+ var _a, _b;
452
+ const styles = useStyles2(getStyles);
453
+ return /* @__PURE__ */ React.createElement("div", {
454
+ className: cx(styles.basePill, styles.valuePill)
455
+ }, /* @__PURE__ */ React.createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React.createElement(Button, {
456
+ onClick: (e) => {
457
+ e.stopPropagation();
458
+ e.preventDefault();
459
+ handleRemoveMultiValue(item);
460
+ },
461
+ onKeyDownCapture: (e) => {
462
+ if (e.key === "Enter") {
463
+ e.preventDefault();
464
+ e.stopPropagation();
465
+ handleRemoveMultiValue(item);
466
+ }
467
+ },
468
+ fill: "text",
469
+ size: "sm",
470
+ variant: "secondary",
471
+ className: styles.removeButton,
472
+ tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
473
+ }, /* @__PURE__ */ React.createElement(Icon, {
474
+ name: "times",
475
+ size: "md",
476
+ id: `${item.value}-${index}`
477
+ })));
478
+ };
301
479
  const getStyles = (theme) => ({
302
480
  comboboxWrapper: css({
303
481
  display: "flex",
304
- flexWrap: "nowrap"
482
+ flexWrap: "wrap"
305
483
  }),
306
484
  pillWrapper: css({
307
485
  display: "flex",
308
486
  alignItems: "center",
309
- whiteSpace: "nowrap"
487
+ flexWrap: "wrap"
310
488
  }),
311
489
  basePill: css(__spreadProps(__spreadValues({
312
490
  display: "flex",
@@ -331,7 +509,8 @@ const getStyles = (theme) => ({
331
509
  }
332
510
  }),
333
511
  valuePill: css({
334
- background: theme.colors.action.selected
512
+ background: theme.colors.action.selected,
513
+ padding: theme.spacing(0.125, 0, 0.125, 1)
335
514
  }),
336
515
  dropdownWrapper: css({
337
516
  backgroundColor: theme.colors.background.primary,
@@ -364,6 +543,25 @@ const getStyles = (theme) => ({
364
543
  "&:not(:first-child)": {
365
544
  borderTop: `1px solid ${theme.colors.border.weak}`
366
545
  }
546
+ }),
547
+ removeButton: css({
548
+ marginInline: theme.spacing(0.5),
549
+ height: "100%",
550
+ padding: 0,
551
+ cursor: "pointer",
552
+ "&:hover": {
553
+ color: theme.colors.text.primary
554
+ }
555
+ }),
556
+ descriptionText: css(__spreadProps(__spreadValues({}, theme.typography.bodySmall), {
557
+ color: theme.colors.text.secondary,
558
+ paddingTop: theme.spacing(0.5)
559
+ })),
560
+ multiValueApply: css({
561
+ position: "absolute",
562
+ top: 0,
563
+ left: 0,
564
+ display: "flex"
367
565
  })
368
566
  });
369
567