@grafana/scenes 5.10.3--canary.830.10612830611.0 → 5.10.3--canary.830.10615082338.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 +7 -5
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +4 -18
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +12 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
- package/dist/index.js +22 -23
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
@@ -24,10 +24,12 @@ var __spreadValues = (a, b) => {
|
|
24
24
|
};
|
25
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
26
26
|
function AdHocFilterPill({ filter, model, readOnly }) {
|
27
|
-
var _a, _b
|
27
|
+
var _a, _b;
|
28
28
|
const styles = useStyles2(getStyles);
|
29
29
|
const [viewMode, setViewMode] = useState(true);
|
30
30
|
const pillWrapperRef = useRef(null);
|
31
|
+
const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
|
32
|
+
const valueLabel = (_b = filter.valueLabel) != null ? _b : filter.value;
|
31
33
|
const handleChangeViewMode = useCallback(
|
32
34
|
(event) => {
|
33
35
|
var _a2;
|
@@ -58,10 +60,10 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
58
60
|
}
|
59
61
|
},
|
60
62
|
role: "button",
|
61
|
-
"aria-label": `Edit filter with key ${
|
63
|
+
"aria-label": `Edit filter with key ${keyLabel}`,
|
62
64
|
tabIndex: 0,
|
63
65
|
ref: pillWrapperRef
|
64
|
-
}, /* @__PURE__ */ React.createElement("span", null,
|
66
|
+
}, /* @__PURE__ */ React.createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
|
65
67
|
onClick: (e) => {
|
66
68
|
e.stopPropagation();
|
67
69
|
model._removeFilter(filter);
|
@@ -76,7 +78,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
76
78
|
name: "times",
|
77
79
|
size: "md",
|
78
80
|
className: styles.removeButton,
|
79
|
-
tooltip: `Remove filter with key ${
|
81
|
+
tooltip: `Remove filter with key ${keyLabel}`
|
80
82
|
}) : null);
|
81
83
|
}
|
82
84
|
return /* @__PURE__ */ React.createElement(AdHocCombobox, {
|
@@ -96,7 +98,7 @@ const getStyles = (theme) => ({
|
|
96
98
|
color: theme.colors.text.primary,
|
97
99
|
overflow: "hidden",
|
98
100
|
whiteSpace: "nowrap",
|
99
|
-
minHeight:
|
101
|
+
minHeight: theme.spacing(2.75)
|
100
102
|
}, theme.typography.bodySmall), {
|
101
103
|
fontWeight: theme.typography.fontWeightBold,
|
102
104
|
cursor: "pointer",
|
@@ -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 } from 'react';\nimport { flushSync } from 'react-dom';\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 pillWrapperRef = useRef<HTMLDivElement>(null);\n\n const handleChangeViewMode = useCallback(\n (event?: React.MouseEvent) => {\n event?.stopPropagation();\n if (readOnly) {\n return;\n }\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 [readOnly]\n );\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 ${
|
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 } from 'react';\nimport { flushSync } from 'react-dom';\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 pillWrapperRef = useRef<HTMLDivElement>(null);\n\n const keyLabel = filter.keyLabel ?? filter.key;\n const valueLabel = filter.valueLabel ?? filter.value;\n\n const handleChangeViewMode = useCallback(\n (event?: React.MouseEvent) => {\n event?.stopPropagation();\n if (readOnly) {\n return;\n }\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 [readOnly]\n );\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","viewMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,eAAgB,CAAA,EAAE,MAAQ,EAAA,KAAA,EAAO,UAAmB,EAAA;AAdpE,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAeE,EAAM,MAAA,MAAA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AAA,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;;;;"}
|
@@ -4,7 +4,7 @@ import { useStyles2, Spinner, Text } from '@grafana/ui';
|
|
4
4
|
import { cx, css } from '@emotion/css';
|
5
5
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
6
6
|
import { LoadingOptionsPlaceholder, OptionsErrorPlaceholder, NoOptionsPlaceholder, DropdownItem } from './DropdownItem.js';
|
7
|
-
import { fuzzySearchOptions, flattenOptionGroups, setupDropdownAccessibility, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, flushSyncInputType, ERROR_STATE_DROPDOWN_WIDTH } from './utils.js';
|
7
|
+
import { fuzzySearchOptions, flattenOptionGroups, setupDropdownAccessibility, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, switchToNextInputType, flushSyncInputType, ERROR_STATE_DROPDOWN_WIDTH } from './utils.js';
|
8
8
|
import { handleOptionGroups } from '../../utils.js';
|
9
9
|
import { useFloatingInteractions } from './useFloatingInteractions.js';
|
10
10
|
|
@@ -148,14 +148,7 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
148
148
|
model._updateFilter(filter, filterInputType, filteredDropDownItems[activeIndex]);
|
149
149
|
setInputValue("");
|
150
150
|
setActiveIndex(0);
|
151
|
-
|
152
|
-
flushSyncInputType("operator", setInputType);
|
153
|
-
} else if (filterInputType === "operator") {
|
154
|
-
flushSyncInputType("value", setInputType);
|
155
|
-
} else if (filterInputType === "value") {
|
156
|
-
flushSyncInputType("key", setInputType);
|
157
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
158
|
-
}
|
151
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode);
|
159
152
|
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
160
153
|
}
|
161
154
|
},
|
@@ -290,14 +283,7 @@ const AdHocCombobox = forwardRef(function AdHocCombobox2({ filter, model, isAlwa
|
|
290
283
|
}
|
291
284
|
model._updateFilter(filter, filterInputType, item);
|
292
285
|
setInputValue("");
|
293
|
-
|
294
|
-
flushSyncInputType("operator", setInputType);
|
295
|
-
} else if (filterInputType === "operator") {
|
296
|
-
flushSyncInputType("value", setInputType);
|
297
|
-
} else if (filterInputType === "value") {
|
298
|
-
flushSyncInputType("key", setInputType);
|
299
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
300
|
-
}
|
286
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode);
|
301
287
|
(_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
|
302
288
|
}
|
303
289
|
})), {
|
@@ -331,7 +317,7 @@ const getStyles = (theme) => ({
|
|
331
317
|
color: theme.colors.text.primary,
|
332
318
|
overflow: "hidden",
|
333
319
|
whiteSpace: "nowrap",
|
334
|
-
minHeight:
|
320
|
+
minHeight: theme.spacing(2.75)
|
335
321
|
}, theme.typography.bodySmall), {
|
336
322
|
cursor: "pointer"
|
337
323
|
})),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AdHocFiltersCombobox.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FloatingFocusManager, FloatingPortal, UseFloatingOptions } from '@floating-ui/react';\nimport { Spinner, Text, useStyles2 } from '@grafana/ui';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport { DropdownItem, LoadingOptionsPlaceholder, NoOptionsPlaceholder, OptionsErrorPlaceholder } from './DropdownItem';\nimport {\n ERROR_STATE_DROPDOWN_WIDTH,\n flattenOptionGroups,\n flushSyncInputType,\n fuzzySearchOptions,\n setupDropdownAccessibility,\n VIRTUAL_LIST_ITEM_HEIGHT,\n VIRTUAL_LIST_OVERSCAN,\n} from './utils';\nimport { handleOptionGroups } from '../../utils';\nimport { useFloatingInteractions } from './useFloatingInteractions';\n\ninterface AdHocComboboxProps {\n filter?: AdHocFilterWithLabels;\n isAlwaysWip?: boolean;\n model: AdHocFiltersVariable;\n handleChangeViewMode?: () => void;\n}\n\nexport type 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 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(getStyles);\n\n // used to identify operator element and prevent dismiss because it registers as outside click\n const operatorIdentifier = useId();\n\n const listRef = useRef<Array<HTMLElement | null>>([]);\n const disabledIndicesRef = useRef<number[]>([]);\n\n const optionsSearcher = useMemo(() => fuzzySearchOptions(options), [options]);\n\n // reset wip filter. Used when navigating away with incomplete wip filer or when selecting wip filter value\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 (reason && ['outside-press', 'escape-key'].includes(reason)) {\n handleResetWip();\n handleChangeViewMode?.();\n }\n },\n [handleChangeViewMode, handleResetWip]\n );\n\n const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({\n open,\n onOpenChange,\n activeIndex,\n setActiveIndex,\n operatorIdentifier,\n listRef,\n disabledIndicesRef,\n });\n\n // pass ability to focus on input element back to parent\n // parentRef is coming from AdHocFiltersComboboxRenderer\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 // filterAutoParser({ event, filterInputType, options, model, filter, setInputValue, setInputType, refs });\n\n const value = event.target.value;\n setInputValue(value);\n setActiveIndex(0);\n }\n\n // operation order on fetched options:\n // fuzzy search -> extract into groups -> flatten group labels and options\n const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));\n\n // adding custom option this way so that virtualiser is aware of it and can scroll to\n if (filterInputType !== 'operator' && inputValue) {\n filteredDropDownItems.push({\n value: inputValue.trim(),\n label: inputValue.trim(),\n isCustom: true,\n });\n }\n\n // calculate width and populate listRef and disabledIndicesRef for arrow key navigation\n const maxOptionWidth = setupDropdownAccessibility(filteredDropDownItems, listRef, disabledIndicesRef);\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(filter!);\n }\n\n setOptions(options);\n if (options[0]?.group) {\n setActiveIndex(1);\n }\n } catch (e) {\n setOptionsError(true);\n }\n setOptionsLoading(false);\n },\n [filter, model]\n );\n\n const rowVirtualizer = useVirtualizer({\n count: filteredDropDownItems.length,\n getScrollElement: () => refs.floating.current,\n estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,\n overscan: VIRTUAL_LIST_OVERSCAN,\n });\n\n //\n // Keyboard interactions\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 // safeguard for non existing items\n if (!filteredDropDownItems[activeIndex]) {\n return;\n }\n\n model._updateFilter(filter!, filterInputType, filteredDropDownItems[activeIndex]);\n setInputValue('');\n setActiveIndex(0);\n\n if (filterInputType === 'key') {\n flushSyncInputType('operator', setInputType);\n } else if (filterInputType === 'operator') {\n flushSyncInputType('value', setInputType);\n } else if (filterInputType === 'value') {\n flushSyncInputType('key', setInputType);\n\n handleChangeViewMode?.();\n }\n\n refs.domReference.current?.focus();\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeIndex, filter, filterInputType, filteredDropDownItems, model]\n );\n\n //\n // Effects\n //\n\n useEffect(() => {\n // fetch options when dropdown is opened.\n if (open) {\n handleFetchOptions(filterInputType);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, filterInputType]);\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 useLayoutEffect(() => {\n // this is needed to scroll virtual list to the position of currently selected\n // dropdown item when navigating with arrow up/down keys to end/start of list\n if (\n activeIndex !== null &&\n rowVirtualizer.range &&\n (activeIndex > rowVirtualizer.range?.endIndex || activeIndex < rowVirtualizer.range?.startIndex)\n ) {\n rowVirtualizer.scrollToIndex(activeIndex);\n }\n }, [activeIndex, rowVirtualizer]);\n\n return (\n <div className={styles.comboboxWrapper}>\n {filter ? (\n <div className={styles.pillWrapper}>\n {/* Filter key pill render */}\n {filter?.key ? (\n <div className={cx(styles.basePill, styles.keyPill)}>{filter.keyLabel ?? filter.key}</div>\n ) : null}\n {/* Filter operator pill render */}\n {filter?.key && filter?.operator && filterInputType !== 'operator' ? (\n <div\n id={operatorIdentifier}\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', setInputType);\n\n refs.domReference.current?.focus();\n }}\n onKeyDown={(event) => {\n handleShiftTabInput(event);\n if (event.key === 'Enter') {\n flushSyncInputType('operator', setInputType);\n refs.domReference.current?.focus();\n }\n }}\n >\n {filter.operator}\n </div>\n ) : null}\n\n {/* Filter value pill render - currently is not possible to see, will be used with multi value */}\n {filter?.key && filter?.operator && filter?.value && !['operator', 'value'].includes(filterInputType) ? (\n <div className={cx(styles.basePill, styles.valuePill)}>{filter.valueLabel ?? filter.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 ? `${filter![filterInputType]} ${filter!.valueLabel || ''}`\n : filter![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={cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading })}\n onClick={(event) => {\n event.stopPropagation();\n setOpen(true);\n }}\n onFocus={() => {\n setActiveIndex(0);\n setOpen(true);\n }}\n />\n {optionsLoading ? <Spinner className={styles.loadingIndicator} inline={true} /> : null}\n <FloatingPortal>\n {open && (\n <FloatingFocusManager context={context} initialFocus={-1} visuallyHiddenDismiss modal={false}>\n <div\n style={{\n ...floatingStyles,\n width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,\n }}\n ref={refs.setFloating}\n className={styles.dropdownWrapper}\n tabIndex={-1}\n >\n <div\n style={{\n height: `${rowVirtualizer.getTotalSize() || VIRTUAL_LIST_ITEM_HEIGHT}px`, // fallback to 38px for loading/error/no options placeholders\n }}\n {...getFloatingProps()}\n tabIndex={-1}\n >\n {optionsLoading ? (\n <LoadingOptionsPlaceholder />\n ) : optionsError ? (\n <OptionsErrorPlaceholder handleFetchOptions={() => handleFetchOptions(filterInputType)} />\n ) : !filteredDropDownItems.length && (filterInputType === 'operator' || !inputValue) ? (\n <NoOptionsPlaceholder />\n ) : (\n rowVirtualizer.getVirtualItems().map((virtualItem) => {\n const item = filteredDropDownItems[virtualItem.index];\n const index = virtualItem.index;\n\n // render group label\n if (item.options) {\n return (\n <div\n key={`${item.label}+${index}`}\n className={cx(styles.optionGroupLabel, styles.groupTopBorder)}\n style={{\n height: `${virtualItem.size}px`,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n <Text weight=\"bold\" variant=\"bodySmall\" color=\"secondary\">\n {item.label!}\n </Text>\n </div>\n );\n }\n\n const nextItem: SelectableValue<string> | undefined = filteredDropDownItems[virtualItem.index + 1];\n const shouldAddBottomBorder = nextItem && !nextItem.group && !nextItem.options && item.group;\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(filter!, filterInputType, item);\n setInputValue('');\n\n if (filterInputType === 'key') {\n flushSyncInputType('operator', setInputType);\n } else if (filterInputType === 'operator') {\n flushSyncInputType('value', setInputType);\n } else if (filterInputType === 'value') {\n flushSyncInputType('key', setInputType);\n handleChangeViewMode?.();\n }\n\n refs.domReference.current?.focus();\n },\n })}\n active={activeIndex === index}\n addGroupBottomBorder={shouldAddBottomBorder}\n // virtual item positioning and accessibility\n style={{\n height: `${virtualItem.size}px`,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n aria-setsize={filteredDropDownItems.length}\n aria-posinset={virtualItem.index + 1}\n >\n {item.isCustom ? 'Use custom value: ' : ''} {item.label ?? item.value}\n </DropdownItem>\n );\n })\n )}\n </div>\n </div>\n </FloatingFocusManager>\n )}\n </FloatingPortal>\n </div>\n );\n});\n\nconst getStyles = (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 overflowY: 'auto',\n zIndex: theme.zIndex.dropdown,\n }),\n inputStyle: css({\n paddingBlock: 0,\n '&:focus': {\n outline: 'none',\n },\n }),\n loadingIndicator: css({\n color: theme.colors.text.secondary,\n marginLeft: theme.spacing(0.5),\n }),\n loadingInputPadding: css({\n paddingRight: theme.spacing(2.5),\n }),\n optionGroupLabel: css({\n padding: theme.spacing(1),\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n }),\n groupTopBorder: css({\n '&:not(:first-child)': {\n borderTop: `1px solid ${theme.colors.border.weak}`,\n },\n }),\n});\n"],"names":["AdHocCombobox","_a","options","_b"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCa,MAAA,aAAA,GAAgB,UAAW,CAAA,SAASA,cAC/C,CAAA,EAAE,QAAQ,KAAO,EAAA,WAAA,EAAa,oBAAqB,EAAA,EACnD,SACA,EAAA;AA1CF,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA2CE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACtC,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,QAAA,CAAyC,EAAE,CAAA,CAAA;AACzE,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAkB,KAAK,CAAA,CAAA;AACnE,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAkB,KAAK,CAAA,CAAA;AAC/D,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,EAAE,CAAA,CAAA;AAC/C,EAAA,MAAM,CAAC,WAAA,EA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AA;AAAA,IACL,IAAM,EAAA,CAAA;AAAA,IACN,KAAO,EAAA,MAAA;AAAA,GACR,CAAA;AAAA,EACD,gBAAgB,GAAI,CAAA;AAAA,IAClB,qBAAuB,EAAA;AAAA,MACrB,SAAW,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,IAAA,CAAA,CAAA;AAAA,KAC9C;AAAA,GACD,CAAA;AACH,CAAA,CAAA;;;;"}
|
1
|
+
{"version":3,"file":"AdHocFiltersCombobox.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FloatingFocusManager, FloatingPortal, UseFloatingOptions } from '@floating-ui/react';\nimport { Spinner, Text, useStyles2 } from '@grafana/ui';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport { DropdownItem, LoadingOptionsPlaceholder, NoOptionsPlaceholder, OptionsErrorPlaceholder } from './DropdownItem';\nimport {\n ERROR_STATE_DROPDOWN_WIDTH,\n flattenOptionGroups,\n flushSyncInputType,\n fuzzySearchOptions,\n setupDropdownAccessibility,\n switchToNextInputType,\n VIRTUAL_LIST_ITEM_HEIGHT,\n VIRTUAL_LIST_OVERSCAN,\n} from './utils';\nimport { handleOptionGroups } from '../../utils';\nimport { useFloatingInteractions } from './useFloatingInteractions';\n\ninterface AdHocComboboxProps {\n filter?: AdHocFilterWithLabels;\n isAlwaysWip?: boolean;\n model: AdHocFiltersVariable;\n handleChangeViewMode?: () => void;\n}\n\nexport type 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 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(getStyles);\n\n // used to identify operator element and prevent dismiss because it registers as outside click\n const operatorIdentifier = useId();\n\n const listRef = useRef<Array<HTMLElement | null>>([]);\n const disabledIndicesRef = useRef<number[]>([]);\n\n const optionsSearcher = useMemo(() => fuzzySearchOptions(options), [options]);\n\n // reset wip filter. Used when navigating away with incomplete wip filer or when selecting wip filter value\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 (reason && ['outside-press', 'escape-key'].includes(reason)) {\n handleResetWip();\n handleChangeViewMode?.();\n }\n },\n [handleChangeViewMode, handleResetWip]\n );\n\n const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({\n open,\n onOpenChange,\n activeIndex,\n setActiveIndex,\n operatorIdentifier,\n listRef,\n disabledIndicesRef,\n });\n\n // pass ability to focus on input element back to parent\n // parentRef is coming from AdHocFiltersComboboxRenderer\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 // filterAutoParser({ event, filterInputType, options, model, filter, setInputValue, setInputType, refs });\n\n const value = event.target.value;\n setInputValue(value);\n setActiveIndex(0);\n }\n\n // operation order on fetched options:\n // fuzzy search -> extract into groups -> flatten group labels and options\n const filteredDropDownItems = flattenOptionGroups(handleOptionGroups(optionsSearcher(inputValue, filterInputType)));\n\n // adding custom option this way so that virtualiser is aware of it and can scroll to\n if (filterInputType !== 'operator' && inputValue) {\n filteredDropDownItems.push({\n value: inputValue.trim(),\n label: inputValue.trim(),\n isCustom: true,\n });\n }\n\n // calculate width and populate listRef and disabledIndicesRef for arrow key navigation\n const maxOptionWidth = setupDropdownAccessibility(filteredDropDownItems, listRef, disabledIndicesRef);\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(filter!);\n }\n\n setOptions(options);\n if (options[0]?.group) {\n setActiveIndex(1);\n }\n } catch (e) {\n setOptionsError(true);\n }\n setOptionsLoading(false);\n },\n [filter, model]\n );\n\n const rowVirtualizer = useVirtualizer({\n count: filteredDropDownItems.length,\n getScrollElement: () => refs.floating.current,\n estimateSize: () => VIRTUAL_LIST_ITEM_HEIGHT,\n overscan: VIRTUAL_LIST_OVERSCAN,\n });\n\n //\n // Keyboard interactions\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 // safeguard for non existing items\n if (!filteredDropDownItems[activeIndex]) {\n return;\n }\n\n model._updateFilter(filter!, filterInputType, filteredDropDownItems[activeIndex]);\n setInputValue('');\n setActiveIndex(0);\n\n switchToNextInputType(filterInputType, setInputType, handleChangeViewMode);\n\n refs.domReference.current?.focus();\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [activeIndex, filter, filterInputType, filteredDropDownItems, model]\n );\n\n //\n // Effects\n //\n\n useEffect(() => {\n // fetch options when dropdown is opened.\n if (open) {\n handleFetchOptions(filterInputType);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, filterInputType]);\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 useLayoutEffect(() => {\n // this is needed to scroll virtual list to the position of currently selected\n // dropdown item when navigating with arrow up/down keys to end/start of list\n if (\n activeIndex !== null &&\n rowVirtualizer.range &&\n (activeIndex > rowVirtualizer.range?.endIndex || activeIndex < rowVirtualizer.range?.startIndex)\n ) {\n rowVirtualizer.scrollToIndex(activeIndex);\n }\n }, [activeIndex, rowVirtualizer]);\n\n return (\n <div className={styles.comboboxWrapper}>\n {filter ? (\n <div className={styles.pillWrapper}>\n {/* Filter key pill render */}\n {filter?.key ? (\n <div className={cx(styles.basePill, styles.keyPill)}>{filter.keyLabel ?? filter.key}</div>\n ) : null}\n {/* Filter operator pill render */}\n {filter?.key && filter?.operator && filterInputType !== 'operator' ? (\n <div\n id={operatorIdentifier}\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', setInputType);\n\n refs.domReference.current?.focus();\n }}\n onKeyDown={(event) => {\n handleShiftTabInput(event);\n if (event.key === 'Enter') {\n flushSyncInputType('operator', setInputType);\n refs.domReference.current?.focus();\n }\n }}\n >\n {filter.operator}\n </div>\n ) : null}\n\n {/* Filter value pill render - currently is not possible to see, will be used with multi value */}\n {filter?.key && filter?.operator && filter?.value && !['operator', 'value'].includes(filterInputType) ? (\n <div className={cx(styles.basePill, styles.valuePill)}>{filter.valueLabel ?? filter.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 ? `${filter![filterInputType]} ${filter!.valueLabel || ''}`\n : filter![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={cx(styles.inputStyle, { [styles.loadingInputPadding]: !optionsLoading })}\n onClick={(event) => {\n event.stopPropagation();\n setOpen(true);\n }}\n onFocus={() => {\n setActiveIndex(0);\n setOpen(true);\n }}\n />\n {optionsLoading ? <Spinner className={styles.loadingIndicator} inline={true} /> : null}\n <FloatingPortal>\n {open && (\n <FloatingFocusManager context={context} initialFocus={-1} visuallyHiddenDismiss modal={false}>\n <div\n style={{\n ...floatingStyles,\n width: `${optionsError ? ERROR_STATE_DROPDOWN_WIDTH : maxOptionWidth}px`,\n }}\n ref={refs.setFloating}\n className={styles.dropdownWrapper}\n tabIndex={-1}\n >\n <div\n style={{\n height: `${rowVirtualizer.getTotalSize() || VIRTUAL_LIST_ITEM_HEIGHT}px`, // fallback to 38px for loading/error/no options placeholders\n }}\n {...getFloatingProps()}\n tabIndex={-1}\n >\n {optionsLoading ? (\n <LoadingOptionsPlaceholder />\n ) : optionsError ? (\n <OptionsErrorPlaceholder handleFetchOptions={() => handleFetchOptions(filterInputType)} />\n ) : !filteredDropDownItems.length && (filterInputType === 'operator' || !inputValue) ? (\n <NoOptionsPlaceholder />\n ) : (\n rowVirtualizer.getVirtualItems().map((virtualItem) => {\n const item = filteredDropDownItems[virtualItem.index];\n const index = virtualItem.index;\n\n // render group label\n if (item.options) {\n return (\n <div\n key={`${item.label}+${index}`}\n className={cx(styles.optionGroupLabel, styles.groupTopBorder)}\n style={{\n height: `${virtualItem.size}px`,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n <Text weight=\"bold\" variant=\"bodySmall\" color=\"secondary\">\n {item.label!}\n </Text>\n </div>\n );\n }\n\n const nextItem: SelectableValue<string> | undefined = filteredDropDownItems[virtualItem.index + 1];\n const shouldAddBottomBorder = nextItem && !nextItem.group && !nextItem.options && item.group;\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(filter!, filterInputType, item);\n setInputValue('');\n\n switchToNextInputType(filterInputType, setInputType, handleChangeViewMode);\n\n refs.domReference.current?.focus();\n },\n })}\n active={activeIndex === index}\n addGroupBottomBorder={shouldAddBottomBorder}\n // virtual item positioning and accessibility\n style={{\n height: `${virtualItem.size}px`,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n aria-setsize={filteredDropDownItems.length}\n aria-posinset={virtualItem.index + 1}\n >\n {item.isCustom ? 'Use custom value: ' : ''} {item.label ?? item.value}\n </DropdownItem>\n );\n })\n )}\n </div>\n </div>\n </FloatingFocusManager>\n )}\n </FloatingPortal>\n </div>\n );\n});\n\nconst getStyles = (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: theme.spacing(2.75),\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 overflowY: 'auto',\n zIndex: theme.zIndex.dropdown,\n }),\n inputStyle: css({\n paddingBlock: 0,\n '&:focus': {\n outline: 'none',\n },\n }),\n loadingIndicator: css({\n color: theme.colors.text.secondary,\n marginLeft: theme.spacing(0.5),\n }),\n loadingInputPadding: css({\n paddingRight: theme.spacing(2.5),\n }),\n optionGroupLabel: css({\n padding: theme.spacing(1),\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n }),\n groupTopBorder: css({\n '&:not(:first-child)': {\n borderTop: `1px solid ${theme.colors.border.weak}`,\n },\n }),\n});\n"],"names":["AdHocCombobox","_a","options","_b"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCa,MAAA,aAAA,GAAgB,UAAW,CAAA,SAASA,cAC/C,CAAA,EAAE,QAAQ,KAAO,EAAA,WAAA,EAAa,oBAAqB,EAAA,EACnD,SACA,EAAA;AA3CF,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA4CE,EAAA,MAAM,CA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AAW,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,IAAA,CAAA,CAAA;AAAA,KAC9C;AAAA,GACD,CAAA;AACH,CAAA,CAAA;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DropdownItem.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/DropdownItem.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2 } from '@grafana/ui';\nimport React, { forwardRef, useId } from 'react';\n\ninterface DropdownItemProps {\n children: React.ReactNode;\n active?: boolean;\n addGroupBottomBorder?: boolean;\n}\n\nexport const DropdownItem = forwardRef<HTMLDivElement, DropdownItemProps & React.HTMLProps<HTMLDivElement>>(\n function DropdownItem({ children, active, addGroupBottomBorder, ...rest }, ref) {\n const styles = useStyles2(getStyles);\n const id = useId();\n return (\n <div\n ref={ref}\n role=\"option\"\n id={id}\n aria-selected={active}\n className={cx(styles.option, active && styles.optionFocused, addGroupBottomBorder && styles.groupBottomBorder)}\n {...rest}\n >\n <div className={styles.optionBody} data-testid={`data-testid ad hoc filter option value ${children}`}>\n <span>{children}</span>\n </div>\n </div>\n );\n }\n);\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n option: css({\n label: 'grafana-select-option',\n top: 0,\n left: 0,\n width: '100%',\n position: 'absolute',\n padding:
|
1
|
+
{"version":3,"file":"DropdownItem.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/DropdownItem.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2 } from '@grafana/ui';\nimport React, { forwardRef, useId } from 'react';\n\ninterface DropdownItemProps {\n children: React.ReactNode;\n active?: boolean;\n addGroupBottomBorder?: boolean;\n}\n\nexport const DropdownItem = forwardRef<HTMLDivElement, DropdownItemProps & React.HTMLProps<HTMLDivElement>>(\n function DropdownItem({ children, active, addGroupBottomBorder, ...rest }, ref) {\n const styles = useStyles2(getStyles);\n const id = useId();\n return (\n <div\n ref={ref}\n role=\"option\"\n id={id}\n aria-selected={active}\n className={cx(styles.option, active && styles.optionFocused, addGroupBottomBorder && styles.groupBottomBorder)}\n {...rest}\n >\n <div className={styles.optionBody} data-testid={`data-testid ad hoc filter option value ${children}`}>\n <span>{children}</span>\n </div>\n </div>\n );\n }\n);\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n option: css({\n label: 'grafana-select-option',\n top: 0,\n left: 0,\n width: '100%',\n position: 'absolute',\n padding: theme.spacing(1),\n display: 'flex',\n alignItems: 'center',\n flexDirection: 'row',\n flexShrink: 0,\n whiteSpace: 'nowrap',\n cursor: 'pointer',\n '&:hover': {\n background: theme.colors.action.hover,\n '@media (forced-colors: active), (prefers-contrast: more)': {\n border: `1px solid ${theme.colors.primary.border}`,\n },\n },\n }),\n optionFocused: css({\n label: 'grafana-select-option-focused',\n background: theme.colors.action.focus,\n '@media (forced-colors: active), (prefers-contrast: more)': {\n border: `1px solid ${theme.colors.primary.border}`,\n },\n }),\n optionBody: css({\n label: 'grafana-select-option-body',\n display: 'flex',\n fontWeight: theme.typography.fontWeightMedium,\n flexDirection: 'column',\n flexGrow: 1,\n }),\n groupBottomBorder: css({\n borderBottom: `1px solid ${theme.colors.border.weak}`,\n }),\n});\n\nexport const LoadingOptionsPlaceholder = () => {\n return <DropdownItem>Loading options...</DropdownItem>;\n};\n\nexport const NoOptionsPlaceholder = () => {\n return <DropdownItem>No options found</DropdownItem>;\n};\n\nexport const OptionsErrorPlaceholder = ({ handleFetchOptions }: { handleFetchOptions: () => void }) => {\n return (\n <DropdownItem onClick={handleFetchOptions}>An error has occurred fetching labels. Click to retry</DropdownItem>\n );\n};\n"],"names":["DropdownItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aAAa,CAAA,EAAA,EAAqD,GAAK,E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uBAA0B,GAAA,CAAC,EAAE,kBAAA,EAA6D,KAAA;AACrG,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA;AAAA,IAAa,OAAS,EAAA,kBAAA;AAAA,GAAA,EAAoB,uDAAqD,CAAA,CAAA;AAEpG;;;;"}
|
@@ -77,6 +77,17 @@ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
|
77
77
|
const flushSyncInputType = (inputType, setInputType) => flushSync(() => {
|
78
78
|
setInputType(inputType);
|
79
79
|
});
|
80
|
+
const nextInputTypeMap = {
|
81
|
+
key: "operator",
|
82
|
+
operator: "value",
|
83
|
+
value: "key"
|
84
|
+
};
|
85
|
+
const switchToNextInputType = (filterInputType, setInputType, handleChangeViewMode) => {
|
86
|
+
flushSyncInputType(nextInputTypeMap[filterInputType], setInputType);
|
87
|
+
if (filterInputType === "value") {
|
88
|
+
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
89
|
+
}
|
90
|
+
};
|
80
91
|
|
81
|
-
export { ERROR_STATE_DROPDOWN_WIDTH, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, flattenOptionGroups, flushSyncInputType, fuzzySearchOptions, setupDropdownAccessibility };
|
92
|
+
export { ERROR_STATE_DROPDOWN_WIDTH, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, flattenOptionGroups, flushSyncInputType, fuzzySearchOptions, setupDropdownAccessibility, switchToNextInputType };
|
82
93
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/utils.ts"],"sourcesContent":["import { SelectableValue } from '@grafana/data';\nimport uFuzzy from '@leeoniya/ufuzzy';\nimport { flushSync } from 'react-dom';\nimport { AdHocInputType } from './AdHocFiltersCombobox';\nimport { AdHocFiltersVariable, AdHocFilterWithLabels } from '../AdHocFiltersVariable';\nimport { UseFloatingReturn } from '@floating-ui/react';\n\nconst VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;\nconst VIRTUAL_LIST_PADDING = 8;\nexport const VIRTUAL_LIST_OVERSCAN = 5;\nexport const VIRTUAL_LIST_ITEM_HEIGHT = 38;\nexport const ERROR_STATE_DROPDOWN_WIDTH = 366;\n\nexport function fuzzySearchOptions(options: Array<SelectableValue<string>>) {\n const ufuzzy = new uFuzzy();\n const haystack: string[] = [];\n const limit = 10000;\n\n return (search: string, filterInputType: AdHocInputType) => {\n if (search === '') {\n if (options.length > limit) {\n return options.slice(0, limit);\n } else {\n return options;\n }\n }\n\n if (filterInputType === 'operator') {\n const filteredOperators = [];\n for (let i = 0; i < options.length; i++) {\n if ((options[i].label || options[i].value)?.includes(search)) {\n filteredOperators.push(options[i]);\n if (filteredOperators.length > limit) {\n return filteredOperators;\n }\n }\n }\n return filteredOperators;\n }\n\n if (haystack.length === 0) {\n for (let i = 0; i < options.length; i++) {\n haystack.push(options[i].label || options[i].value!);\n }\n }\n const idxs = ufuzzy.filter(haystack, search);\n const filteredOptions: Array<SelectableValue<string>> = [];\n\n if (idxs) {\n for (let i = 0; i < idxs.length; i++) {\n filteredOptions.push(options[idxs[i]]);\n\n if (filteredOptions.length > limit) {\n return filteredOptions;\n }\n }\n return filteredOptions;\n }\n\n if (options.length > limit) {\n return options.slice(0, limit);\n }\n\n return options;\n };\n}\nexport const flattenOptionGroups = (options: Array<SelectableValue<string>>) =>\n options.flatMap<SelectableValue<string>>((option) => (option.options ? [option, ...option.options] : [option]));\n\nexport const setupDropdownAccessibility = (\n options: Array<SelectableValue<string>>,\n listRef: React.MutableRefObject<Array<HTMLElement | null>>,\n disabledIndicesRef: React.MutableRefObject<number[]>\n) => {\n let maxOptionWidth = 182;\n const listRefArr = [];\n const disabledIndices = [];\n\n for (let i = 0; i < options.length; i++) {\n // listRefArr should be filled with nulls for amount of dropdown items so that\n // useNavigationList sets activeIndex correctly when navigating with arrow keys\n listRefArr.push(null);\n\n // disabledIndices are used to skip unselectable group items in dropdown when\n // navigating with arrow keys\n if (options[i]?.options) {\n disabledIndices.push(i);\n }\n let label = options[i].label ?? options[i].value ?? '';\n\n // rough widthEstimate\n const widthEstimate =\n (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER +\n VIRTUAL_LIST_PADDING * 2;\n if (widthEstimate > maxOptionWidth) {\n maxOptionWidth = widthEstimate;\n }\n }\n\n listRef.current = [...listRefArr];\n disabledIndicesRef.current = [...disabledIndices];\n return maxOptionWidth;\n};\n\n// used for updating inputType concurrently because other bunched updates depend on this being up to date\nexport const flushSyncInputType = (\n inputType: AdHocInputType,\n setInputType: React.Dispatch<React.SetStateAction<AdHocInputType>>\n) =>\n flushSync(() => {\n setInputType(inputType);\n });\n\n// WIP: POC for parsing key and operator values automatically\nexport const filterAutoParser = ({\n event,\n filterInputType,\n options,\n model,\n filter,\n setInputValue,\n setInputType,\n refs,\n}: {\n event: React.ChangeEvent<HTMLInputElement>;\n filterInputType: AdHocInputType;\n options: Array<SelectableValue<string>>;\n model: AdHocFiltersVariable;\n filter: AdHocFilterWithLabels | undefined;\n setInputValue: (value: React.SetStateAction<string>) => void;\n setInputType: (value: React.SetStateAction<AdHocInputType>) => void;\n refs: UseFloatingReturn<HTMLInputElement>['refs'];\n}) => {\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(filter!, 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(filter!, 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"],"names":[],"mappings":";;;AAOA,MAAM,sCAAyC,GAAA,CAAA,CAAA;AAC/C,MAAM,oBAAuB,GAAA,CAAA,CAAA;AACtB,MAAM,qBAAwB,GAAA,EAAA;AAC9B,MAAM,wBAA2B,GAAA,GAAA;AACjC,MAAM,0BAA6B,GAAA,IAAA;AAEnC,SAAS,mBAAmB,OAAyC,EAAA;AAC1E,EAAM,MAAA,MAAA,GAAS,IAAI,MAAO,EAAA,CAAA;AAC1B,EAAA,MAAM,WAAqB,EAAC,CAAA;AAC5B,EAAA,MAAM,KAAQ,GAAA,GAAA,CAAA;AAEd,EAAO,OAAA,CAAC,QAAgB,eAAoC,KAAA;AAlB9D,IAAA,IAAA,EAAA,CAAA;AAmBI,IAAA,IAAI,WAAW,EAAI,EAAA;AACjB,MAAI,IAAA,OAAA,CAAQ,SAAS,KAAO,EAAA;AAC1B,QAAO,OAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,EAAG,KAAK,CAAA,CAAA;AAAA,OACxB,MAAA;AACL,QAAO,OAAA,OAAA,CAAA;AAAA,OACT;AAAA,KACF;AAEA,IAAA,IAAI,oBAAoB,UAAY,EAAA;AAClC,MAAA,MAAM,oBAAoB,EAAC,CAAA;AAC3B,MAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,OAAA,CAAQ,QAAQ,CAAK,EAAA,EAAA;AACvC,QAAK,IAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,GAAG,KAAS,IAAA,OAAA,CAAQ,GAAG,KAA/B,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAuC,SAAS,MAAS,CAAA,EAAA;AAC5D,UAAkB,iBAAA,CAAA,IAAA,CAAK,QA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;AAChD,EAAO,OAAA,cAAA,CAAA;AACT,EAAA;AAGO,MAAM,kBAAqB,GAAA,CAChC,SACA,EAAA,YAAA,KAEA,UAAU,MAAM;AACd,EAAA,YAAA,CAAa,SAAS,CAAA,CAAA;AACxB,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/utils.ts"],"sourcesContent":["import { SelectableValue } from '@grafana/data';\nimport uFuzzy from '@leeoniya/ufuzzy';\nimport { flushSync } from 'react-dom';\nimport { AdHocInputType } from './AdHocFiltersCombobox';\nimport { AdHocFiltersVariable, AdHocFilterWithLabels } from '../AdHocFiltersVariable';\nimport { UseFloatingReturn } from '@floating-ui/react';\n\nconst VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;\nconst VIRTUAL_LIST_PADDING = 8;\nexport const VIRTUAL_LIST_OVERSCAN = 5;\nexport const VIRTUAL_LIST_ITEM_HEIGHT = 38;\nexport const ERROR_STATE_DROPDOWN_WIDTH = 366;\n\nexport function fuzzySearchOptions(options: Array<SelectableValue<string>>) {\n const ufuzzy = new uFuzzy();\n const haystack: string[] = [];\n const limit = 10000;\n\n return (search: string, filterInputType: AdHocInputType) => {\n if (search === '') {\n if (options.length > limit) {\n return options.slice(0, limit);\n } else {\n return options;\n }\n }\n\n if (filterInputType === 'operator') {\n const filteredOperators = [];\n for (let i = 0; i < options.length; i++) {\n if ((options[i].label || options[i].value)?.includes(search)) {\n filteredOperators.push(options[i]);\n if (filteredOperators.length > limit) {\n return filteredOperators;\n }\n }\n }\n return filteredOperators;\n }\n\n if (haystack.length === 0) {\n for (let i = 0; i < options.length; i++) {\n haystack.push(options[i].label || options[i].value!);\n }\n }\n const idxs = ufuzzy.filter(haystack, search);\n const filteredOptions: Array<SelectableValue<string>> = [];\n\n if (idxs) {\n for (let i = 0; i < idxs.length; i++) {\n filteredOptions.push(options[idxs[i]]);\n\n if (filteredOptions.length > limit) {\n return filteredOptions;\n }\n }\n return filteredOptions;\n }\n\n if (options.length > limit) {\n return options.slice(0, limit);\n }\n\n return options;\n };\n}\nexport const flattenOptionGroups = (options: Array<SelectableValue<string>>) =>\n options.flatMap<SelectableValue<string>>((option) => (option.options ? [option, ...option.options] : [option]));\n\nexport const setupDropdownAccessibility = (\n options: Array<SelectableValue<string>>,\n listRef: React.MutableRefObject<Array<HTMLElement | null>>,\n disabledIndicesRef: React.MutableRefObject<number[]>\n) => {\n let maxOptionWidth = 182;\n const listRefArr = [];\n const disabledIndices = [];\n\n for (let i = 0; i < options.length; i++) {\n // listRefArr should be filled with nulls for amount of dropdown items so that\n // useNavigationList sets activeIndex correctly when navigating with arrow keys\n listRefArr.push(null);\n\n // disabledIndices are used to skip unselectable group items in dropdown when\n // navigating with arrow keys\n if (options[i]?.options) {\n disabledIndices.push(i);\n }\n let label = options[i].label ?? options[i].value ?? '';\n\n // rough widthEstimate\n const widthEstimate =\n (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER +\n VIRTUAL_LIST_PADDING * 2;\n if (widthEstimate > maxOptionWidth) {\n maxOptionWidth = widthEstimate;\n }\n }\n\n listRef.current = [...listRefArr];\n disabledIndicesRef.current = [...disabledIndices];\n return maxOptionWidth;\n};\n\n// used for updating inputType concurrently because other bunched updates depend on this being up to date\nexport const flushSyncInputType = (\n inputType: AdHocInputType,\n setInputType: React.Dispatch<React.SetStateAction<AdHocInputType>>\n) =>\n flushSync(() => {\n setInputType(inputType);\n });\n\n// WIP: POC for parsing key and operator values automatically\nexport const filterAutoParser = ({\n event,\n filterInputType,\n options,\n model,\n filter,\n setInputValue,\n setInputType,\n refs,\n}: {\n event: React.ChangeEvent<HTMLInputElement>;\n filterInputType: AdHocInputType;\n options: Array<SelectableValue<string>>;\n model: AdHocFiltersVariable;\n filter: AdHocFilterWithLabels | undefined;\n setInputValue: (value: React.SetStateAction<string>) => void;\n setInputType: (value: React.SetStateAction<AdHocInputType>) => void;\n refs: UseFloatingReturn<HTMLInputElement>['refs'];\n}) => {\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(filter!, 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(filter!, 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\nconst nextInputTypeMap = {\n key: 'operator',\n operator: 'value',\n value: 'key',\n} as const;\n\nexport const switchToNextInputType = (\n filterInputType: AdHocInputType,\n setInputType: React.Dispatch<React.SetStateAction<AdHocInputType>>,\n handleChangeViewMode: (() => void) | undefined\n) => {\n flushSyncInputType(nextInputTypeMap[filterInputType], setInputType);\n\n if (filterInputType === 'value') {\n handleChangeViewMode?.();\n }\n};\n"],"names":[],"mappings":";;;AAOA,MAAM,sCAAyC,GAAA,CAAA,CAAA;AAC/C,MAAM,oBAAuB,GAAA,CAAA,CAAA;AACtB,MAAM,qBAAwB,GAAA,EAAA;AAC9B,MAAM,wBAA2B,GAAA,GAAA;AACjC,MAAM,0BAA6B,GAAA,IAAA;AAEnC,SAAS,mBAAmB,OAAyC,EAAA;AAC1E,EAAM,MAAA,MAAA,GAAS,IAAI,MAAO,EAAA,CAAA;AAC1B,EAAA,MAAM,WAAqB,EAAC,CAAA;AAC5B,EAAA,MAAM,KAAQ,GAAA,GAAA,CAAA;AAEd,EAA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AAA,GACF;AACF;;;;"}
|
package/dist/index.js
CHANGED
@@ -3522,7 +3522,7 @@ const getStyles$c = (theme) => ({
|
|
3522
3522
|
left: 0,
|
3523
3523
|
width: "100%",
|
3524
3524
|
position: "absolute",
|
3525
|
-
padding:
|
3525
|
+
padding: theme.spacing(1),
|
3526
3526
|
display: "flex",
|
3527
3527
|
alignItems: "center",
|
3528
3528
|
flexDirection: "row",
|
@@ -3642,6 +3642,17 @@ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
|
3642
3642
|
const flushSyncInputType = (inputType, setInputType) => reactDom.flushSync(() => {
|
3643
3643
|
setInputType(inputType);
|
3644
3644
|
});
|
3645
|
+
const nextInputTypeMap = {
|
3646
|
+
key: "operator",
|
3647
|
+
operator: "value",
|
3648
|
+
value: "key"
|
3649
|
+
};
|
3650
|
+
const switchToNextInputType = (filterInputType, setInputType, handleChangeViewMode) => {
|
3651
|
+
flushSyncInputType(nextInputTypeMap[filterInputType], setInputType);
|
3652
|
+
if (filterInputType === "value") {
|
3653
|
+
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3654
|
+
}
|
3655
|
+
};
|
3645
3656
|
|
3646
3657
|
const MAX_MENU_HEIGHT = 300;
|
3647
3658
|
const useFloatingInteractions = ({
|
@@ -3838,14 +3849,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3838
3849
|
model._updateFilter(filter, filterInputType, filteredDropDownItems[activeIndex]);
|
3839
3850
|
setInputValue("");
|
3840
3851
|
setActiveIndex(0);
|
3841
|
-
|
3842
|
-
flushSyncInputType("operator", setInputType);
|
3843
|
-
} else if (filterInputType === "operator") {
|
3844
|
-
flushSyncInputType("value", setInputType);
|
3845
|
-
} else if (filterInputType === "value") {
|
3846
|
-
flushSyncInputType("key", setInputType);
|
3847
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3848
|
-
}
|
3852
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode);
|
3849
3853
|
(_a2 = refs.domReference.current) == null ? void 0 : _a2.focus();
|
3850
3854
|
}
|
3851
3855
|
},
|
@@ -3980,14 +3984,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
3980
3984
|
}
|
3981
3985
|
model._updateFilter(filter, filterInputType, item);
|
3982
3986
|
setInputValue("");
|
3983
|
-
|
3984
|
-
flushSyncInputType("operator", setInputType);
|
3985
|
-
} else if (filterInputType === "operator") {
|
3986
|
-
flushSyncInputType("value", setInputType);
|
3987
|
-
} else if (filterInputType === "value") {
|
3988
|
-
flushSyncInputType("key", setInputType);
|
3989
|
-
handleChangeViewMode == null ? void 0 : handleChangeViewMode();
|
3990
|
-
}
|
3987
|
+
switchToNextInputType(filterInputType, setInputType, handleChangeViewMode);
|
3991
3988
|
(_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
|
3992
3989
|
}
|
3993
3990
|
})), {
|
@@ -4021,7 +4018,7 @@ const getStyles$b = (theme) => ({
|
|
4021
4018
|
color: theme.colors.text.primary,
|
4022
4019
|
overflow: "hidden",
|
4023
4020
|
whiteSpace: "nowrap",
|
4024
|
-
minHeight:
|
4021
|
+
minHeight: theme.spacing(2.75)
|
4025
4022
|
}, theme.typography.bodySmall), {
|
4026
4023
|
cursor: "pointer"
|
4027
4024
|
})),
|
@@ -4091,10 +4088,12 @@ var __spreadValues$z = (a, b) => {
|
|
4091
4088
|
};
|
4092
4089
|
var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
|
4093
4090
|
function AdHocFilterPill({ filter, model, readOnly }) {
|
4094
|
-
var _a, _b
|
4091
|
+
var _a, _b;
|
4095
4092
|
const styles = ui.useStyles2(getStyles$a);
|
4096
4093
|
const [viewMode, setViewMode] = React.useState(true);
|
4097
4094
|
const pillWrapperRef = React.useRef(null);
|
4095
|
+
const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
|
4096
|
+
const valueLabel = (_b = filter.valueLabel) != null ? _b : filter.value;
|
4098
4097
|
const handleChangeViewMode = React.useCallback(
|
4099
4098
|
(event) => {
|
4100
4099
|
var _a2;
|
@@ -4125,10 +4124,10 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4125
4124
|
}
|
4126
4125
|
},
|
4127
4126
|
role: "button",
|
4128
|
-
"aria-label": `Edit filter with key ${
|
4127
|
+
"aria-label": `Edit filter with key ${keyLabel}`,
|
4129
4128
|
tabIndex: 0,
|
4130
4129
|
ref: pillWrapperRef
|
4131
|
-
}, /* @__PURE__ */ React__default["default"].createElement("span", null,
|
4130
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", null, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
4132
4131
|
onClick: (e) => {
|
4133
4132
|
e.stopPropagation();
|
4134
4133
|
model._removeFilter(filter);
|
@@ -4143,7 +4142,7 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4143
4142
|
name: "times",
|
4144
4143
|
size: "md",
|
4145
4144
|
className: styles.removeButton,
|
4146
|
-
tooltip: `Remove filter with key ${
|
4145
|
+
tooltip: `Remove filter with key ${keyLabel}`
|
4147
4146
|
}) : null);
|
4148
4147
|
}
|
4149
4148
|
return /* @__PURE__ */ React__default["default"].createElement(AdHocCombobox, {
|
@@ -4163,7 +4162,7 @@ const getStyles$a = (theme) => ({
|
|
4163
4162
|
color: theme.colors.text.primary,
|
4164
4163
|
overflow: "hidden",
|
4165
4164
|
whiteSpace: "nowrap",
|
4166
|
-
minHeight:
|
4165
|
+
minHeight: theme.spacing(2.75)
|
4167
4166
|
}, theme.typography.bodySmall), {
|
4168
4167
|
fontWeight: theme.typography.fontWeightBold,
|
4169
4168
|
cursor: "pointer",
|