@grafana/scenes 5.9.1 → 5.9.2--canary.830.10452071184.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,387 @@
1
+ import React, { forwardRef, useState, useRef, useCallback, useImperativeHandle, useEffect } from 'react';
2
+ import { useFloating, autoUpdate, offset, flip, size, useRole, useDismiss, useListNavigation, useInteractions, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
3
+ import { useStyles2 } from '@grafana/ui';
4
+ import { cx, css } from '@emotion/css';
5
+ import { flushSync } from 'react-dom';
6
+ import { useVirtualizer } from '@tanstack/react-virtual';
7
+ import { DropdownItem } from './DropdownItem.js';
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __defProps = Object.defineProperties;
11
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
+ var __spreadValues = (a, b) => {
17
+ for (var prop in b || (b = {}))
18
+ if (__hasOwnProp.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ if (__getOwnPropSymbols)
21
+ for (var prop of __getOwnPropSymbols(b)) {
22
+ if (__propIsEnum.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ }
25
+ return a;
26
+ };
27
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwaysWip, handleChangeViewMode }, parentRef) {
29
+ var _a;
30
+ const [open, setOpen] = useState(false);
31
+ const [options, setOptions] = useState([]);
32
+ const [optionsLoading, setOptionsLoading] = useState(false);
33
+ const [optionsError, setOptionsError] = useState(false);
34
+ const [inputValue, setInputValue] = useState("");
35
+ const [activeIndex, setActiveIndex] = useState(null);
36
+ const [filterInputType, setInputType] = useState(!isAlwaysWip ? "value" : "key");
37
+ const styles = useStyles2(getStyles2);
38
+ const listRef = useRef([]);
39
+ const { _wip } = model.useState();
40
+ const handleResetWip = useCallback(() => {
41
+ if (isAlwaysWip) {
42
+ model._addWip();
43
+ setInputType("key");
44
+ setInputValue("");
45
+ }
46
+ }, [model, isAlwaysWip]);
47
+ const onOpenChange = useCallback(
48
+ (nextOpen, _, reason) => {
49
+ setOpen(nextOpen);
50
+ if (["outside-press", "escape-key"].includes(reason || "")) {
51
+ handleResetWip();
52
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
53
+ }
54
+ },
55
+ [handleChangeViewMode, handleResetWip]
56
+ );
57
+ const filterToUse = filter || _wip;
58
+ const operatorIdentifier = `${(_a = filterToUse == null ? void 0 : filterToUse.key) != null ? _a : ""}-operator`;
59
+ const { refs, floatingStyles, context } = useFloating({
60
+ whileElementsMounted: autoUpdate,
61
+ open,
62
+ onOpenChange,
63
+ placement: "bottom-start",
64
+ middleware: [
65
+ offset(10),
66
+ flip({ padding: 10 }),
67
+ size({
68
+ apply({ availableHeight, elements }) {
69
+ elements.floating.style.maxHeight = `${availableHeight > 300 ? 300 : availableHeight}px`;
70
+ },
71
+ padding: 10
72
+ })
73
+ ]
74
+ });
75
+ const role = useRole(context, { role: "listbox" });
76
+ const dismiss = useDismiss(context, {
77
+ outsidePress: (event) => {
78
+ return !event.currentTarget.classList.contains(
79
+ operatorIdentifier
80
+ );
81
+ }
82
+ });
83
+ const listNav = useListNavigation(context, {
84
+ listRef,
85
+ activeIndex,
86
+ onNavigate: setActiveIndex,
87
+ virtual: true,
88
+ loop: true
89
+ });
90
+ const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([role, dismiss, listNav]);
91
+ useImperativeHandle(parentRef, () => () => {
92
+ var _a2;
93
+ return (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
94
+ }, [refs.domReference]);
95
+ function onChange(event) {
96
+ const value = event.target.value;
97
+ setInputValue(value);
98
+ setActiveIndex(0);
99
+ }
100
+ const filteredDropDownItems = options.filter(
101
+ (item) => {
102
+ var _a2, _b;
103
+ return (_b = (_a2 = item.label) != null ? _a2 : item.value) == null ? void 0 : _b.toLocaleLowerCase().startsWith(inputValue.toLowerCase());
104
+ }
105
+ );
106
+ const flushSyncInputType = useCallback((inputType) => {
107
+ flushSync(() => {
108
+ setInputType(inputType);
109
+ });
110
+ }, []);
111
+ useEffect(() => {
112
+ if (isAlwaysWip && !_wip) {
113
+ model._addWip();
114
+ }
115
+ }, [_wip]);
116
+ useEffect(() => {
117
+ if (!isAlwaysWip && refs.domReference.current) {
118
+ setInputType("value");
119
+ setInputValue("");
120
+ refs.domReference.current.focus();
121
+ }
122
+ }, []);
123
+ const handleFetchOptions = useCallback(
124
+ async (inputType) => {
125
+ setOptionsError(false);
126
+ setOptionsLoading(true);
127
+ setOptions([]);
128
+ let options2 = [];
129
+ try {
130
+ if (inputType === "key") {
131
+ options2 = await model._getKeys(null);
132
+ } else if (inputType === "operator") {
133
+ options2 = model._getOperators();
134
+ } else if (inputType === "value") {
135
+ options2 = await model._getValuesFor(filterToUse);
136
+ }
137
+ setOptions(options2);
138
+ } catch (e) {
139
+ setOptionsError(true);
140
+ }
141
+ setOptionsLoading(false);
142
+ },
143
+ [filterToUse, model]
144
+ );
145
+ const handleBackspaceInput = useCallback(
146
+ (event) => {
147
+ if (event.key === "Backspace" && !inputValue && filterInputType === "key") {
148
+ model._removeLastFilter();
149
+ handleFetchOptions(filterInputType);
150
+ }
151
+ },
152
+ [inputValue, filterInputType]
153
+ );
154
+ const handleTabInput = useCallback((event) => {
155
+ if (event.key === "Tab" && !event.shiftKey) {
156
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
157
+ handleResetWip();
158
+ }
159
+ }, []);
160
+ const handleShiftTabInput = useCallback((event) => {
161
+ if (event.key === "Tab" && event.shiftKey) {
162
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
163
+ handleResetWip();
164
+ }
165
+ }, []);
166
+ const handleEnterInput = useCallback(
167
+ (event) => {
168
+ var _a2;
169
+ if (event.key === "Enter" && activeIndex != null) {
170
+ if (filterInputType !== "value" && !filteredDropDownItems[activeIndex]) {
171
+ return;
172
+ }
173
+ let dropdownItem = filteredDropDownItems[activeIndex];
174
+ if (filterInputType === "value" && !filteredDropDownItems[activeIndex]) {
175
+ if (!inputValue.trim()) {
176
+ return;
177
+ }
178
+ dropdownItem = { value: inputValue };
179
+ }
180
+ model._updateFilter(filterToUse, filterInputType, dropdownItem);
181
+ setInputValue("");
182
+ setActiveIndex(0);
183
+ if (filterInputType === "key") {
184
+ flushSyncInputType("operator");
185
+ } else if (filterInputType === "operator") {
186
+ flushSyncInputType("value");
187
+ } else if (filterInputType === "value") {
188
+ flushSyncInputType("key");
189
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
190
+ }
191
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
192
+ }
193
+ },
194
+ [activeIndex, filterToUse, filterInputType, filteredDropDownItems, model]
195
+ );
196
+ useEffect(() => {
197
+ if (open) {
198
+ handleFetchOptions(filterInputType);
199
+ }
200
+ }, [open, filterInputType]);
201
+ const rowVirtualizer = useVirtualizer({
202
+ count: filteredDropDownItems.length,
203
+ getScrollElement: () => refs.floating.current,
204
+ estimateSize: () => 38,
205
+ overscan: 5
206
+ });
207
+ return /* @__PURE__ */ React.createElement("div", {
208
+ className: styles.comboboxWrapper
209
+ }, filterToUse ? /* @__PURE__ */ React.createElement("div", {
210
+ className: styles.pillWrapper
211
+ }, (filterToUse == null ? void 0 : filterToUse.key) ? /* @__PURE__ */ React.createElement("div", {
212
+ className: cx(styles.basePill, styles.keyPill)
213
+ }, filterToUse.key) : null, (filterToUse == null ? void 0 : filterToUse.key) && (filterToUse == null ? void 0 : filterToUse.operator) && filterInputType !== "operator" ? /* @__PURE__ */ React.createElement("div", {
214
+ className: cx(styles.basePill, styles.operatorPill, operatorIdentifier),
215
+ role: "button",
216
+ "aria-label": "Edit filter operator",
217
+ tabIndex: 0,
218
+ onClick: (event) => {
219
+ var _a2;
220
+ event.stopPropagation();
221
+ flushSyncInputType("operator");
222
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
223
+ },
224
+ onKeyDown: (event) => {
225
+ var _a2;
226
+ handleShiftTabInput(event);
227
+ if (event.key === "Enter") {
228
+ flushSyncInputType("operator");
229
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
230
+ }
231
+ }
232
+ }, filterToUse.operator) : null, (filterToUse == null ? void 0 : filterToUse.key) && (filterToUse == null ? void 0 : filterToUse.operator) && (filterToUse == null ? void 0 : filterToUse.value) && !["operator", "value"].includes(filterInputType) ? /* @__PURE__ */ React.createElement("div", {
233
+ className: cx(styles.basePill, styles.valuePill)
234
+ }, filterToUse.value) : null) : null, /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, getReferenceProps({
235
+ ref: refs.setReference,
236
+ onChange,
237
+ value: inputValue,
238
+ placeholder: !isAlwaysWip ? filterInputType === "operator" ? `${filterToUse[filterInputType]} ${filterToUse.value || ""}` : filterToUse[filterInputType] : "Filter by label values",
239
+ "aria-autocomplete": "list",
240
+ onKeyDown(event) {
241
+ if (!open) {
242
+ setOpen(true);
243
+ return;
244
+ }
245
+ if (filterInputType === "operator") {
246
+ handleShiftTabInput(event);
247
+ }
248
+ handleBackspaceInput(event);
249
+ handleTabInput(event);
250
+ handleEnterInput(event);
251
+ }
252
+ })), {
253
+ className: styles.inputStyle,
254
+ onClick: (event) => {
255
+ event.stopPropagation();
256
+ setOpen(true);
257
+ },
258
+ onFocus: () => {
259
+ setActiveIndex(0);
260
+ setOpen(true);
261
+ }
262
+ })), /* @__PURE__ */ React.createElement(FloatingPortal, null, open && /* @__PURE__ */ React.createElement(FloatingFocusManager, {
263
+ context,
264
+ initialFocus: -1,
265
+ visuallyHiddenDismiss: true
266
+ }, /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, getFloatingProps({
267
+ ref: refs.setFloating,
268
+ style: __spreadProps(__spreadValues({}, floatingStyles), {
269
+ overflowY: "auto",
270
+ zIndex: 1
271
+ })
272
+ })), {
273
+ className: styles.dropdownWrapper
274
+ }), optionsLoading ? /* @__PURE__ */ React.createElement(LoadingOptionsPlaceholder, null) : optionsError ? /* @__PURE__ */ React.createElement(OptionsErrorPlaceholder, {
275
+ handleFetchOptions: () => handleFetchOptions(filterInputType)
276
+ }) : !filteredDropDownItems.length && filterInputType !== "value" ? /* @__PURE__ */ React.createElement(NoOptionsPlaceholder, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, rowVirtualizer.getVirtualItems().map((virtualItem) => {
277
+ var _a2;
278
+ const item = filteredDropDownItems[virtualItem.index];
279
+ const index = virtualItem.index;
280
+ return /* @__PURE__ */ React.createElement(DropdownItem, __spreadProps(__spreadValues({}, getItemProps({
281
+ key: `${item.value}-${index}`,
282
+ ref(node) {
283
+ listRef.current[index] = node;
284
+ },
285
+ onClick(event) {
286
+ var _a3;
287
+ if (filterInputType !== "value") {
288
+ event.stopPropagation();
289
+ }
290
+ model._updateFilter(filterToUse, filterInputType, item);
291
+ setInputValue("");
292
+ if (filterInputType === "key") {
293
+ flushSyncInputType("operator");
294
+ } else if (filterInputType === "operator") {
295
+ flushSyncInputType("value");
296
+ } else if (filterInputType === "value") {
297
+ flushSyncInputType("key");
298
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
299
+ }
300
+ (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
301
+ }
302
+ })), {
303
+ active: activeIndex === index
304
+ }), (_a2 = item.label) != null ? _a2 : item.value);
305
+ }), filterInputType === "value" && inputValue ? /* @__PURE__ */ React.createElement(DropdownItem, __spreadProps(__spreadValues({}, getItemProps({
306
+ key: "__custom_value_list_item",
307
+ ref(node) {
308
+ listRef.current[filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0] = node;
309
+ },
310
+ onClick() {
311
+ var _a2;
312
+ model._updateFilter(filterToUse, filterInputType, { value: inputValue });
313
+ setInputValue("");
314
+ flushSyncInputType("key");
315
+ handleChangeViewMode == null ? void 0 : handleChangeViewMode();
316
+ (_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
317
+ }
318
+ })), {
319
+ active: activeIndex === (filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0)
320
+ }), "Use custom value: ", inputValue) : null)))));
321
+ });
322
+ const LoadingOptionsPlaceholder = () => {
323
+ return /* @__PURE__ */ React.createElement(DropdownItem, {
324
+ active: false
325
+ }, "Loading options...");
326
+ };
327
+ const NoOptionsPlaceholder = () => {
328
+ return /* @__PURE__ */ React.createElement(DropdownItem, {
329
+ active: false
330
+ }, "No options found");
331
+ };
332
+ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
333
+ return /* @__PURE__ */ React.createElement(DropdownItem, {
334
+ active: false,
335
+ onClick: handleFetchOptions
336
+ }, "Error. Click to try again!");
337
+ };
338
+ const getStyles2 = (theme) => ({
339
+ comboboxWrapper: css({
340
+ display: "flex",
341
+ flexWrap: "nowrap"
342
+ }),
343
+ pillWrapper: css({
344
+ display: "flex",
345
+ alignItems: "center",
346
+ whiteSpace: "nowrap"
347
+ }),
348
+ basePill: css(__spreadProps(__spreadValues({
349
+ display: "flex",
350
+ alignItems: "center",
351
+ background: theme.colors.action.disabledBackground,
352
+ border: `1px solid ${theme.colors.border.weak}`,
353
+ padding: theme.spacing(0.125, 1, 0.125, 1),
354
+ color: theme.colors.text.primary,
355
+ overflow: "hidden",
356
+ whiteSpace: "nowrap",
357
+ minHeight: "22px"
358
+ }, theme.typography.bodySmall), {
359
+ cursor: "pointer"
360
+ })),
361
+ keyPill: css({
362
+ fontWeight: theme.typography.fontWeightBold,
363
+ cursor: "default"
364
+ }),
365
+ operatorPill: css({
366
+ "&:hover": {
367
+ background: theme.colors.action.hover
368
+ }
369
+ }),
370
+ valuePill: css({
371
+ background: theme.colors.action.selected
372
+ }),
373
+ dropdownWrapper: css({
374
+ backgroundColor: theme.colors.background.primary,
375
+ color: theme.colors.text.primary,
376
+ boxShadow: theme.shadows.z2
377
+ }),
378
+ inputStyle: css({
379
+ paddingBlock: 0,
380
+ "&:focus": {
381
+ outline: "none"
382
+ }
383
+ })
384
+ });
385
+
386
+ export { AdHocCombobox };
387
+ //# sourceMappingURL=AdHocFiltersCombobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdHocFiltersCombobox.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport {\n autoUpdate,\n size,\n flip,\n useDismiss,\n useFloating,\n useInteractions,\n useListNavigation,\n useRole,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n UseFloatingOptions,\n} from '@floating-ui/react';\nimport { useStyles2 } from '@grafana/ui';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport { DropdownItem } from './DropdownItem';\n\ninterface AdHocComboboxProps {\n filter?: AdHocFilterWithLabels;\n isAlwaysWip?: boolean;\n model: AdHocFiltersVariable;\n handleChangeViewMode?: () => void;\n}\n\ntype AdHocInputType = 'key' | 'operator' | 'value';\n\nexport const AdHocCombobox = forwardRef(function AdHocCombobox(\n { filter, model, isAlwaysWip, handleChangeViewMode }: AdHocComboboxProps,\n parentRef\n) {\n const [open, setOpen] = useState(false);\n\n const [options, setOptions] = useState<Array<SelectableValue<string>>>([]);\n const [optionsLoading, setOptionsLoading] = useState<boolean>(false);\n const [optionsError, setOptionsError] = useState<boolean>(false);\n const [inputValue, setInputValue] = useState('');\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n const [filterInputType, setInputType] = useState<AdHocInputType>(!isAlwaysWip ? 'value' : 'key');\n const styles = useStyles2(getStyles2);\n\n const listRef = useRef<Array<HTMLElement | null>>([]);\n const { _wip } = model.useState();\n\n const handleResetWip = useCallback(() => {\n if (isAlwaysWip) {\n model._addWip();\n setInputType('key');\n setInputValue('');\n }\n }, [model, isAlwaysWip]);\n\n const onOpenChange = useCallback<NonNullable<UseFloatingOptions['onOpenChange']>>(\n (nextOpen, _, reason) => {\n setOpen(nextOpen);\n // change from filter edit mode to filter view mode when clicked\n // outside input or dropdown\n if (['outside-press', 'escape-key'].includes(reason || '')) {\n handleResetWip();\n handleChangeViewMode?.();\n }\n },\n [handleChangeViewMode, handleResetWip]\n );\n\n const filterToUse = filter || _wip;\n\n const operatorIdentifier = `${filterToUse?.key ?? ''}-operator`;\n\n const { refs, floatingStyles, context } = useFloating<HTMLInputElement>({\n whileElementsMounted: autoUpdate,\n open,\n onOpenChange,\n placement: 'bottom-start',\n middleware: [\n offset(10),\n flip({ padding: 10 }),\n size({\n apply({ availableHeight, elements }) {\n // limit the maxHeight of dropdown\n elements.floating.style.maxHeight = `${availableHeight > 300 ? 300 : availableHeight}px`;\n },\n padding: 10,\n }),\n ],\n });\n\n const role = useRole(context, { role: 'listbox' });\n const dismiss = useDismiss(context, {\n // if outside click lands on operator pill, then ignore outside click\n outsidePress: (event) => {\n return !(event as unknown as React.MouseEvent<HTMLElement, MouseEvent>).currentTarget.classList.contains(\n operatorIdentifier\n );\n },\n });\n const listNav = useListNavigation(context, {\n listRef,\n activeIndex,\n onNavigate: setActiveIndex,\n virtual: true,\n loop: true,\n });\n\n const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([role, dismiss, listNav]);\n\n // pass ability to focus on input element back to parent\n useImperativeHandle(parentRef, () => () => refs.domReference.current?.focus(), [refs.domReference]);\n\n function onChange(event: React.ChangeEvent<HTMLInputElement>) {\n // // part of POC for seamless filter parser\n // if (filterInputType === 'key') {\n // const lastChar = event.target.value.slice(-1);\n // if (['=', '!', '<', '>'].includes(lastChar)) {\n // const key = event.target.value.slice(0, -1);\n // const optionIndex = options.findIndex((option) => option.value === key);\n // if (optionIndex >= 0) {\n // model._updateFilter(filterToUse!, filterInputType, options[optionIndex]);\n // setInputValue(lastChar);\n // }\n // flushSync(() => {\n // setInputType('operator');\n // });\n // refs.domReference.current?.focus();\n // return;\n // }\n // }\n // if (filterInputType === 'operator') {\n // const lastChar = event.target.value.slice(-1);\n // if (/\\w/.test(lastChar)) {\n // const operator = event.target.value.slice(0, -1);\n // if (!/\\w/.test(operator)) {\n // const optionIndex = options.findIndex((option) => option.value === operator);\n // if (optionIndex >= 0) {\n // model._updateFilter(filterToUse!, filterInputType, options[optionIndex]);\n // setInputValue(lastChar);\n // }\n // flushSync(() => {\n // setInputType('value');\n // });\n // refs.domReference.current?.focus();\n // return;\n // }\n // }\n // }\n\n const value = event.target.value;\n setInputValue(value);\n setActiveIndex(0);\n }\n\n const filteredDropDownItems = options.filter((item) =>\n (item.label ?? item.value)?.toLocaleLowerCase().startsWith(inputValue.toLowerCase())\n );\n\n const flushSyncInputType = useCallback((inputType: AdHocInputType) => {\n flushSync(() => {\n setInputType(inputType);\n });\n }, []);\n\n // when combobox is in wip mode then check and add _wip if its missing\n // needed on first render and when _wip is reset on filter value commit\n useEffect(() => {\n if (isAlwaysWip && !_wip) {\n model._addWip();\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [_wip]);\n\n // when not in wip mode this is the point of switching from view to edit mode\n // and in this case we default to 'value' input type and focus input\n useEffect(() => {\n if (!isAlwaysWip && refs.domReference.current) {\n setInputType('value');\n setInputValue('');\n\n refs.domReference.current.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleFetchOptions = useCallback(\n async (inputType: AdHocInputType) => {\n setOptionsError(false);\n setOptionsLoading(true);\n setOptions([]);\n let options: Array<SelectableValue<string>> = [];\n try {\n if (inputType === 'key') {\n options = await model._getKeys(null);\n } else if (inputType === 'operator') {\n options = model._getOperators();\n } else if (inputType === 'value') {\n options = await model._getValuesFor(filterToUse!);\n }\n setOptions(options);\n } catch (e) {\n setOptionsError(true);\n }\n setOptionsLoading(false);\n },\n [filterToUse, model]\n );\n\n const handleBackspaceInput = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Backspace' && !inputValue && filterInputType === 'key') {\n model._removeLastFilter();\n handleFetchOptions(filterInputType);\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [inputValue, filterInputType]\n );\n\n const handleTabInput = useCallback((event: React.KeyboardEvent) => {\n // change filter to view mode when navigating away with Tab key\n // this is needed because useDismiss only reacts to mousedown\n if (event.key === 'Tab' && !event.shiftKey) {\n handleChangeViewMode?.();\n handleResetWip();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleShiftTabInput = useCallback((event: React.KeyboardEvent) => {\n if (event.key === 'Tab' && event.shiftKey) {\n handleChangeViewMode?.();\n handleResetWip();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleEnterInput = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Enter' && activeIndex != null) {\n // dropDownItems[activeIndex] can be undefined if we entering custom value only\n // therefore adding a guard for other filterInputTypes\n if (filterInputType !== 'value' && !filteredDropDownItems[activeIndex]) {\n return;\n }\n\n let dropdownItem = filteredDropDownItems[activeIndex];\n\n // if we entering value and match no items in dropdown then\n // allow to enter current input value\n if (filterInputType === 'value' && !filteredDropDownItems[activeIndex]) {\n // prevent from adding empty value\n if (!inputValue.trim()) {\n return;\n }\n dropdownItem = { value: inputValue };\n }\n\n model._updateFilter(filterToUse!, filterInputType, dropdownItem);\n setInputValue('');\n setActiveIndex(0);\n\n if (filterInputType === 'key') {\n flushSyncInputType('operator');\n } else if (filterInputType === 'operator') {\n flushSyncInputType('value');\n } else if (filterInputType === 'value') {\n flushSyncInputType('key');\n\n handleChangeViewMode?.();\n }\n\n refs.domReference.current?.focus();\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeIndex, filterToUse, filterInputType, filteredDropDownItems, model]\n );\n\n useEffect(() => {\n if (open) {\n handleFetchOptions(filterInputType);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, filterInputType]);\n\n const rowVirtualizer = useVirtualizer({\n count: filteredDropDownItems.length,\n getScrollElement: () => refs.floating.current,\n estimateSize: () => 38,\n overscan: 5,\n });\n\n return (\n <div className={styles.comboboxWrapper}>\n {filterToUse ? (\n <div className={styles.pillWrapper}>\n {filterToUse?.key ? <div className={cx(styles.basePill, styles.keyPill)}>{filterToUse.key}</div> : null}\n {filterToUse?.key && filterToUse?.operator && filterInputType !== 'operator' ? (\n <div\n className={cx(styles.basePill, styles.operatorPill, operatorIdentifier)}\n role=\"button\"\n aria-label=\"Edit filter operator\"\n tabIndex={0}\n onClick={(event) => {\n event.stopPropagation();\n flushSyncInputType('operator');\n\n refs.domReference.current?.focus();\n }}\n onKeyDown={(event) => {\n handleShiftTabInput(event);\n if (event.key === 'Enter') {\n flushSyncInputType('operator');\n refs.domReference.current?.focus();\n }\n }}\n >\n {filterToUse.operator}\n </div>\n ) : null}\n {filterToUse?.key &&\n filterToUse?.operator &&\n filterToUse?.value &&\n !['operator', 'value'].includes(filterInputType) ? (\n <div className={cx(styles.basePill, styles.valuePill)}>{filterToUse.value}</div>\n ) : null}\n </div>\n ) : null}\n\n <input\n {...getReferenceProps({\n ref: refs.setReference,\n onChange,\n value: inputValue,\n // dynamic placeholder to display operator and/or value in filter edit mode\n placeholder: !isAlwaysWip\n ? filterInputType === 'operator'\n ? `${filterToUse![filterInputType]} ${filterToUse!.value || ''}`\n : filterToUse![filterInputType]\n : 'Filter by label values',\n 'aria-autocomplete': 'list',\n onKeyDown(event) {\n if (!open) {\n setOpen(true);\n return;\n }\n if (filterInputType === 'operator') {\n handleShiftTabInput(event);\n }\n handleBackspaceInput(event);\n handleTabInput(event);\n handleEnterInput(event);\n },\n })}\n className={styles.inputStyle}\n onClick={(event) => {\n event.stopPropagation();\n setOpen(true);\n }}\n onFocus={() => {\n setActiveIndex(0);\n setOpen(true);\n }}\n />\n <FloatingPortal>\n {open && (\n <FloatingFocusManager context={context} initialFocus={-1} visuallyHiddenDismiss>\n <div\n {...getFloatingProps({\n ref: refs.setFloating,\n style: {\n ...floatingStyles,\n overflowY: 'auto',\n zIndex: 1,\n },\n })}\n className={styles.dropdownWrapper}\n >\n {optionsLoading ? (\n <LoadingOptionsPlaceholder />\n ) : optionsError ? (\n <OptionsErrorPlaceholder handleFetchOptions={() => handleFetchOptions(filterInputType)} />\n ) : !filteredDropDownItems.length && filterInputType !== 'value' ? (\n <NoOptionsPlaceholder />\n ) : (\n <>\n {rowVirtualizer.getVirtualItems().map((virtualItem) => {\n const item = filteredDropDownItems[virtualItem.index];\n const index = virtualItem.index;\n\n return (\n // key is included in getItemProps()\n // eslint-disable-next-line react/jsx-key\n <DropdownItem\n {...getItemProps({\n key: `${item.value!}-${index}`,\n ref(node) {\n listRef.current[index] = node;\n },\n onClick(event) {\n if (filterInputType !== 'value') {\n event.stopPropagation();\n }\n model._updateFilter(filterToUse!, filterInputType, item);\n setInputValue('');\n\n if (filterInputType === 'key') {\n flushSyncInputType('operator');\n } else if (filterInputType === 'operator') {\n flushSyncInputType('value');\n } else if (filterInputType === 'value') {\n flushSyncInputType('key');\n handleChangeViewMode?.();\n }\n\n refs.domReference.current?.focus();\n },\n })}\n active={activeIndex === index}\n >\n {item.label ?? item.value}\n </DropdownItem>\n );\n })}\n {filterInputType === 'value' && inputValue ? (\n <DropdownItem\n {...getItemProps({\n key: '__custom_value_list_item',\n ref(node) {\n listRef.current[filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0] = node;\n },\n onClick() {\n model._updateFilter(filterToUse!, filterInputType, { value: inputValue });\n setInputValue('');\n\n flushSyncInputType('key');\n\n handleChangeViewMode?.();\n refs.domReference.current?.focus();\n },\n })}\n active={activeIndex === (filteredDropDownItems.length ? filteredDropDownItems.length + 1 : 0)}\n >\n Use custom value: {inputValue}\n </DropdownItem>\n ) : null}\n </>\n )}\n </div>\n </FloatingFocusManager>\n )}\n </FloatingPortal>\n </div>\n );\n});\n\nconst LoadingOptionsPlaceholder = () => {\n return <DropdownItem active={false}>Loading options...</DropdownItem>;\n};\n\nconst NoOptionsPlaceholder = () => {\n return <DropdownItem active={false}>No options found</DropdownItem>;\n};\n\nconst OptionsErrorPlaceholder = ({ handleFetchOptions }: { handleFetchOptions: () => void }) => {\n return (\n <DropdownItem active={false} onClick={handleFetchOptions}>\n Error. Click to try again!\n </DropdownItem>\n );\n};\n\nconst getStyles2 = (theme: GrafanaTheme2) => ({\n comboboxWrapper: css({\n display: 'flex',\n flexWrap: 'nowrap',\n }),\n pillWrapper: css({\n display: 'flex',\n alignItems: 'center',\n whiteSpace: 'nowrap',\n }),\n basePill: css({\n display: 'flex',\n alignItems: 'center',\n background: theme.colors.action.disabledBackground,\n border: `1px solid ${theme.colors.border.weak}`,\n padding: theme.spacing(0.125, 1, 0.125, 1),\n color: theme.colors.text.primary,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n minHeight: '22px',\n ...theme.typography.bodySmall,\n cursor: 'pointer',\n }),\n keyPill: css({\n fontWeight: theme.typography.fontWeightBold,\n cursor: 'default',\n }),\n operatorPill: css({\n '&:hover': {\n background: theme.colors.action.hover,\n },\n }),\n valuePill: css({\n background: theme.colors.action.selected,\n }),\n dropdownWrapper: css({\n backgroundColor: theme.colors.background.primary,\n color: theme.colors.text.primary,\n boxShadow: theme.shadows.z2,\n }),\n inputStyle: css({\n paddingBlock: 0,\n '&:focus': {\n outline: 'none',\n },\n }),\n});\n"],"names":["AdHocCombobox","_a","options"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCa,MAAA,aAAA,GAAgB,UAAW,CAAA,SAASA,cAC/C,CAAA,EAAE,QAAQ,KAAO,EAAA,WAAA,EAAa,oBAAqB,EAAA,EACnD,SACA,EAAA;AAnCF,EAAA,IAAA,EAAA,CAAA;AAoCE,EAAA,MAAM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AA,IACnB,eAAA,EAAiB,KAAM,CAAA,MAAA,CAAO,UAAW,CAAA,OAAA;AAAA,IACzC,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,OAAA;AAAA,IACzB,SAAA,EAAW,MAAM,OAAQ,CAAA,EAAA;AAAA,GAC1B,CAAA;AAAA,EACD,YAAY,GAAI,CAAA;AAAA,IACd,YAAc,EAAA,CAAA;AAAA,IACd,SAAW,EAAA;AAAA,MACT,OAAS,EAAA,MAAA;AAAA,KACX;AAAA,GACD,CAAA;AACH,CAAA,CAAA;;;;"}
@@ -0,0 +1,113 @@
1
+ import { css } from '@emotion/css';
2
+ import { useStyles2, IconButton } from '@grafana/ui';
3
+ import React, { useState, useRef, useCallback } from 'react';
4
+ import { flushSync } from 'react-dom';
5
+ import { AdHocCombobox } from './AdHocFiltersCombobox.js';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __defProps = Object.defineProperties;
9
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues = (a, b) => {
15
+ for (var prop in b || (b = {}))
16
+ if (__hasOwnProp.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols)
19
+ for (var prop of __getOwnPropSymbols(b)) {
20
+ if (__propIsEnum.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ }
23
+ return a;
24
+ };
25
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
+ function AdHocFiltersComboboxEditSwitch({
27
+ filter,
28
+ model
29
+ }) {
30
+ const styles = useStyles2(getStyles);
31
+ const [viewMode, setViewMode] = useState(true);
32
+ const pillWrapperRef = useRef(null);
33
+ const handleChangeViewMode = useCallback((event) => {
34
+ var _a;
35
+ event == null ? void 0 : event.stopPropagation();
36
+ let viewMode2 = false;
37
+ flushSync(() => {
38
+ setViewMode((mode) => {
39
+ viewMode2 = mode;
40
+ return !mode;
41
+ });
42
+ });
43
+ if (!viewMode2) {
44
+ (_a = pillWrapperRef.current) == null ? void 0 : _a.focus();
45
+ }
46
+ }, []);
47
+ if (viewMode) {
48
+ return /* @__PURE__ */ React.createElement("div", {
49
+ className: styles.combinedFilterPill,
50
+ onClick: handleChangeViewMode,
51
+ onKeyDown: (e) => {
52
+ if (e.key === "Enter") {
53
+ handleChangeViewMode();
54
+ }
55
+ },
56
+ role: "button",
57
+ "aria-label": `Edit filter with key ${filter.key}`,
58
+ tabIndex: 0,
59
+ ref: pillWrapperRef
60
+ }, /* @__PURE__ */ React.createElement("span", null, filter.key, " ", filter.operator, " ", filter.value), /* @__PURE__ */ React.createElement(IconButton, {
61
+ onClick: (e) => {
62
+ e.stopPropagation();
63
+ model._removeFilter(filter);
64
+ },
65
+ onKeyDownCapture: (e) => {
66
+ if (e.key === "Enter") {
67
+ e.preventDefault();
68
+ e.stopPropagation();
69
+ model._removeFilter(filter);
70
+ }
71
+ },
72
+ name: "times",
73
+ size: "md",
74
+ className: styles.removeButton,
75
+ tooltip: `Remove filter with key ${filter.key}`
76
+ }));
77
+ }
78
+ return /* @__PURE__ */ React.createElement(AdHocCombobox, {
79
+ filter,
80
+ model,
81
+ handleChangeViewMode
82
+ });
83
+ }
84
+ const getStyles = (theme) => ({
85
+ combinedFilterPill: css(__spreadProps(__spreadValues({
86
+ display: "flex",
87
+ alignItems: "center",
88
+ background: theme.colors.action.selected,
89
+ borderRadius: theme.shape.radius.default,
90
+ border: `1px solid ${theme.colors.border.weak}`,
91
+ padding: theme.spacing(0.125, 0, 0.125, 1),
92
+ color: theme.colors.text.primary,
93
+ overflow: "hidden",
94
+ whiteSpace: "nowrap",
95
+ minHeight: "22px"
96
+ }, theme.typography.bodySmall), {
97
+ fontWeight: theme.typography.fontWeightBold,
98
+ cursor: "pointer",
99
+ "&:hover": {
100
+ background: theme.colors.action.hover
101
+ }
102
+ })),
103
+ removeButton: css({
104
+ marginInline: theme.spacing(0.5),
105
+ cursor: "pointer",
106
+ "&:hover": {
107
+ color: theme.colors.text.primary
108
+ }
109
+ })
110
+ });
111
+
112
+ export { AdHocFiltersComboboxEditSwitch };
113
+ //# sourceMappingURL=AdHocFiltersComboboxEditSwitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdHocFiltersComboboxEditSwitch.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxEditSwitch.tsx"],"sourcesContent":["import { css } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2, IconButton } from '@grafana/ui';\nimport React, { useState, useRef, useCallback } from 'react';\nimport { flushSync } from 'react-dom';\nimport { AdHocCombobox } from './AdHocFiltersCombobox';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\n\nexport function AdHocFiltersComboboxEditSwitch({\n filter,\n model,\n}: {\n filter: AdHocFilterWithLabels;\n model: AdHocFiltersVariable;\n}) {\n const styles = useStyles2(getStyles);\n const [viewMode, setViewMode] = useState(true);\n const pillWrapperRef = useRef<HTMLDivElement>(null);\n\n const handleChangeViewMode = useCallback((event?: React.MouseEvent) => {\n event?.stopPropagation();\n let viewMode = false;\n flushSync(() => {\n setViewMode((mode) => {\n viewMode = mode;\n return !mode;\n });\n });\n if (!viewMode) {\n pillWrapperRef.current?.focus();\n }\n }, []);\n\n if (viewMode) {\n return (\n <div\n className={styles.combinedFilterPill}\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 ${filter.key}`}\n tabIndex={0}\n ref={pillWrapperRef}\n >\n <span>\n {filter.key} {filter.operator} {filter.value}\n </span>\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 ${filter.key}`}\n />\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: '22px',\n ...theme.typography.bodySmall,\n fontWeight: theme.typography.fontWeightBold,\n cursor: 'pointer',\n\n '&:hover': {\n background: theme.colors.action.hover,\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":["viewMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQO,SAAS,8BAA+B,CAAA;AAAA,EAC7C,MAAA;AAAA,EACA,KAAA;AACF,CAGG,EAAA;AACD,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,IAAI,CAAA,CAAA;AAC7C,EAAM,MAAA,cAAA,GAAiB,OAAuB,IAAI,CAAA,CAAA;AAElD,EAAM,MAAA,oBAAA,GAAuB,WAAY,CAAA,CAAC,KAA6B,KAAA;AAnBzE,IAAA,IAAA,EAAA,CAAA;AAoBI,IAAO,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,eAAA,EAAA,CAAA;AACP,IAAA,IAAIA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,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,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;;;;"}
@@ -0,0 +1,63 @@
1
+ import { css } from '@emotion/css';
2
+ import { useStyles2, Icon } from '@grafana/ui';
3
+ import React, { memo, useRef } from 'react';
4
+ import { AdHocCombobox } from './AdHocFiltersCombobox.js';
5
+ import { AdHocFiltersComboboxEditSwitch } from './AdHocFiltersComboboxEditSwitch.js';
6
+
7
+ const AdHocFiltersComboboxRenderer = memo(function AdHocFiltersComboboxRenderer2({
8
+ model
9
+ }) {
10
+ const { filters } = model.useState();
11
+ const styles = useStyles2(getStyles);
12
+ const focusOnInputRef = useRef();
13
+ return /* @__PURE__ */ React.createElement("div", {
14
+ className: styles.comboboxWrapper,
15
+ onClick: () => {
16
+ var _a;
17
+ (_a = focusOnInputRef.current) == null ? void 0 : _a.call(focusOnInputRef);
18
+ }
19
+ }, /* @__PURE__ */ React.createElement(Icon, {
20
+ name: "filter",
21
+ className: styles.filterIcon,
22
+ size: "lg"
23
+ }), filters.map((filter, index) => /* @__PURE__ */ React.createElement(AdHocFiltersComboboxEditSwitch, {
24
+ key: index,
25
+ filter,
26
+ model
27
+ })), /* @__PURE__ */ React.createElement(AdHocCombobox, {
28
+ model,
29
+ isAlwaysWip: true,
30
+ ref: focusOnInputRef
31
+ }));
32
+ });
33
+ const getStyles = (theme) => ({
34
+ comboboxWrapper: css({
35
+ display: "flex",
36
+ flexWrap: "wrap",
37
+ alignItems: "center",
38
+ columnGap: theme.spacing(1),
39
+ rowGap: theme.spacing(0.5),
40
+ minHeight: theme.spacing(4),
41
+ backgroundColor: theme.components.input.background,
42
+ border: `1px solid ${theme.colors.border.strong}`,
43
+ borderRadius: theme.shape.radius.default,
44
+ paddingInline: theme.spacing(1),
45
+ paddingBlock: theme.spacing(0.5),
46
+ flexGrow: 1,
47
+ "&:focus-within": {
48
+ outline: "2px dotted transparent",
49
+ outlineOffset: "2px",
50
+ boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,
51
+ transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,
52
+ transitionDuration: "0.2s",
53
+ transitionProperty: "outline, outline-offset, box-shadow"
54
+ }
55
+ }),
56
+ filterIcon: css({
57
+ color: theme.colors.text.secondary,
58
+ alignSelf: "center"
59
+ })
60
+ });
61
+
62
+ export { AdHocFiltersComboboxRenderer };
63
+ //# sourceMappingURL=AdHocFiltersComboboxRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdHocFiltersComboboxRenderer.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersComboboxRenderer.tsx"],"sourcesContent":["import { css } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Icon, useStyles2 } from '@grafana/ui';\nimport React, { memo, useRef } from 'react';\nimport { AdHocCombobox } from './AdHocFiltersCombobox';\nimport { AdHocFiltersVariable } from '../AdHocFiltersVariable';\nimport { AdHocFiltersComboboxEditSwitch } from './AdHocFiltersComboboxEditSwitch';\n\nexport const AdHocFiltersComboboxRenderer = memo(function AdHocFiltersComboboxRenderer({\n model,\n}: {\n model: AdHocFiltersVariable;\n}) {\n const { filters } = model.useState();\n const styles = useStyles2(getStyles);\n const focusOnInputRef = useRef<() => void>();\n\n return (\n <div\n className={styles.comboboxWrapper}\n onClick={() => {\n focusOnInputRef.current?.();\n }}\n >\n <Icon name=\"filter\" className={styles.filterIcon} size=\"lg\" />\n\n {filters.map((filter, index) => (\n <AdHocFiltersComboboxEditSwitch key={index} filter={filter} model={model} />\n ))}\n\n <AdHocCombobox model={model} isAlwaysWip ref={focusOnInputRef} />\n </div>\n );\n});\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n comboboxWrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n columnGap: theme.spacing(1),\n rowGap: theme.spacing(0.5),\n minHeight: theme.spacing(4),\n backgroundColor: theme.components.input.background,\n border: `1px solid ${theme.colors.border.strong}`,\n borderRadius: theme.shape.radius.default,\n paddingInline: theme.spacing(1),\n paddingBlock: theme.spacing(0.5),\n flexGrow: 1,\n\n '&:focus-within': {\n outline: '2px dotted transparent',\n outlineOffset: '2px',\n boxShadow: `0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main}`,\n transitionTimingFunction: `cubic-bezier(0.19, 1, 0.22, 1)`,\n transitionDuration: '0.2s',\n transitionProperty: 'outline, outline-offset, box-shadow',\n },\n }),\n filterIcon: css({\n color: theme.colors.text.secondary,\n alignSelf: 'center',\n }),\n});\n"],"names":["AdHocFiltersComboboxRenderer"],"mappings":";;;;;;AAQa,MAAA,4BAAA,GAA+B,IAAK,CAAA,SAASA,6BAA6B,CAAA;AAAA,EACrF,KAAA;AACF,CAEG,EAAA;AACD,EAAA,MAAM,EAAE,OAAA,EAAY,GAAA,KAAA,CAAM,QAAS,EAAA,CAAA;AACnC,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,EAAA,MAAM,kBAAkB,MAAmB,EAAA,CAAA;AAE3C,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IACC,WAAW,MAAO,CAAA,eAAA;AAAA,IAClB,SAAS,MAAM;AApBrB,MAAA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