@grafana/scenes 5.14.1--canary.889.10722729172.0 → 5.14.1--canary.890.10722192103.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +2 -7
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +54 -245
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js +4 -40
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.js +2 -8
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +2 -6
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +2 -2
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/components/VariableValueInput.js +1 -1
- package/dist/esm/variables/components/VariableValueInput.js.map +1 -1
- package/dist/esm/variables/variants/TextBoxVariable.js +1 -3
- package/dist/esm/variables/variants/TextBoxVariable.js.map +1 -1
- package/dist/index.js +60 -303
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
@@ -29,7 +29,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
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 = ((_b = filter.valueLabels) == null ? void 0 : _b
|
32
|
+
const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
|
33
33
|
const handleChangeViewMode = useCallback(
|
34
34
|
(event) => {
|
35
35
|
event == null ? void 0 : event.stopPropagation();
|
@@ -61,9 +61,7 @@ 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", {
|
65
|
-
className: styles.pillText
|
66
|
-
}, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
|
64
|
+
}, /* @__PURE__ */ React.createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
|
67
65
|
onClick: (e) => {
|
68
66
|
e.stopPropagation();
|
69
67
|
model._removeFilter(filter);
|
@@ -119,9 +117,6 @@ const getStyles = (theme) => ({
|
|
119
117
|
"&:hover": {
|
120
118
|
color: theme.colors.text.primary
|
121
119
|
}
|
122
|
-
}),
|
123
|
-
pillText: css({
|
124
|
-
whiteSpace: "break-spaces"
|
125
120
|
})
|
126
121
|
});
|
127
122
|
|
@@ -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
|
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,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,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AAA,IACR,SAAW,EAAA;AAAA,MACT,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,OAAA;AAAA,KAC3B;AAAA,GACD,CAAA;AACH,CAAA,CAAA;;;;"}
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import React, { forwardRef, useState,
|
1
|
+
import React, { forwardRef, useState, useId, useRef, useMemo, useCallback, useImperativeHandle, useEffect, useLayoutEffect } from 'react';
|
2
2
|
import { FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
3
|
-
import { useStyles2, Spinner, Text
|
3
|
+
import { useStyles2, Spinner, Text } from '@grafana/ui';
|
4
4
|
import { cx, css } from '@emotion/css';
|
5
|
-
import { OPERATORS } from '../AdHocFiltersVariable.js';
|
6
5
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
7
|
-
import { LoadingOptionsPlaceholder, OptionsErrorPlaceholder, NoOptionsPlaceholder, DropdownItem
|
8
|
-
import { fuzzySearchOptions, flattenOptionGroups, setupDropdownAccessibility,
|
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';
|
9
8
|
import { handleOptionGroups } from '../../utils.js';
|
10
9
|
import { useFloatingInteractions } from './useFloatingInteractions.js';
|
11
10
|
|
@@ -38,14 +37,6 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
38
37
|
const [activeIndex, setActiveIndex] = useState(null);
|
39
38
|
const [filterInputType, setInputType] = useState(!isAlwaysWip ? "value" : "key");
|
40
39
|
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";
|
49
40
|
const operatorIdentifier = useId();
|
50
41
|
const listRef = useRef([]);
|
51
42
|
const disabledIndicesRef = useRef([]);
|
@@ -57,70 +48,22 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
57
48
|
setInputValue("");
|
58
49
|
}
|
59
50
|
}, [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
|
-
}, []);
|
90
|
-
const handleRemoveMultiValue = useCallback(
|
91
|
-
(item) => setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value)),
|
92
|
-
[]
|
93
|
-
);
|
94
51
|
const onOpenChange = useCallback(
|
95
|
-
(nextOpen,
|
52
|
+
(nextOpen, _, reason) => {
|
96
53
|
setOpen(nextOpen);
|
97
54
|
if (reason && ["outside-press", "escape-key"].includes(reason)) {
|
98
|
-
if (isMultiValueEdit) {
|
99
|
-
handleMultiValueFilterCommit(model, filter, filterMultiValues);
|
100
|
-
}
|
101
55
|
handleResetWip();
|
102
56
|
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
103
57
|
}
|
104
58
|
},
|
105
|
-
[
|
106
|
-
filter,
|
107
|
-
filterMultiValues,
|
108
|
-
handleChangeViewMode,
|
109
|
-
handleMultiValueFilterCommit,
|
110
|
-
handleResetWip,
|
111
|
-
isMultiValueEdit,
|
112
|
-
model
|
113
|
-
]
|
59
|
+
[handleChangeViewMode, handleResetWip]
|
114
60
|
);
|
115
|
-
const outsidePressIdsToIgnore = useMemo(() => {
|
116
|
-
return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];
|
117
|
-
}, [operatorIdentifier, filterMultiValues]);
|
118
61
|
const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({
|
119
62
|
open,
|
120
63
|
onOpenChange,
|
121
64
|
activeIndex,
|
122
65
|
setActiveIndex,
|
123
|
-
|
66
|
+
operatorIdentifier,
|
124
67
|
listRef,
|
125
68
|
disabledIndicesRef
|
126
69
|
});
|
@@ -171,89 +114,43 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
171
114
|
const rowVirtualizer = useVirtualizer({
|
172
115
|
count: filteredDropDownItems.length,
|
173
116
|
getScrollElement: () => refs.floating.current,
|
174
|
-
estimateSize: (
|
117
|
+
estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,
|
175
118
|
overscan: VIRTUAL_LIST_OVERSCAN
|
176
119
|
});
|
177
120
|
const handleBackspaceInput = useCallback(
|
178
|
-
(event
|
179
|
-
if (event.key === "Backspace" && !inputValue) {
|
180
|
-
|
181
|
-
|
182
|
-
const updated = [...items];
|
183
|
-
updated.splice(-1, 1);
|
184
|
-
return updated;
|
185
|
-
});
|
186
|
-
} else if (filterInputType === "key") {
|
187
|
-
model._removeLastFilter();
|
188
|
-
handleFetchOptions(filterInputType);
|
189
|
-
}
|
190
|
-
}
|
191
|
-
},
|
192
|
-
[inputValue, filterInputType, model, handleFetchOptions]
|
193
|
-
);
|
194
|
-
const handleTabInput = useCallback(
|
195
|
-
(event, multiValueEdit) => {
|
196
|
-
var _a2;
|
197
|
-
if (event.key === "Tab" && !event.shiftKey) {
|
198
|
-
if (multiValueEdit) {
|
199
|
-
event.preventDefault();
|
200
|
-
handleMultiValueFilterCommit(model, filter, filterMultiValues);
|
201
|
-
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
202
|
-
}
|
203
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
204
|
-
handleResetWip();
|
205
|
-
}
|
206
|
-
},
|
207
|
-
[
|
208
|
-
filter,
|
209
|
-
filterMultiValues,
|
210
|
-
handleChangeViewMode,
|
211
|
-
handleMultiValueFilterCommit,
|
212
|
-
handleResetWip,
|
213
|
-
model,
|
214
|
-
refs.domReference
|
215
|
-
]
|
216
|
-
);
|
217
|
-
const handleShiftTabInput = useCallback(
|
218
|
-
(event, multiValueEdit) => {
|
219
|
-
if (event.key === "Tab" && event.shiftKey) {
|
220
|
-
if (multiValueEdit) {
|
221
|
-
event.preventDefault();
|
222
|
-
handleMultiValueFilterCommit(model, filter, filterMultiValues, true);
|
223
|
-
}
|
224
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
225
|
-
handleResetWip();
|
121
|
+
(event) => {
|
122
|
+
if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
|
123
|
+
model._removeLastFilter();
|
124
|
+
handleFetchOptions(filterInputType);
|
226
125
|
}
|
227
126
|
},
|
228
|
-
[
|
127
|
+
[inputValue, filterInputType]
|
229
128
|
);
|
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
|
+
}, []);
|
230
141
|
const handleEnterInput = useCallback(
|
231
|
-
(event
|
142
|
+
(event) => {
|
232
143
|
if (event.key === "Enter" && activeIndex != null) {
|
233
144
|
if (!filteredDropDownItems[activeIndex]) {
|
234
145
|
return;
|
235
146
|
}
|
236
|
-
|
237
|
-
if (multiValueEdit) {
|
238
|
-
handleLocalMultiValueChange(selectedItem);
|
239
|
-
} else {
|
240
|
-
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, selectedItem));
|
241
|
-
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
242
|
-
setActiveIndex(0);
|
243
|
-
}
|
147
|
+
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));
|
244
148
|
setInputValue("");
|
149
|
+
setActiveIndex(0);
|
150
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);
|
245
151
|
}
|
246
152
|
},
|
247
|
-
[
|
248
|
-
activeIndex,
|
249
|
-
filter,
|
250
|
-
filterInputType,
|
251
|
-
filteredDropDownItems,
|
252
|
-
handleLocalMultiValueChange,
|
253
|
-
handleChangeViewMode,
|
254
|
-
model,
|
255
|
-
refs.domReference
|
256
|
-
]
|
153
|
+
[activeIndex, filter, filterInputType, filteredDropDownItems, model]
|
257
154
|
);
|
258
155
|
useEffect(() => {
|
259
156
|
if (open) {
|
@@ -261,34 +158,13 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
261
158
|
}
|
262
159
|
}, [open, filterInputType]);
|
263
160
|
useEffect(() => {
|
264
|
-
var _a2
|
161
|
+
var _a2;
|
265
162
|
if (!isAlwaysWip) {
|
266
163
|
setInputType("value");
|
267
164
|
setInputValue("");
|
268
|
-
|
269
|
-
const multiValueOptions = filter.values.reduce(
|
270
|
-
(acc, value, i) => {
|
271
|
-
var _a3;
|
272
|
-
return [
|
273
|
-
...acc,
|
274
|
-
{
|
275
|
-
label: ((_a3 = filter.valueLabels) == null ? void 0 : _a3[i]) || value,
|
276
|
-
value
|
277
|
-
}
|
278
|
-
];
|
279
|
-
},
|
280
|
-
[]
|
281
|
-
);
|
282
|
-
setFilterMultiValues(multiValueOptions);
|
283
|
-
}
|
284
|
-
(_b2 = refs.domReference.current) == null ? void 0 : _b2.focus();
|
165
|
+
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
285
166
|
}
|
286
167
|
}, []);
|
287
|
-
useEffect(() => {
|
288
|
-
if (isMultiValueEdit && filterMultiValues) {
|
289
|
-
setTimeout(() => setForceRefresh({}));
|
290
|
-
}
|
291
|
-
}, [filterMultiValues, isMultiValueEdit]);
|
292
168
|
useLayoutEffect(() => {
|
293
169
|
var _a2, _b2;
|
294
170
|
if (activeIndex !== null && rowVirtualizer.range && (activeIndex > ((_a2 = rowVirtualizer.range) == null ? void 0 : _a2.endIndex) || activeIndex < ((_b2 = rowVirtualizer.range) == null ? void 0 : _b2.startIndex))) {
|
@@ -314,17 +190,14 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
314
190
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
315
191
|
},
|
316
192
|
onKeyDown: (event) => {
|
317
|
-
handleShiftTabInput(event
|
193
|
+
handleShiftTabInput(event);
|
318
194
|
if (event.key === "Enter") {
|
319
195
|
switchInputType("operator", setInputType, void 0, refs.domReference.current);
|
320
196
|
}
|
321
197
|
}
|
322
|
-
}, filter.operator) : null,
|
323
|
-
|
324
|
-
|
325
|
-
index: i,
|
326
|
-
handleRemoveMultiValue
|
327
|
-
})) : null) : null, /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, getReferenceProps({
|
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
201
|
ref: refs.setReference,
|
329
202
|
onChange,
|
330
203
|
value: inputValue,
|
@@ -338,9 +211,9 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
338
211
|
if (filterInputType === "operator") {
|
339
212
|
handleShiftTabInput(event);
|
340
213
|
}
|
341
|
-
handleBackspaceInput(event
|
342
|
-
handleTabInput(event
|
343
|
-
handleEnterInput(event
|
214
|
+
handleBackspaceInput(event);
|
215
|
+
handleTabInput(event);
|
216
|
+
handleEnterInput(event);
|
344
217
|
}
|
345
218
|
})), {
|
346
219
|
className: cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading }),
|
@@ -360,7 +233,7 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
360
233
|
initialFocus: -1,
|
361
234
|
visuallyHiddenDismiss: true,
|
362
235
|
modal: false
|
363
|
-
}, /* @__PURE__ */ React.createElement(
|
236
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
364
237
|
style: __spreadProps(__spreadValues({}, floatingStyles), {
|
365
238
|
width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`
|
366
239
|
}),
|
@@ -401,24 +274,17 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
401
274
|
listRef.current[index] = node;
|
402
275
|
},
|
403
276
|
onClick(event) {
|
404
|
-
var _a3;
|
405
277
|
if (filterInputType !== "value") {
|
406
278
|
event.stopPropagation();
|
407
279
|
}
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
filterInputType,
|
417
|
-
setInputType,
|
418
|
-
handleChangeViewMode,
|
419
|
-
refs.domReference.current
|
420
|
-
);
|
421
|
-
}
|
280
|
+
model._updateFilter(filter, generateFilterUpdatePayload(filterInputType, item));
|
281
|
+
setInputValue("");
|
282
|
+
switchToNextInputType(
|
283
|
+
filterInputType,
|
284
|
+
setInputType,
|
285
|
+
handleChangeViewMode,
|
286
|
+
refs.domReference.current
|
287
|
+
);
|
422
288
|
}
|
423
289
|
})), {
|
424
290
|
active: activeIndex === index,
|
@@ -428,56 +294,19 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
428
294
|
transform: `translateY(${virtualItem.start}px)`
|
429
295
|
},
|
430
296
|
"aria-setsize": filteredDropDownItems.length,
|
431
|
-
"aria-posinset": virtualItem.index + 1
|
432
|
-
|
433
|
-
|
434
|
-
}), /* @__PURE__ */ React.createElement("span", null, item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value), item.description ? /* @__PURE__ */ React.createElement("div", {
|
435
|
-
className: styles.descriptionText
|
436
|
-
}, item.description) : null);
|
437
|
-
}))), isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? /* @__PURE__ */ React.createElement(MultiValueApplyButton, {
|
438
|
-
onClick: () => handleMultiValueFilterCommit(model, filter, filterMultiValues),
|
439
|
-
floatingElement: refs.floating.current,
|
440
|
-
maxOptionWidth
|
441
|
-
}) : null))));
|
297
|
+
"aria-posinset": virtualItem.index + 1
|
298
|
+
}), item.isCustom ? "Use custom value: " : "", " ", (_a2 = item.label) != null ? _a2 : item.value);
|
299
|
+
}))))));
|
442
300
|
});
|
443
|
-
const MultiValuePill = ({ item, handleRemoveMultiValue, index }) => {
|
444
|
-
var _a, _b;
|
445
|
-
const styles = useStyles2(getStyles);
|
446
|
-
return /* @__PURE__ */ React.createElement("div", {
|
447
|
-
className: cx(styles.basePill, styles.valuePill)
|
448
|
-
}, /* @__PURE__ */ React.createElement("span", null, " ", (_a = item.label) != null ? _a : item.value), /* @__PURE__ */ React.createElement(Button, {
|
449
|
-
onClick: (e) => {
|
450
|
-
e.stopPropagation();
|
451
|
-
e.preventDefault();
|
452
|
-
handleRemoveMultiValue(item);
|
453
|
-
},
|
454
|
-
onKeyDownCapture: (e) => {
|
455
|
-
if (e.key === "Enter") {
|
456
|
-
e.preventDefault();
|
457
|
-
e.stopPropagation();
|
458
|
-
handleRemoveMultiValue(item);
|
459
|
-
}
|
460
|
-
},
|
461
|
-
fill: "text",
|
462
|
-
size: "sm",
|
463
|
-
variant: "secondary",
|
464
|
-
className: styles.removeButton,
|
465
|
-
tooltip: `Remove filter value - ${(_b = item.label) != null ? _b : item.value}`
|
466
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
467
|
-
name: "times",
|
468
|
-
size: "md",
|
469
|
-
id: `${item.value}-${index}`
|
470
|
-
})));
|
471
|
-
};
|
472
301
|
const getStyles = (theme) => ({
|
473
302
|
comboboxWrapper: css({
|
474
303
|
display: "flex",
|
475
|
-
flexWrap: "
|
304
|
+
flexWrap: "nowrap"
|
476
305
|
}),
|
477
306
|
pillWrapper: css({
|
478
307
|
display: "flex",
|
479
308
|
alignItems: "center",
|
480
|
-
|
309
|
+
whiteSpace: "nowrap"
|
481
310
|
}),
|
482
311
|
basePill: css(__spreadProps(__spreadValues({
|
483
312
|
display: "flex",
|
@@ -502,8 +331,7 @@ const getStyles = (theme) => ({
|
|
502
331
|
}
|
503
332
|
}),
|
504
333
|
valuePill: css({
|
505
|
-
background: theme.colors.action.selected
|
506
|
-
padding: theme.spacing(0.125, 0, 0.125, 1)
|
334
|
+
background: theme.colors.action.selected
|
507
335
|
}),
|
508
336
|
dropdownWrapper: css({
|
509
337
|
backgroundColor: theme.colors.background.primary,
|
@@ -536,25 +364,6 @@ const getStyles = (theme) => ({
|
|
536
364
|
"&:not(:first-child)": {
|
537
365
|
borderTop: `1px solid ${theme.colors.border.weak}`
|
538
366
|
}
|
539
|
-
}),
|
540
|
-
removeButton: css({
|
541
|
-
marginInline: theme.spacing(0.5),
|
542
|
-
height: "100%",
|
543
|
-
padding: 0,
|
544
|
-
cursor: "pointer",
|
545
|
-
"&:hover": {
|
546
|
-
color: theme.colors.text.primary
|
547
|
-
}
|
548
|
-
}),
|
549
|
-
descriptionText: css(__spreadProps(__spreadValues({}, theme.typography.bodySmall), {
|
550
|
-
color: theme.colors.text.secondary,
|
551
|
-
paddingTop: theme.spacing(0.5)
|
552
|
-
})),
|
553
|
-
multiValueApply: css({
|
554
|
-
position: "absolute",
|
555
|
-
top: 0,
|
556
|
-
left: 0,
|
557
|
-
display: "flex"
|
558
367
|
})
|
559
368
|
});
|
560
369
|
|