@grafana/scenes 5.14.1 → 5.14.2--canary.889.10728276286.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.
@@ -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',\n '&:hover': {\n color: theme.colors.text.primary,\n },\n }),\n});\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,eAAgB,CAAA,EAAE,MAAQ,EAAA,KAAA,EAAO,UAAmB,EAAA;AAbpE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAcE,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,QAAA,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A;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"],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AAG,OAAO,CAAC,CAAA;AAAA,IACzC,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,OAAA;AAAA,IACzB,QAAU,EAAA,QAAA;AAAA,IACV,UAAY,EAAA,QAAA;AAAA,IACZ,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,GAC1B,EAAA,KAAA,CAAM,WAAW,SAXE,CAAA,EAAA;AAAA,IAYtB,UAAA,EAAY,MAAM,UAAW,CAAA,cAAA;AAAA,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;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, useRef, useMemo, useId, 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, generatePlaceholder, 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,15 @@ 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 multiValuePillWrapperRef = useRef(null);
44
+ const multiValueOperators = useMemo(
45
+ () => OPERATORS.reduce((acc, operator) => operator.isMulti ? [...acc, operator.value] : acc, []),
46
+ []
47
+ );
48
+ const hasMultiValueOperator = multiValueOperators.includes((filter == null ? void 0 : filter.operator) || "");
49
+ const isMultiValueEdit = hasMultiValueOperator && filterInputType === "value";
40
50
  const operatorIdentifier = useId();
41
51
  const listRef = useRef([]);
42
52
  const disabledIndicesRef = useRef([]);
@@ -48,22 +58,66 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
48
58
  setInputValue("");
49
59
  }
50
60
  }, [model, isAlwaysWip]);
61
+ const handleMultiValueFilterCommit = useCallback(
62
+ (model2, filter2, filterMultiValues2, preventFocus) => {
63
+ if (filterMultiValues2.length) {
64
+ const valueLabels = [];
65
+ const values = [];
66
+ filterMultiValues2.forEach((item) => {
67
+ var _a2;
68
+ valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
69
+ values.push(item.value);
70
+ });
71
+ model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
72
+ setFilterMultiValues([]);
73
+ }
74
+ if (!preventFocus) {
75
+ setTimeout(() => {
76
+ var _a2;
77
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
78
+ });
79
+ }
80
+ },
81
+ []
82
+ );
83
+ const handleLocalMultiValueChange = useCallback((selectedItem) => {
84
+ setFilterMultiValues((items) => {
85
+ if (items.some((item) => item.value === selectedItem.value)) {
86
+ return items.filter((item) => item.value !== selectedItem.value);
87
+ }
88
+ return [...items, selectedItem];
89
+ });
90
+ }, []);
51
91
  const onOpenChange = useCallback(
52
- (nextOpen, _, reason) => {
92
+ (nextOpen, _2, reason) => {
53
93
  setOpen(nextOpen);
54
94
  if (reason && ["outside-press", "escape-key"].includes(reason)) {
95
+ if (isMultiValueEdit) {
96
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
97
+ }
55
98
  handleResetWip();
56
99
  handleChangeViewMode == null ? void 0 : handleChangeViewMode();
57
100
  }
58
101
  },
59
- [handleChangeViewMode, handleResetWip]
102
+ [
103
+ filter,
104
+ filterMultiValues,
105
+ handleChangeViewMode,
106
+ handleMultiValueFilterCommit,
107
+ handleResetWip,
108
+ isMultiValueEdit,
109
+ model
110
+ ]
60
111
  );
112
+ const outsidePressIdsToIgnore = useMemo(() => {
113
+ return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
114
+ }, [operatorIdentifier, filterMultiValues]);
61
115
  const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
62
116
  open,
63
117
  onOpenChange,
64
118
  activeIndex,
65
119
  setActiveIndex,
66
- operatorIdentifier,
120
+ outsidePressIdsToIgnore,
67
121
  listRef,
68
122
  disabledIndicesRef
69
123
  });
@@ -76,6 +130,16 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
76
130
  setInputValue(value);
77
131
  setActiveIndex(0);
78
132
  }
133
+ const handleRemoveMultiValue = useCallback(
134
+ (item) => {
135
+ setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value));
136
+ setTimeout(() => {
137
+ var _a2;
138
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
139
+ });
140
+ },
141
+ [refs.domReference]
142
+ );
79
143
  const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));
80
144
  if (filterInputType !== "operator" && inputValue) {
81
145
  filteredDropDownItems.push({
@@ -114,43 +178,89 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
114
178
  const rowVirtualizer = useVirtualizer({
115
179
  count: filteredDropDownItems.length,
116
180
  getScrollElement: () => refs.floating.current,
117
- estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
181
+ estimateSize: (index) => filteredDropDownItems[index].description ? VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION : VIRTUAL_LIST_ITEM_HEIGHT,
118
182
  overscan: VIRTUAL_LIST_OVERSCAN
119
183
  });
120
184
  const handleBackspaceInput = useCallback(
121
- (event) => {
122
- if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
123
- model._removeLastFilter();
124
- handleFetchOptions(filterInputType);
185
+ (event, multiValueEdit) => {
186
+ if (event.key === "Backspace" && !inputValue) {
187
+ if (multiValueEdit) {
188
+ setFilterMultiValues((items) => {
189
+ const updated = [...items];
190
+ updated.splice(-1, 1);
191
+ return updated;
192
+ });
193
+ } else if (filterInputType === "key") {
194
+ model._removeLastFilter();
195
+ handleFetchOptions(filterInputType);
196
+ }
125
197
  }
126
198
  },
127
- [inputValue, filterInputType]
199
+ [inputValue, filterInputType, model, handleFetchOptions]
200
+ );
201
+ const handleTabInput = useCallback(
202
+ (event, multiValueEdit) => {
203
+ var _a2;
204
+ if (event.key === "Tab" && !event.shiftKey) {
205
+ if (multiValueEdit) {
206
+ event.preventDefault();
207
+ handleMultiValueFilterCommit(model, filter, filterMultiValues);
208
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
209
+ }
210
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
211
+ handleResetWip();
212
+ }
213
+ },
214
+ [
215
+ filter,
216
+ filterMultiValues,
217
+ handleChangeViewMode,
218
+ handleMultiValueFilterCommit,
219
+ handleResetWip,
220
+ model,
221
+ refs.domReference
222
+ ]
223
+ );
224
+ const handleShiftTabInput = useCallback(
225
+ (event, multiValueEdit) => {
226
+ if (event.key === "Tab" && event.shiftKey) {
227
+ if (multiValueEdit) {
228
+ event.preventDefault();
229
+ handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
230
+ }
231
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
232
+ handleResetWip();
233
+ }
234
+ },
235
+ [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]
128
236
  );
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
237
  const handleEnterInput = useCallback(
142
- (event) => {
238
+ (event, multiValueEdit) => {
143
239
  if (event.key === "Enter" && activeIndex != null) {
144
240
  if (!filteredDropDownItems[activeIndex]) {
145
241
  return;
146
242
  }
147
- model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
243
+ const selectedItem = filteredDropDownItems[activeIndex];
244
+ if (multiValueEdit) {
245
+ handleLocalMultiValueChange(selectedItem);
246
+ } else {
247
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
248
+ switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
249
+ setActiveIndex(0);
250
+ }
148
251
  setInputValue("");
149
- setActiveIndex(0);
150
- switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
151
252
  }
152
253
  },
153
- [activeIndex, filter, filterInputType, filteredDropDownItems, model]
254
+ [
255
+ activeIndex,
256
+ filter,
257
+ filterInputType,
258
+ filteredDropDownItems,
259
+ handleLocalMultiValueChange,
260
+ handleChangeViewMode,
261
+ model,
262
+ refs.domReference
263
+ ]
154
264
  );
155
265
  useEffect(() => {
156
266
  if (open) {
@@ -158,13 +268,34 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
158
268
  }
159
269
  }, [open, filterInputType]);
160
270
  useEffect(() => {
161
- var _a2;
271
+ var _a2, _b2;
162
272
  if (!isAlwaysWip) {
163
273
  setInputType("value");
164
274
  setInputValue("");
165
- (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
275
+ if (hasMultiValueOperator && ((_a2 = filter == null ? void 0 : filter.values) == null ? void 0 : _a2.length)) {
276
+ const multiValueOptions = filter.values.reduce(
277
+ (acc, value, i) => {
278
+ var _a3;
279
+ return [
280
+ ...acc,
281
+ {
282
+ label: ((_a3 = filter.valueLabels) == null ? void 0 : _a3[i]) || value,
283
+ value
284
+ }
285
+ ];
286
+ },
287
+ []
288
+ );
289
+ setFilterMultiValues(multiValueOptions);
290
+ }
291
+ (_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
166
292
  }
167
293
  }, []);
294
+ useEffect(() => {
295
+ if (isMultiValueEdit && filterMultiValues) {
296
+ setTimeout(() => setForceRefresh({}));
297
+ }
298
+ }, [filterMultiValues, isMultiValueEdit]);
168
299
  useLayoutEffect(() => {
169
300
  var _a2, _b2;
170
301
  if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
@@ -172,7 +303,6 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
172
303
  }
173
304
  }, [activeIndex, rowVirtualizer]);
174
305
  const keyLabel = (_a = filter == null ? void 0 : filter.keyLabel) != null ? _a : filter == null ? void 0 : filter.key;
175
- const valueLabel = (_c = (_b = filter == null ? void 0 : filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter == null ? void 0 : filter.value;
176
306
  return /* @__PURE__ */ React.createElement("div", {
177
307
  className: styles.comboboxWrapper
178
308
  }, filter ? /* @__PURE__ */ React.createElement("div", {
@@ -190,18 +320,23 @@ 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, /* @__PURE__ */ React.createElement("div", {
329
+ ref: multiValuePillWrapperRef
330
+ }), isMultiValueEdit ? filterMultiValues.map((item, i) => /* @__PURE__ */ React.createElement(MultiValuePill, {
331
+ key: `${item.value}-${i}`,
332
+ item,
333
+ index: i,
334
+ handleRemoveMultiValue
335
+ })) : null) : null, /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, getReferenceProps({
201
336
  ref: refs.setReference,
202
337
  onChange,
203
338
  value: inputValue,
204
- placeholder: !isAlwaysWip ? filterInputType === "operator" ? `${filter[filterInputType]} ${valueLabel}` : filter[filterInputType] : "Filter by label values",
339
+ placeholder: generatePlaceholder(filter, filterInputType, isMultiValueEdit, isAlwaysWip),
205
340
  "aria-autocomplete": "list",
206
341
  onKeyDown(event) {
207
342
  if (!open) {
@@ -211,9 +346,9 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
211
346
  if (filterInputType === "operator") {
212
347
  handleShiftTabInput(event);
213
348
  }
214
- handleBackspaceInput(event);
215
- handleTabInput(event);
216
- handleEnterInput(event);
349
+ handleBackspaceInput(event, isMultiValueEdit);
350
+ handleTabInput(event, isMultiValueEdit);
351
+ handleEnterInput(event, isMultiValueEdit);
217
352
  }
218
353
  })), {
219
354
  className: cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
@@ -233,9 +368,10 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
233
368
  initialFocus: -1,
234
369
  visuallyHiddenDismiss: true,
235
370
  modal: false
236
- }, /* @__PURE__ */ React.createElement("div", {
371
+ }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
237
372
  style: __spreadProps(__spreadValues({}, floatingStyles), {
238
- width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
373
+ width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,
374
+ 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
239
375
  }),
240
376
  ref: refs.setFloating,
241
377
  className: styles.dropdownWrapper,
@@ -274,17 +410,25 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
274
410
  listRef.current[index] = node;
275
411
  },
276
412
  onClick(event) {
413
+ var _a3;
277
414
  if (filterInputType !== "value") {
278
415
  event.stopPropagation();
279
416
  }
280
- model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
281
- setInputValue("");
282
- switchToNextInputType(
283
- filterInputType,
284
- setInputType,
285
- handleChangeViewMode,
286
- refs.domReference.current
287
- );
417
+ if (isMultiValueEdit) {
418
+ event.preventDefault();
419
+ event.stopPropagation();
420
+ handleLocalMultiValueChange(item);
421
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
422
+ } else {
423
+ model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
424
+ setInputValue("");
425
+ switchToNextInputType(
426
+ filterInputType,
427
+ setInputType,
428
+ handleChangeViewMode,
429
+ refs.domReference.current
430
+ );
431
+ }
288
432
  }
289
433
  })), {
290
434
  active: activeIndex === index,
@@ -294,19 +438,56 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
294
438
  transform: `translateY(${virtualItem.start}px)`
295
439
  },
296
440
  "aria-setsize": filteredDropDownItems.length,
297
- "aria-posinset": virtualItem.index + 1
298
- }), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
299
- }))))));
441
+ "aria-posinset": virtualItem.index + 1,
442
+ isMultiValueEdit,
443
+ checked: filterMultiValues.some((val) => val.value === item.value)
444
+ }), /* @__PURE__ */ React.createElement("span", null, item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value), item.description ? /* @__PURE__ */ React.createElement("div", {
445
+ className: styles.descriptionText
446
+ }, item.description) : null);
447
+ }))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React.createElement(MultiValueApplyButton, {
448
+ onClick: () => handleMultiValueFilterCommit(model, filter, filterMultiValues),
449
+ floatingElement: refs.floating.current,
450
+ maxOptionWidth
451
+ }) : null))));
300
452
  });
453
+ const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
454
+ var _a, _b;
455
+ const styles = useStyles2(getStyles);
456
+ return /* @__PURE__ */ React.createElement("div", {
457
+ className: cx(styles.basePill, styles.valuePill)
458
+ }, /* @__PURE__ */ React.createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React.createElement(Button, {
459
+ onClick: (e) => {
460
+ e.stopPropagation();
461
+ e.preventDefault();
462
+ handleRemoveMultiValue(item);
463
+ },
464
+ onKeyDownCapture: (e) => {
465
+ if (e.key === "Enter") {
466
+ e.preventDefault();
467
+ e.stopPropagation();
468
+ handleRemoveMultiValue(item);
469
+ }
470
+ },
471
+ fill: "text",
472
+ size: "sm",
473
+ variant: "secondary",
474
+ className: styles.removeButton,
475
+ tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
476
+ }, /* @__PURE__ */ React.createElement(Icon, {
477
+ name: "times",
478
+ size: "md",
479
+ id: `${item.value}-${index}`
480
+ })));
481
+ };
301
482
  const getStyles = (theme) => ({
302
483
  comboboxWrapper: css({
303
484
  display: "flex",
304
- flexWrap: "nowrap"
485
+ flexWrap: "wrap"
305
486
  }),
306
487
  pillWrapper: css({
307
488
  display: "flex",
308
489
  alignItems: "center",
309
- whiteSpace: "nowrap"
490
+ flexWrap: "wrap"
310
491
  }),
311
492
  basePill: css(__spreadProps(__spreadValues({
312
493
  display: "flex",
@@ -331,7 +512,8 @@ const getStyles = (theme) => ({
331
512
  }
332
513
  }),
333
514
  valuePill: css({
334
- background: theme.colors.action.selected
515
+ background: theme.colors.action.selected,
516
+ padding: theme.spacing(0.125, 0, 0.125, 1)
335
517
  }),
336
518
  dropdownWrapper: css({
337
519
  backgroundColor: theme.colors.background.primary,
@@ -364,6 +546,25 @@ const getStyles = (theme) => ({
364
546
  "&:not(:first-child)": {
365
547
  borderTop: `1px solid ${theme.colors.border.weak}`
366
548
  }
549
+ }),
550
+ removeButton: css({
551
+ marginInline: theme.spacing(0.5),
552
+ height: "100%",
553
+ padding: 0,
554
+ cursor: "pointer",
555
+ "&:hover": {
556
+ color: theme.colors.text.primary
557
+ }
558
+ }),
559
+ descriptionText: css(__spreadProps(__spreadValues({}, theme.typography.bodySmall), {
560
+ color: theme.colors.text.secondary,
561
+ paddingTop: theme.spacing(0.5)
562
+ })),
563
+ multiValueApply: css({
564
+ position: "absolute",
565
+ top: 0,
566
+ left: 0,
567
+ display: "flex"
367
568
  })
368
569
  });
369
570