@grafana/scenes 5.14.1--canary.889.10722729172.0 → 5.14.1--canary.890.10722192103.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 { Button, Icon, Spinner, Text, useStyles2 } from '@grafana/ui';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable, OPERATORS } from '../AdHocFiltersVariable';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport {\n DropdownItem,\n LoadingOptionsPlaceholder,\n MultiValueApplyButton,\n NoOptionsPlaceholder,\n OptionsErrorPlaceholder,\n} from './DropdownItem';\nimport {\n ERROR_STATE_DROPDOWN_WIDTH,\n flattenOptionGroups,\n fuzzySearchOptions,\n generateFilterUpdatePayload,\n setupDropdownAccessibility,\n switchInputType,\n switchToNextInputType,\n VIRTUAL_LIST_ITEM_HEIGHT,\n VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION,\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 // control multi values with local state in order to commit all values at once and avoid _wip reset mid creation\n const [filterMultiValues, setFilterMultiValues] = useState<Array<SelectableValue<string>>>([]);\n const [_, setForceRefresh] = useState({});\n\n const multiValueOperators = useMemo(\n () => OPERATORS.reduce<string[]>((acc, operator) => (operator.isMulti ? [...acc, operator.value!] : acc), []),\n []\n );\n\n const hasMultiValueOperator = multiValueOperators.includes(filter?.operator || '');\n const isMultiValueEdit = hasMultiValueOperator && filterInputType === 'value';\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 handleMultiValueFilterCommit = useCallback(\n (\n model: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels,\n filterMultiValues: Array<SelectableValue<string>>,\n preventFocus?: boolean\n ) => {\n if (filterMultiValues.length) {\n const valueLabels: string[] = [];\n const values: string[] = [];\n filterMultiValues.forEach((item) => {\n valueLabels.push(item.label ?? item.value!);\n values.push(item.value!);\n });\n // TODO remove when we're on the latest version of @grafana/data\n //@ts-expect-error\n model._updateFilter(filter!, { valueLabels, values, value: values[0] });\n setFilterMultiValues([]);\n }\n if (!preventFocus) {\n setTimeout(() => refs.domReference.current?.focus());\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const handleLocalMultiValueChange = useCallback((selectedItem: SelectableValue<string>) => {\n setFilterMultiValues((items) => {\n if (items.some((item) => item.value === selectedItem.value)) {\n return items.filter((item) => item.value !== selectedItem.value);\n }\n return [...items, selectedItem];\n });\n }, []);\n\n const handleRemoveMultiValue = useCallback(\n (item: SelectableValue<string>) =>\n setFilterMultiValues((selected) => selected.filter((option) => option.value !== item.value)),\n []\n );\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\n if (reason && ['outside-press', 'escape-key'].includes(reason)) {\n if (isMultiValueEdit) {\n // commit multi value filter values on escape and click-away\n handleMultiValueFilterCommit(model, filter!, filterMultiValues);\n }\n handleResetWip();\n handleChangeViewMode?.();\n }\n },\n [\n filter,\n filterMultiValues,\n handleChangeViewMode,\n handleMultiValueFilterCommit,\n handleResetWip,\n isMultiValueEdit,\n model,\n ]\n );\n\n // generate ids from multi values in order to prevent outside click based on those ids\n const outsidePressIdsToIgnore = useMemo(() => {\n return [operatorIdentifier, ...filterMultiValues.map((item, i) => `${item.value}-${i}`)];\n }, [operatorIdentifier, filterMultiValues]);\n\n const { refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps } = useFloatingInteractions({\n open,\n onOpenChange,\n activeIndex,\n setActiveIndex,\n outsidePressIdsToIgnore,\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: (index) =>\n filteredDropDownItems[index].description ? VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION : 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, multiValueEdit: boolean) => {\n if (event.key === 'Backspace' && !inputValue) {\n if (multiValueEdit) {\n setFilterMultiValues((items) => {\n const updated = [...items];\n updated.splice(-1, 1);\n\n return updated;\n });\n } else if (filterInputType === 'key') {\n model._removeLastFilter();\n handleFetchOptions(filterInputType);\n }\n }\n },\n [inputValue, filterInputType, model, handleFetchOptions]\n );\n\n const handleTabInput = useCallback(\n (event: React.KeyboardEvent, multiValueEdit?: boolean) => {\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 if (multiValueEdit) {\n // commit multi value filter values on tab away\n event.preventDefault();\n handleMultiValueFilterCommit(model, filter!, filterMultiValues);\n refs.domReference.current?.focus();\n }\n\n handleChangeViewMode?.();\n handleResetWip();\n }\n },\n [\n filter,\n filterMultiValues,\n handleChangeViewMode,\n handleMultiValueFilterCommit,\n handleResetWip,\n model,\n refs.domReference,\n ]\n );\n\n const handleShiftTabInput = useCallback(\n (event: React.KeyboardEvent, multiValueEdit?: boolean) => {\n if (event.key === 'Tab' && event.shiftKey) {\n if (multiValueEdit) {\n // commit multi value filter values on shift tab away\n event.preventDefault();\n handleMultiValueFilterCommit(model, filter!, filterMultiValues, true);\n }\n handleChangeViewMode?.();\n handleResetWip();\n }\n },\n [filter, filterMultiValues, handleChangeViewMode, handleMultiValueFilterCommit, handleResetWip, model]\n );\n\n const handleEnterInput = useCallback(\n (event: React.KeyboardEvent, multiValueEdit?: boolean) => {\n if (event.key === 'Enter' && activeIndex != null) {\n // safeguard for non existing items\n if (!filteredDropDownItems[activeIndex]) {\n return;\n }\n const selectedItem = filteredDropDownItems[activeIndex];\n\n if (multiValueEdit) {\n handleLocalMultiValueChange(selectedItem);\n } else {\n model._updateFilter(filter!, generateFilterUpdatePayload(filterInputType, selectedItem));\n\n switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);\n setActiveIndex(0);\n }\n\n setInputValue('');\n }\n },\n [\n activeIndex,\n filter,\n filterInputType,\n filteredDropDownItems,\n handleLocalMultiValueChange,\n handleChangeViewMode,\n model,\n refs.domReference,\n ]\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) {\n setInputType('value');\n setInputValue('');\n\n // TODO remove when we're on the latest version of @grafana/data\n //@ts-expect-error\n if (hasMultiValueOperator && filter?.values?.length) {\n // TODO remove when we're on the latest version of @grafana/data\n //@ts-expect-error\n const multiValueOptions = (filter.values as string[]).reduce<Array<SelectableValue<string>>>(\n (acc, value, i) => [\n ...acc,\n {\n label: filter.valueLabels?.[i] || value,\n value: value,\n },\n ],\n []\n );\n // populate filter multi values to local state on pill edit enter\n setFilterMultiValues(multiValueOptions);\n }\n\n refs.domReference.current?.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // this is required only with multi value select in order to update position\n // of the multi value apply button\n useEffect(() => {\n if (isMultiValueEdit && filterMultiValues) {\n setTimeout(() => setForceRefresh({}));\n }\n }, [filterMultiValues, isMultiValueEdit]);\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 const keyLabel = filter?.keyLabel ?? filter?.key;\n const valueLabel = filter?.valueLabels?.[0] ?? filter?.value;\n\n return (\n <div className={styles.comboboxWrapper}>\n {filter ? (\n <div className={styles.pillWrapper}>\n {/* Filter key pill render */}\n {filter?.key ? <div className={cx(styles.basePill, styles.keyPill)}>{keyLabel}</div> : 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 switchInputType('operator', setInputType, undefined, refs.domReference.current);\n }}\n onKeyDown={(event) => {\n handleShiftTabInput(event, hasMultiValueOperator);\n if (event.key === 'Enter') {\n switchInputType('operator', setInputType, undefined, refs.domReference.current);\n }\n }}\n >\n {filter.operator}\n </div>\n ) : null}\n\n {isMultiValueEdit\n ? filterMultiValues.map((item, i) => (\n <MultiValuePill\n key={`${item.value}-${i}`}\n item={item}\n index={i}\n handleRemoveMultiValue={handleRemoveMultiValue}\n />\n ))\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]} ${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\n if (filterInputType === 'operator') {\n handleShiftTabInput(event);\n }\n handleBackspaceInput(event, isMultiValueEdit);\n handleTabInput(event, isMultiValueEdit);\n handleEnterInput(event, isMultiValueEdit);\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 <>\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 =\n 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 // ref: rowVirtualizer.measureElement,\n onClick(event) {\n if (filterInputType !== 'value') {\n event.stopPropagation();\n }\n if (isMultiValueEdit) {\n event.stopPropagation();\n handleLocalMultiValueChange(item);\n refs.domReference.current?.focus();\n } else {\n model._updateFilter(filter!, generateFilterUpdatePayload(filterInputType, item));\n setInputValue('');\n\n switchToNextInputType(\n filterInputType,\n setInputType,\n handleChangeViewMode,\n refs.domReference.current\n );\n }\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 isMultiValueEdit={isMultiValueEdit}\n checked={filterMultiValues.some((val) => val.value === item.value)}\n >\n <span>\n {item.isCustom ? 'Use custom value: ' : ''} {item.label ?? item.value}\n </span>\n {item.description ? <div className={styles.descriptionText}>{item.description}</div> : null}\n </DropdownItem>\n );\n })\n )}\n </div>\n </div>\n {isMultiValueEdit && !optionsLoading && !optionsError && filteredDropDownItems.length ? (\n <MultiValueApplyButton\n onClick={() => handleMultiValueFilterCommit(model, filter!, filterMultiValues)}\n floatingElement={refs.floating.current}\n maxOptionWidth={maxOptionWidth}\n />\n ) : null}\n </>\n </FloatingFocusManager>\n )}\n </FloatingPortal>\n </div>\n );\n});\n\ninterface MultiValuePillProps {\n item: SelectableValue<string>;\n handleRemoveMultiValue: (item: SelectableValue<string>) => void;\n index: number;\n}\nconst MultiValuePill = ({ item, handleRemoveMultiValue, index }: MultiValuePillProps) => {\n const styles = useStyles2(getStyles);\n\n return (\n <div className={cx(styles.basePill, styles.valuePill)}>\n <span> {item.label ?? item.value}</span>\n <Button\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleRemoveMultiValue(item);\n }}\n onKeyDownCapture={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n handleRemoveMultiValue(item);\n }\n }}\n fill=\"text\"\n size=\"sm\"\n variant=\"secondary\"\n className={styles.removeButton}\n tooltip={`Remove filter value - ${item.label ?? item.value}`}\n >\n <Icon name=\"times\" size=\"md\" id={`${item.value}-${index}`} />\n </Button>\n </div>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n comboboxWrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n }),\n pillWrapper: css({\n display: 'flex',\n alignItems: 'center',\n flexWrap: 'wrap',\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 padding: theme.spacing(0.125, 0, 0.125, 1),\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 removeButton: css({\n marginInline: theme.spacing(0.5),\n height: '100%',\n padding: 0,\n cursor: 'pointer',\n '&:hover': {\n color: theme.colors.text.primary,\n },\n }),\n descriptionText: css({\n ...theme.typography.bodySmall,\n color: theme.colors.text.secondary,\n paddingTop: theme.spacing(0.5),\n }),\n multiValueApply: css({\n position: 'absolute',\n top: 0,\n left: 0,\n display: 'flex',\n }),\n});\n"],"names":["AdHocCombobox","model","filter","filterMultiValues","_a","_","options","_b"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDa,MAAA,aAAA,GAAgB,UAAW,CAAA,SAASA,cAC/C,CAAA,EAAE,QAAQ,KAAO,EAAA,WAAA,EAAa,oBAAqB,EAAA,EACnD,SACA,EAAA;AAnDF,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAoDE,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,CAA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T,MAAQ,EAAA,SAAA;AAAA,IACR,SAAW,EAAA;AAAA,MACT,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,OAAA;AAAA,KAC3B;AAAA,GACD,CAAA;AAAA,EACD,eAAiB,EAAA,GAAA,CAAI,aAChB,CAAA,cAAA,CAAA,EAAA,EAAA,KAAA,CAAM,WAAW,SADD,CAAA,EAAA;AAAA,IAEnB,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,SAAA;AAAA,IACzB,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,GAC9B,CAAA,CAAA;AAAA,EACD,iBAAiB,GAAI,CAAA;AAAA,IACnB,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,CAAA;AAAA,IACL,IAAM,EAAA,CAAA;AAAA,IACN,OAAS,EAAA,MAAA;AAAA,GACV,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 fuzzySearchOptions,\n generateFilterUpdatePayload,\n setupDropdownAccessibility,\n switchInputType,\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!, generateFilterUpdatePayload(filterInputType, filteredDropDownItems[activeIndex]));\n setInputValue('');\n setActiveIndex(0);\n\n switchToNextInputType(filterInputType, setInputType, handleChangeViewMode, refs.domReference.current);\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) {\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 const keyLabel = filter?.keyLabel ?? filter?.key;\n const valueLabel = filter?.valueLabels?.[0] ?? filter?.value;\n\n return (\n <div className={styles.comboboxWrapper}>\n {filter ? (\n <div className={styles.pillWrapper}>\n {/* Filter key pill render */}\n {filter?.key ? <div className={cx(styles.basePill, styles.keyPill)}>{keyLabel}</div> : 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 switchInputType('operator', setInputType, undefined, refs.domReference.current);\n }}\n onKeyDown={(event) => {\n handleShiftTabInput(event);\n if (event.key === 'Enter') {\n switchInputType('operator', setInputType, undefined, refs.domReference.current);\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)}>{valueLabel}</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]} ${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!, generateFilterUpdatePayload(filterInputType, item));\n setInputValue('');\n\n switchToNextInputType(\n filterInputType,\n setInputType,\n handleChangeViewMode,\n refs.domReference.current\n );\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%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;AAAA,IACpB,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACxB,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,CAAA;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,5 +1,5 @@
1
1
  import { cx, css } from '@emotion/css';
2
- import { useStyles2, Checkbox, Button } from '@grafana/ui';
2
+ import { useStyles2 } from '@grafana/ui';
3
3
  import React, { forwardRef, useId } from 'react';
4
4
 
5
5
  var __defProp = Object.defineProperty;
@@ -32,7 +32,7 @@ var __objRest = (source, exclude) => {
32
32
  };
33
33
  const DropdownItem = forwardRef(
34
34
  function DropdownItem2(_a, ref) {
35
- var _b = _a, { children, active, addGroupBottomBorder, isMultiValueEdit, checked } = _b, rest = __objRest(_b, ["children", "active", "addGroupBottomBorder", "isMultiValueEdit", "checked"]);
35
+ var _b = _a, { children, active, addGroupBottomBorder } = _b, rest = __objRest(_b, ["children", "active", "addGroupBottomBorder"]);
36
36
  const styles = useStyles2(getStyles);
37
37
  const id = useId();
38
38
  return /* @__PURE__ */ React.createElement("div", __spreadValues({
@@ -44,11 +44,7 @@ const DropdownItem = forwardRef(
44
44
  }, rest), /* @__PURE__ */ React.createElement("div", {
45
45
  className: styles.optionBody,
46
46
  "data-testid": `data-testid ad hoc filter option value ${children}`
47
- }, /* @__PURE__ */ React.createElement("span", null, isMultiValueEdit ? /* @__PURE__ */ React.createElement(Checkbox, {
48
- tabIndex: -1,
49
- checked,
50
- className: styles.checkbox
51
- }) : null, children)));
47
+ }, /* @__PURE__ */ React.createElement("span", null, children)));
52
48
  }
53
49
  );
54
50
  const getStyles = (theme) => ({
@@ -88,22 +84,6 @@ const getStyles = (theme) => ({
88
84
  }),
89
85
  groupBottomBorder: css({
90
86
  borderBottom: `1px solid ${theme.colors.border.weak}`
91
- }),
92
- checkbox: css({
93
- paddingRight: theme.spacing(0.5)
94
- }),
95
- multiValueApply: css({
96
- position: "absolute",
97
- top: 0,
98
- left: 0,
99
- display: "flex"
100
- }),
101
- dropdownWrapper: css({
102
- backgroundColor: theme.colors.background.primary,
103
- color: theme.colors.text.primary,
104
- boxShadow: theme.shadows.z2,
105
- overflowY: "auto",
106
- zIndex: theme.zIndex.dropdown
107
87
  })
108
88
  });
109
89
  const LoadingOptionsPlaceholder = () => {
@@ -121,22 +101,6 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
121
101
  onClick: handleFetchOptions
122
102
  }, "An error has occurred fetching labels. Click to retry");
123
103
  };
124
- const MultiValueApplyButton = ({ onClick, floatingElement, maxOptionWidth }) => {
125
- const styles = useStyles2(getStyles);
126
- const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
127
- return /* @__PURE__ */ React.createElement("div", {
128
- className: cx(styles.dropdownWrapper, styles.multiValueApply),
129
- style: {
130
- width: `${maxOptionWidth}px`,
131
- transform: `translate(${floatingElementRect == null ? void 0 : floatingElementRect.left}px,${floatingElementRect == null ? void 0 : floatingElementRect.bottom}px)`
132
- }
133
- }, /* @__PURE__ */ React.createElement(Button, {
134
- onClick,
135
- fill: "text",
136
- fullWidth: true,
137
- tabIndex: -1
138
- }, "Apply"));
139
- };
140
104
 
141
- export { DropdownItem, LoadingOptionsPlaceholder, MultiValueApplyButton, NoOptionsPlaceholder, OptionsErrorPlaceholder };
105
+ export { DropdownItem, LoadingOptionsPlaceholder, NoOptionsPlaceholder, OptionsErrorPlaceholder };
142
106
  //# sourceMappingURL=DropdownItem.js.map
@@ -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 { Button, Checkbox, useStyles2 } from '@grafana/ui';\nimport React, { forwardRef, useId } from 'react';\n\ninterface DropdownItemProps {\n children: React.ReactNode;\n active?: boolean;\n addGroupBottomBorder?: boolean;\n isMultiValueEdit?: boolean;\n checked?: boolean;\n}\n\nexport const DropdownItem = forwardRef<HTMLDivElement, DropdownItemProps & React.HTMLProps<HTMLDivElement>>(\n function DropdownItem({ children, active, addGroupBottomBorder, isMultiValueEdit, checked, ...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>\n {isMultiValueEdit ? <Checkbox tabIndex={-1} checked={checked} className={styles.checkbox} /> : null}\n {children}\n </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 checkbox: css({\n paddingRight: theme.spacing(0.5),\n }),\n multiValueApply: css({\n position: 'absolute',\n top: 0,\n left: 0,\n display: 'flex',\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});\n\nexport const LoadingOptionsPlaceholder = () => {\n return <DropdownItem onClick={(e) => e.stopPropagation()}>Loading options...</DropdownItem>;\n};\n\nexport const NoOptionsPlaceholder = () => {\n return <DropdownItem onClick={(e) => e.stopPropagation()}>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\ninterface MultiValueApplyButtonProps {\n onClick: () => void;\n floatingElement: HTMLElement | null;\n maxOptionWidth: number;\n}\n\nexport const MultiValueApplyButton = ({ onClick, floatingElement, maxOptionWidth }: MultiValueApplyButtonProps) => {\n const styles = useStyles2(getStyles);\n\n const floatingElementRect = floatingElement?.getBoundingClientRect();\n return (\n <div\n className={cx(styles.dropdownWrapper, styles.multiValueApply)}\n style={{\n width: `${maxOptionWidth}px`,\n transform: `translate(${floatingElementRect?.left}px,${floatingElementRect?.bottom}px)`,\n }}\n >\n <Button onClick={onClick} fill=\"text\" fullWidth tabIndex={-1}>\n Apply\n </Button>\n </div>\n );\n};\n"],"names":["DropdownItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aAAa,CAAA,EAAA,EAAgF,GAAK,EAAA;AAArF,IAAA,IAAA,EAAA,GAAA,EAAA,EAAE,EAAU,QAAA,EAAA,MAAA,EAAQ,oBAAsB,EAAA,gBAAA,EAAkB,OAdpF,EAAA,GAcwB,EAAw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AAA,KAAA,CAAA,GAAA,eAAA,CAAA,qBAAA,EAAA,CAAA;AAC7C,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IACC,SAAW,EAAA,EAAA,CAAG,MAAO,CAAA,eAAA,EAAiB,OAAO,eAAe,CAAA;AAAA,IAC5D,KAAO,EAAA;AAAA,MACL,OAAO,CAAG,EAAA,cAAA,CAAA,EAAA,CAAA;AAAA,MACV,SAAW,EAAA,CAAA,UAAA,EAAa,mBAAqB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,mBAAA,CAAA,IAAA,CAAA,GAAA,EAAU,mBAAqB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,CAAA;AAAA,KAC9E;AAAA,GAAA,kBAEC,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,IAAO,OAAA;AAAA,IAAkB,IAAK,EAAA,MAAA;AAAA,IAAO,SAAS,EAAA,IAAA;AAAA,IAAC,QAAU,EAAA,CAAA,CAAA;AAAA,GAAA,EAAI,OAE9D,CACF,CAAA,CAAA;AAEJ;;;;"}
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 onClick={(e) => e.stopPropagation()}>Loading options...</DropdownItem>;\n};\n\nexport const NoOptionsPlaceholder = () => {\n return <DropdownItem onClick={(e) => e.stopPropagation()}>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,EAAA;AAA1D,IAAE,IAAA,EAAA,GAAA,EAAA,EAAA,EAAA,QAAA,EAAU,QAAQ,oBAZ5C,EAAA,GAYwB,IAA6C,IAA7C,GAAA,SAAA,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AAA,GAAA,EAAG,kBAAgB,CAAA,CAAA;AAC5E,EAAA;AAEO,MAAM,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;;;;"}
@@ -6,7 +6,7 @@ const useFloatingInteractions = ({
6
6
  onOpenChange,
7
7
  activeIndex,
8
8
  setActiveIndex,
9
- outsidePressIdsToIgnore,
9
+ operatorIdentifier,
10
10
  listRef,
11
11
  disabledIndicesRef
12
12
  }) => {
@@ -30,13 +30,7 @@ const useFloatingInteractions = ({
30
30
  const role = useRole(context, { role: "listbox" });
31
31
  const dismiss = useDismiss(context, {
32
32
  outsidePress: (event) => {
33
- var _a;
34
- const target = event.currentTarget || event.target;
35
- let idToCompare = (target == null ? void 0 : target.id) || "";
36
- if ((target == null ? void 0 : target.nodeName) === "path") {
37
- idToCompare = ((_a = target.parentElement) == null ? void 0 : _a.id) || "";
38
- }
39
- if (outsidePressIdsToIgnore.includes(idToCompare)) {
33
+ if (event.currentTarget instanceof HTMLElement && event.currentTarget.id === operatorIdentifier) {
40
34
  return false;
41
35
  }
42
36
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"useFloatingInteractions.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.ts"],"sourcesContent":["import {\n useFloating,\n autoUpdate,\n offset,\n useRole,\n useDismiss,\n useListNavigation,\n UseFloatingOptions,\n flip,\n size,\n UseListNavigationProps,\n useInteractions,\n} from '@floating-ui/react';\n\ntype useFloatingInteractionsProps = {\n open: UseFloatingOptions['open'];\n onOpenChange: UseFloatingOptions['onOpenChange'];\n activeIndex: UseListNavigationProps['activeIndex'];\n setActiveIndex: UseListNavigationProps['onNavigate'];\n outsidePressIdsToIgnore: string[];\n listRef: React.MutableRefObject<Array<HTMLElement | null>>;\n disabledIndicesRef: React.MutableRefObject<number[]>;\n};\n\nconst MAX_MENU_HEIGHT = 300;\n\nexport const useFloatingInteractions = ({\n open,\n onOpenChange,\n activeIndex,\n setActiveIndex,\n outsidePressIdsToIgnore,\n listRef,\n disabledIndicesRef,\n}: useFloatingInteractionsProps) => {\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, availableWidth, elements }) {\n // limit maxHeight and maxWidth of dropdown\n elements.floating.style.maxHeight = `${Math.min(MAX_MENU_HEIGHT, availableHeight)}px`;\n elements.floating.style.maxWidth = `${availableWidth}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 const target = (event.currentTarget || event.target) as HTMLElement | null;\n let idToCompare = target?.id || '';\n if (target?.nodeName === 'path') {\n idToCompare = target.parentElement?.id || '';\n }\n\n if (outsidePressIdsToIgnore.includes(idToCompare)) {\n return false;\n }\n return true;\n },\n });\n const listNav = useListNavigation(context, {\n listRef,\n activeIndex,\n onNavigate: setActiveIndex,\n virtual: true,\n loop: true,\n disabledIndices: disabledIndicesRef.current,\n });\n\n const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([role, dismiss, listNav]);\n\n return {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n getItemProps,\n };\n};\n"],"names":[],"mappings":";;AAwBA,MAAM,eAAkB,GAAA,GAAA,CAAA;AAEjB,MAAM,0BAA0B,CAAC;AAAA,EACtC,IAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,uBAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AACF,CAAoC,KAAA;AAClC,EAAA,MAAM,EAAE,IAAA,EAAM,cA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AAM,KAAA,EAAA,CAAA;AAAA,OAC5C;AAEA,MAAI,IAAA,uBAAA,CAAwB,QAAS,CAAA,WAAW,CAAG,EAAA;AACjD,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AACA,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAAA,GACD,CAAA,CAAA;AACD,EAAM,MAAA,OAAA,GAAU,kBAAkB,OAAS,EAAA;AAAA,IACzC,OAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAY,EAAA,cAAA;AAAA,IACZ,OAAS,EAAA,IAAA;AAAA,IACT,IAAM,EAAA,IAAA;AAAA,IACN,iBAAiB,kBAAmB,CAAA,OAAA;AAAA,GACrC,CAAA,CAAA;AAED,EAAM,MAAA,EAAE,iBAAmB,EAAA,gBAAA,EAAkB,YAAa,EAAA,GAAI,gBAAgB,CAAC,IAAA,EAAM,OAAS,EAAA,OAAO,CAAC,CAAA,CAAA;AAEtG,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,cAAA;AAAA,IACA,OAAA;AAAA,IACA,iBAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"useFloatingInteractions.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/useFloatingInteractions.ts"],"sourcesContent":["import {\n useFloating,\n autoUpdate,\n offset,\n useRole,\n useDismiss,\n useListNavigation,\n UseFloatingOptions,\n flip,\n size,\n UseListNavigationProps,\n useInteractions,\n} from '@floating-ui/react';\n\ntype useFloatingInteractionsProps = {\n open: UseFloatingOptions['open'];\n onOpenChange: UseFloatingOptions['onOpenChange'];\n activeIndex: UseListNavigationProps['activeIndex'];\n setActiveIndex: UseListNavigationProps['onNavigate'];\n operatorIdentifier: string;\n listRef: React.MutableRefObject<Array<HTMLElement | null>>;\n disabledIndicesRef: React.MutableRefObject<number[]>;\n};\n\nconst MAX_MENU_HEIGHT = 300;\n\nexport const useFloatingInteractions = ({\n open,\n onOpenChange,\n activeIndex,\n setActiveIndex,\n operatorIdentifier,\n listRef,\n disabledIndicesRef,\n}: useFloatingInteractionsProps) => {\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, availableWidth, elements }) {\n // limit maxHeight and maxWidth of dropdown\n elements.floating.style.maxHeight = `${Math.min(MAX_MENU_HEIGHT, availableHeight)}px`;\n elements.floating.style.maxWidth = `${availableWidth}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 // if outside click lands on operator pill, then ignore outside click\n if (event.currentTarget instanceof HTMLElement && event.currentTarget.id === operatorIdentifier) {\n return false;\n }\n return true;\n },\n });\n const listNav = useListNavigation(context, {\n listRef,\n activeIndex,\n onNavigate: setActiveIndex,\n virtual: true,\n loop: true,\n disabledIndices: disabledIndicesRef.current,\n });\n\n const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([role, dismiss, listNav]);\n\n return {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n getItemProps,\n };\n};\n"],"names":[],"mappings":";;AAwBA,MAAM,eAAkB,GAAA,GAAA,CAAA;AAEjB,MAAM,0BAA0B,CAAC;AAAA,EACtC,IAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,kBAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AACF,CAAoC,KAAA;AAClC,EAAA,MAAM,EAAE,IAAA,EAAM,cAAgB,EAAA,OAAA,KAAY,WAA8B,CAAA;AAAA,IACtE,oBAAsB,EAAA,UAAA;AAAA,IACtB,IAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAW,EAAA,cAAA;AAAA,IACX,UAAY,EAAA;AAAA,MACV,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A;AAEtG,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,cAAA;AAAA,IACA,OAAA;AAAA,IACA,iBAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -4,7 +4,6 @@ const VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER = 8;
4
4
  const VIRTUAL_LIST_PADDING = 8;
5
5
  const VIRTUAL_LIST_OVERSCAN = 5;
6
6
  const VIRTUAL_LIST_ITEM_HEIGHT = 38;
7
- const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
8
7
  const ERROR_STATE_DROPDOWN_WIDTH = 366;
9
8
  function fuzzySearchOptions(options) {
10
9
  const ufuzzy = new uFuzzy();
@@ -55,7 +54,7 @@ function fuzzySearchOptions(options) {
55
54
  }
56
55
  const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
57
56
  const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
58
- var _a, _b, _c, _d;
57
+ var _a, _b, _c;
59
58
  let maxOptionWidth = 182;
60
59
  const listRefArr = [];
61
60
  const disabledIndices = [];
@@ -65,9 +64,6 @@ const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
65
64
  disabledIndices.push(i);
66
65
  }
67
66
  let label = (_c = (_b = options[i].label) != null ? _b : options[i].value) != null ? _c : "";
68
- if (label.length < (((_d = options[i].description) == null ? void 0 : _d.length) || 0)) {
69
- label = options[i].description;
70
- }
71
67
  const widthEstimate = (options[i].isCustom ? label.length + 18 : label.length) * VIRTUAL_LIST_WIDTH_ESTIMATE_MULTIPLIER + VIRTUAL_LIST_PADDING * 2;
72
68
  if (widthEstimate > maxOptionWidth) {
73
69
  maxOptionWidth = widthEstimate;
@@ -111,5 +107,5 @@ const generateFilterUpdatePayload = (filterInputType, item) => {
111
107
  };
112
108
  };
113
109
 
114
- export { ERROR_STATE_DROPDOWN_WIDTH, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION, VIRTUAL_LIST_OVERSCAN, flattenOptionGroups, fuzzySearchOptions, generateFilterUpdatePayload, setupDropdownAccessibility, switchInputType, switchToNextInputType };
110
+ export { ERROR_STATE_DROPDOWN_WIDTH, VIRTUAL_LIST_ITEM_HEIGHT, VIRTUAL_LIST_OVERSCAN, flattenOptionGroups, fuzzySearchOptions, generateFilterUpdatePayload, setupDropdownAccessibility, switchInputType, switchToNextInputType };
115
111
  //# 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 { 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 VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;\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 if (label.length < (options[i].description?.length || 0)) {\n label = options[i].description!;\n }\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// 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!, generateFilterUpdatePayload(filterInputType, options[optionIndex]));\n setInputValue(lastChar);\n }\n switchInputType('operator', setInputType, undefined, refs.domReference.current);\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!, generateFilterUpdatePayload(filterInputType, options[optionIndex]));\n setInputValue(lastChar);\n }\n switchInputType('value', setInputType, undefined, refs.domReference.current);\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 element: HTMLInputElement | null\n) =>\n switchInputType(\n nextInputTypeMap[filterInputType],\n setInputType,\n filterInputType === 'value' ? handleChangeViewMode : undefined,\n element\n );\n\nexport const switchInputType = (\n filterInputType: AdHocInputType,\n setInputType: React.Dispatch<React.SetStateAction<AdHocInputType>>,\n handleChangeViewMode?: () => void,\n element?: HTMLInputElement | null\n) => {\n setInputType(filterInputType);\n\n handleChangeViewMode?.();\n\n setTimeout(() => element?.focus());\n};\n\nexport const generateFilterUpdatePayload = (\n filterInputType: AdHocInputType,\n item: SelectableValue<string>\n): Partial<AdHocFilterWithLabels> => {\n if (filterInputType === 'key') {\n return {\n key: item.value,\n keyLabel: item.label ? item.label : item.value,\n };\n }\n if (filterInputType === 'value') {\n return {\n value: item.value,\n valueLabels: [item.label ? item.label : item.value!],\n };\n }\n\n return {\n [filterInputType]: item.value,\n };\n};\n"],"names":[],"mappings":";;AAMA,MAAM,sCAAyC,GAAA,CAAA,CAAA;AAC/C,MAAM,oBAAuB,GAAA,CAAA,CAAA;AACtB,MAAM,qBAAwB,GAAA,EAAA;AAC9B,MAAM,wBAA2B,GAAA,GAAA;AACjC,MAAM,yCAA4C,GAAA,GAAA;AAClD,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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I,oBAAoB,OAAS,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL,OAAO,IAAK,CAAA,KAAA;AAAA,MACZ,aAAa,CAAC,IAAA,CAAK,QAAQ,IAAK,CAAA,KAAA,GAAQ,KAAK,KAAM,CAAA;AAAA,KACrD,CAAA;AAAA,GACF;AAEA,EAAO,OAAA;AAAA,IACL,CAAC,kBAAkB,IAAK,CAAA,KAAA;AAAA,GAC1B,CAAA;AACF;;;;"}
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 { 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// 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!, generateFilterUpdatePayload(filterInputType, options[optionIndex]));\n setInputValue(lastChar);\n }\n switchInputType('operator', setInputType, undefined, refs.domReference.current);\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!, generateFilterUpdatePayload(filterInputType, options[optionIndex]));\n setInputValue(lastChar);\n }\n switchInputType('value', setInputType, undefined, refs.domReference.current);\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 element: HTMLInputElement | null\n) =>\n switchInputType(\n nextInputTypeMap[filterInputType],\n setInputType,\n filterInputType === 'value' ? handleChangeViewMode : undefined,\n element\n );\n\nexport const switchInputType = (\n filterInputType: AdHocInputType,\n setInputType: React.Dispatch<React.SetStateAction<AdHocInputType>>,\n handleChangeViewMode?: () => void,\n element?: HTMLInputElement | null\n) => {\n setInputType(filterInputType);\n\n handleChangeViewMode?.();\n\n setTimeout(() => element?.focus());\n};\n\nexport const generateFilterUpdatePayload = (\n filterInputType: AdHocInputType,\n item: SelectableValue<string>\n): Partial<AdHocFilterWithLabels> => {\n if (filterInputType === 'key') {\n return {\n key: item.value,\n keyLabel: item.label ? item.label : item.value,\n };\n }\n if (filterInputType === 'value') {\n return {\n value: item.value,\n valueLabels: [item.label ? item.label : item.value!],\n };\n }\n\n return {\n [fil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,KAAA;AACT,CAAA,CAAA;AAEO,MAAM,qBAAwB,GAAA,CACnC,eACA,EAAA,YAAA,EACA,sBACA,OAEA,KAAA,eAAA;AAAA,EACE,gBAAiB,CAAA,eAAA,CAAA;AAAA,EACjB,YAAA;AAAA,EACA,eAAA,KAAoB,UAAU,oBAAuB,GAAA,KAAA,CAAA;AAAA,EACrD,OAAA;AACF,EAAA;AAEK,MAAM,eAAkB,GAAA,CAC7B,eACA,EAAA,YAAA,EACA,sBACA,OACG,KAAA;AACH,EAAA,YAAA,CAAa,eAAe,CAAA,CAAA;AAE5B,EAAA,oBAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,oBAAA,EAAA,CAAA;AAEA,EAAW,UAAA,CAAA,MAAM,mCAAS,KAAO,EAAA,CAAA,CAAA;AACnC,EAAA;AAEa,MAAA,2BAAA,GAA8B,CACzC,eAAA,EACA,IACmC,KAAA;AACnC,EAAA,IAAI,oBAAoB,KAAO,EAAA;AAC7B,IAAO,OAAA;AAAA,MACL,KAAK,IAAK,CAAA,KAAA;AAAA,MACV,QAAU,EAAA,IAAA,CAAK,KAAQ,GAAA,IAAA,CAAK,QAAQ,IAAK,CAAA,KAAA;AAAA,KAC3C,CAAA;AAAA,GACF;AACA,EAAA,IAAI,oBAAoB,OAAS,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL,OAAO,IAAK,CAAA,KAAA;AAAA,MACZ,aAAa,CAAC,IAAA,CAAK,QAAQ,IAAK,CAAA,KAAA,GAAQ,KAAK,KAAM,CAAA;AAAA,KACrD,CAAA;AAAA,GACF;AAEA,EAAO,OAAA;AAAA,IACL,CAAC,kBAAkB,IAAK,CAAA,KAAA;AAAA,GAC1B,CAAA;AACF;;;;"}
@@ -205,7 +205,7 @@ function renderExpression(builder, filters) {
205
205
  function AdHocFiltersVariableRenderer({ model }) {
206
206
  const { filters, readOnly, addFilterButtonText } = model.useState();
207
207
  const styles = useStyles2(getStyles);
208
- if (model.state.layout === "combobox") {
208
+ if (!model.state.supportsMultiValueOperators && model.state.layout === "combobox") {
209
209
  return /* @__PURE__ */ React.createElement(AdHocFiltersComboboxRenderer, {
210
210
  model
211
211
  });
@@ -254,5 +254,5 @@ function isMultiValueOperator(operatorValue) {
254
254
  return Boolean(operator.isMulti);
255
255
  }
256
256
 
257
- export { AdHocFiltersVariable, AdHocFiltersVariableRenderer, OPERATORS, isFilterComplete, isMultiValueOperator, toSelectableValue };
257
+ export { AdHocFiltersVariable, AdHocFiltersVariableRenderer, isFilterComplete, isMultiValueOperator, toSelectableValue };
258
258
  //# sourceMappingURL=AdHocFiltersVariable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdHocFiltersVariable.js","sources":["../../../../src/variables/adhoc/AdHocFiltersVariable.tsx"],"sourcesContent":["import React from 'react';\n// @ts-expect-error Remove when 11.1.x is released\nimport { AdHocVariableFilter, GetTagResponse, GrafanaTheme2, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { ControlsLayout, SceneComponentProps } from '../../core/types';\nimport { DataSourceRef } from '@grafana/schema';\nimport { dataFromResponse, getQueriesForVariables, renderPrometheusLabelFilters, responseHasError } from '../utils';\nimport { patchGetAdhocFilters } from './patchGetAdhocFilters';\nimport { useStyles2 } from '@grafana/ui';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { AdHocFilterBuilder } from './AdHocFilterBuilder';\nimport { AdHocFilterRenderer } from './AdHocFilterRenderer';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler';\nimport { css } from '@emotion/css';\nimport { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest';\nimport { AdHocFiltersComboboxRenderer } from './AdHocFiltersCombobox/AdHocFiltersComboboxRenderer';\nimport { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject';\n\nexport interface AdHocFilterWithLabels extends AdHocVariableFilter {\n keyLabel?: string;\n valueLabels?: string[];\n}\n\nexport type AdHocControlsLayout = ControlsLayout | 'combobox';\n\nexport interface AdHocFiltersVariableState extends SceneVariableState {\n /** Optional text to display on the 'add filter' button */\n addFilterButtonText?: string;\n /** The visible filters */\n filters: AdHocFilterWithLabels[];\n /** Base filters to always apply when looking up keys*/\n baseFilters?: AdHocFilterWithLabels[];\n /** Datasource to use for getTagKeys and getTagValues and also controls which scene queries the filters should apply to */\n datasource: DataSourceRef | null;\n /** Controls if the filters can be changed */\n readOnly?: boolean;\n /**\n * @experimental\n * Controls the layout and design of the label.\n */\n layout?: AdHocControlsLayout;\n /**\n * Defaults to automatic which means filters will automatically be applied to all queries with the same data source as this AdHocFilterSet.\n * In manual mode you either have to use the filters programmatically or as a variable inside query expressions.\n */\n applyMode: 'auto' | 'manual';\n /**\n * Filter out the keys that do not match the regex.\n */\n tagKeyRegexFilter?: RegExp;\n /**\n * Extension hook for customizing the key lookup.\n * Return replace: true if you want to override the default lookup\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagKeysProvider?: getTagKeysProvider;\n /**\n * Extension hook for customizing the value lookup.\n * Return replace: true if you want to override the default lookup.\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagValuesProvider?: getTagValuesProvider;\n\n /**\n * Optionally provide an array of static keys that override getTagKeys\n */\n defaultKeys?: MetricFindValue[];\n\n /**\n * This is the expression that the filters resulted in. Defaults to\n * Prometheus / Loki compatible label filter expression\n */\n filterExpression?: string;\n\n /**\n * The default builder creates a Prometheus/Loki compatible filter expression,\n * this can be overridden to create a different expression based on the current filters.\n */\n expressionBuilder?: AdHocVariableExpressionBuilderFn;\n\n /**\n * Whether the filter supports new multi-value operators like =| and !=|\n */\n supportsMultiValueOperators?: boolean;\n\n /**\n * When querying the datasource for label names and values to determine keys and values\n * for this ad hoc filter, consider the queries in the scene and use them as a filter.\n * This queries filter can be used to ensure that only ad hoc filter options that would\n * impact the current queries are presented to the user.\n */\n useQueriesAsFilterForOptions?: boolean;\n\n /**\n * @internal state of the new filter being added\n */\n _wip?: AdHocFilterWithLabels;\n}\n\nexport type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;\n\nexport type getTagKeysProvider = (\n variable: AdHocFiltersVariable,\n currentKey: string | null\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type getTagValuesProvider = (\n variable: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type AdHocFiltersVariableCreateHelperArgs = AdHocFiltersVariableState;\n\nexport type OperatorDefinition = {\n value: string;\n description?: string;\n isMulti?: Boolean;\n};\n\nexport const OPERATORS: OperatorDefinition[] = [\n {\n value: '=',\n },\n {\n value: '!=',\n },\n {\n value: '=|',\n description: 'Is one of. Use to filter on multiple values.',\n isMulti: true,\n },\n {\n value: '!=|',\n description: 'Is not one of. Use to exclude multiple values.',\n isMulti: true,\n },\n {\n value: '=~',\n description: 'Matches regex',\n },\n {\n value: '!~',\n description: 'Does not match regex',\n },\n {\n value: '<',\n },\n {\n value: '>',\n },\n];\n\nexport class AdHocFiltersVariable\n extends SceneObjectBase<AdHocFiltersVariableState>\n implements SceneVariable<AdHocFiltersVariableState>\n{\n static Component = AdHocFiltersVariableRenderer;\n\n private _scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };\n private _dataSourceSrv = getDataSourceSrv();\n\n protected _urlSync = new AdHocFiltersVariableUrlSyncHandler(this);\n\n public constructor(state: Partial<AdHocFiltersVariableState>) {\n super({\n type: 'adhoc',\n name: state.name ?? 'Filters',\n filters: [],\n datasource: null,\n applyMode: 'auto',\n filterExpression: state.filterExpression ?? renderExpression(state.expressionBuilder, state.filters),\n ...state,\n });\n\n if (this.state.applyMode === 'auto') {\n patchGetAdhocFilters(this);\n }\n }\n\n public setState(update: Partial<AdHocFiltersVariableState>): void {\n let filterExpressionChanged = false;\n\n if (update.filters && update.filters !== this.state.filters && !update.filterExpression) {\n update.filterExpression = renderExpression(this.state.expressionBuilder, update.filters);\n filterExpressionChanged = update.filterExpression !== this.state.filterExpression;\n }\n\n super.setState(update);\n\n if (filterExpressionChanged) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n public getValue(): VariableValue | undefined {\n return this.state.filterExpression;\n }\n\n public _updateFilter(filter: AdHocFilterWithLabels, update: Partial<AdHocFilterWithLabels>) {\n const { filters, _wip } = this.state;\n\n if (filter === _wip) {\n // If we set value we are done with this \"work in progress\" filter and we can add it\n if ('value' in update && update['value'] !== '') {\n this.setState({ filters: [...filters, { ..._wip, ...update }], _wip: undefined });\n } else {\n this.setState({ _wip: { ...filter, ...update } });\n }\n return;\n }\n\n const updatedFilters = this.state.filters.map((f) => {\n return f === filter ? { ...f, ...update } : f;\n });\n\n this.setState({ filters: updatedFilters });\n }\n\n public _removeFilter(filter: AdHocFilterWithLabels) {\n if (filter === this.state._wip) {\n this.setState({ _wip: undefined });\n return;\n }\n\n this.setState({ filters: this.state.filters.filter((f) => f !== filter) });\n }\n\n public _removeLastFilter() {\n const filterToRemove = this.state.filters.at(-1);\n\n if (filterToRemove) {\n this._removeFilter(filterToRemove);\n }\n }\n\n /**\n * Get possible keys given current filters. Do not call from plugins directly\n */\n public async _getKeys(currentKey: string | null): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagKeysProvider?.(this, currentKey);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n if (this.state.defaultKeys) {\n return this.state.defaultKeys.map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n if (!ds || !ds.getTagKeys) {\n return [];\n }\n\n const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat(this.state.baseFilters ?? []);\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n const response = await ds.getTagKeys({\n filters: otherFilters,\n queries,\n timeRange,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let keys = dataFromResponse(response);\n if (override) {\n keys = keys.concat(dataFromResponse(override.values));\n }\n\n const tagKeyRegexFilter = this.state.tagKeyRegexFilter;\n if (tagKeyRegexFilter) {\n // @ts-expect-error Remove when 11.1.x is released\n keys = keys.filter((f) => f.text.match(tagKeyRegexFilter));\n }\n\n return keys.map(toSelectableValue);\n }\n\n /**\n * Get possible key values for a specific key given current filters. Do not call from plugins directly\n */\n public async _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagValuesProvider?.(this, filter);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n\n if (!ds || !ds.getTagValues) {\n return [];\n }\n\n // Filter out the current filter key from the list of all filters\n const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(this.state.baseFilters ?? []);\n\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n\n const response = await ds.getTagValues({\n key: filter.key,\n filters: otherFilters,\n timeRange, // @ts-expect-error TODO: remove this once 11.1.x is released\n queries,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let values = dataFromResponse(response);\n if (override) {\n values = values.concat(dataFromResponse(override.values));\n }\n\n return values.map(toSelectableValue);\n }\n\n public _addWip() {\n this.setState({\n _wip: { key: '', value: '', operator: '=', condition: '' },\n });\n }\n\n public _getOperators() {\n const filteredOperators = this.state.supportsMultiValueOperators\n ? OPERATORS\n : OPERATORS.filter((operator) => !operator.isMulti);\n return filteredOperators.map<SelectableValue<string>>(({ value, description }) => ({\n label: value,\n value,\n description,\n }));\n }\n}\n\nfunction renderExpression(\n builder: AdHocVariableExpressionBuilderFn | undefined,\n filters: AdHocFilterWithLabels[] | undefined\n) {\n return (builder ?? renderPrometheusLabelFilters)(filters ?? []);\n}\n\nexport function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>) {\n const { filters, readOnly, addFilterButtonText } = model.useState();\n const styles = useStyles2(getStyles);\n\n if (model.state.layout === 'combobox') {\n return <AdHocFiltersComboboxRenderer model={model} />;\n }\n\n return (\n <div className={styles.wrapper}>\n {filters.map((filter, index) => (\n <React.Fragment key={index}>\n <AdHocFilterRenderer filter={filter} model={model} />\n </React.Fragment>\n ))}\n\n {!readOnly && <AdHocFilterBuilder model={model} key=\"'builder\" addFilterButtonText={addFilterButtonText} />}\n </div>\n );\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'flex-end',\n columnGap: theme.spacing(2),\n rowGap: theme.spacing(1),\n }),\n});\n\nexport function toSelectableValue(input: MetricFindValue): SelectableValue<string> {\n const { text, value } = input;\n const result: SelectableValue<string> = {\n label: text,\n value: String(value ?? text),\n };\n\n if ('group' in input) {\n result.group = input.group;\n }\n\n return result;\n}\n\nexport function isFilterComplete(filter: AdHocFilterWithLabels): boolean {\n return filter.key !== '' && filter.operator !== '' && filter.value !== '';\n}\n\nexport function isMultiValueOperator(operatorValue: string): boolean {\n const operator = OPERATORS.find((o) => o.value === operatorValue);\n if (!operator) {\n throw new Error('Unknown operator');\n }\n return Boolean(operator.isMulti);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHO,MAAM,SAAkC,GAAA;AAAA,EAC7C;AAAA,IACE,KAAO,EAAA,GAAA;AAAA,GACT;AAAA,EACA;AAAA,IACE,KAAO,EAAA,IAAA;AAAA,GACT;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,EAAO,OAAA,MAAA,CAAA;AACT,CAAA;AAEO,SAAS,iBAAiB,MAAwC,EAAA;AACvE,EAAA,OAAO,OAAO,GAAQ,KAAA,EAAA,IAAM,OAAO,QAAa,KAAA,EAAA,IAAM,OAAO,KAAU,KAAA,EAAA,CAAA;AACzE,CAAA;AAEO,SAAS,qBAAqB,aAAgC,EAAA;AACnE,EAAA,MAAM,WAAW,SAAU,CAAA,IAAA,CAAK,CAAC,CAAM,KAAA,CAAA,CAAE,UAAU,aAAa,CAAA,CAAA;AAChE,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,kBAAkB,CAAA,CAAA;AAAA,GACpC;AACA,EAAO,OAAA,OAAA,CAAQ,SAAS,OAAO,CAAA,CAAA;AACjC;;;;"}
1
+ {"version":3,"file":"AdHocFiltersVariable.js","sources":["../../../../src/variables/adhoc/AdHocFiltersVariable.tsx"],"sourcesContent":["import React from 'react';\n// @ts-expect-error Remove when 11.1.x is released\nimport { AdHocVariableFilter, GetTagResponse, GrafanaTheme2, MetricFindValue, SelectableValue } from '@grafana/data';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\nimport { ControlsLayout, SceneComponentProps } from '../../core/types';\nimport { DataSourceRef } from '@grafana/schema';\nimport { dataFromResponse, getQueriesForVariables, renderPrometheusLabelFilters, responseHasError } from '../utils';\nimport { patchGetAdhocFilters } from './patchGetAdhocFilters';\nimport { useStyles2 } from '@grafana/ui';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { AdHocFilterBuilder } from './AdHocFilterBuilder';\nimport { AdHocFilterRenderer } from './AdHocFilterRenderer';\nimport { getDataSourceSrv } from '@grafana/runtime';\nimport { AdHocFiltersVariableUrlSyncHandler } from './AdHocFiltersVariableUrlSyncHandler';\nimport { css } from '@emotion/css';\nimport { getEnrichedFiltersRequest } from '../getEnrichedFiltersRequest';\nimport { AdHocFiltersComboboxRenderer } from './AdHocFiltersCombobox/AdHocFiltersComboboxRenderer';\nimport { wrapInSafeSerializableSceneObject } from '../../utils/wrapInSafeSerializableSceneObject';\n\nexport interface AdHocFilterWithLabels extends AdHocVariableFilter {\n keyLabel?: string;\n valueLabels?: string[];\n}\n\nexport type AdHocControlsLayout = ControlsLayout | 'combobox';\n\nexport interface AdHocFiltersVariableState extends SceneVariableState {\n /** Optional text to display on the 'add filter' button */\n addFilterButtonText?: string;\n /** The visible filters */\n filters: AdHocFilterWithLabels[];\n /** Base filters to always apply when looking up keys*/\n baseFilters?: AdHocFilterWithLabels[];\n /** Datasource to use for getTagKeys and getTagValues and also controls which scene queries the filters should apply to */\n datasource: DataSourceRef | null;\n /** Controls if the filters can be changed */\n readOnly?: boolean;\n /**\n * @experimental\n * Controls the layout and design of the label.\n */\n layout?: AdHocControlsLayout;\n /**\n * Defaults to automatic which means filters will automatically be applied to all queries with the same data source as this AdHocFilterSet.\n * In manual mode you either have to use the filters programmatically or as a variable inside query expressions.\n */\n applyMode: 'auto' | 'manual';\n /**\n * Filter out the keys that do not match the regex.\n */\n tagKeyRegexFilter?: RegExp;\n /**\n * Extension hook for customizing the key lookup.\n * Return replace: true if you want to override the default lookup\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagKeysProvider?: getTagKeysProvider;\n /**\n * Extension hook for customizing the value lookup.\n * Return replace: true if you want to override the default lookup.\n * Return replace: false if you want to combine the results with the default lookup\n */\n getTagValuesProvider?: getTagValuesProvider;\n\n /**\n * Optionally provide an array of static keys that override getTagKeys\n */\n defaultKeys?: MetricFindValue[];\n\n /**\n * This is the expression that the filters resulted in. Defaults to\n * Prometheus / Loki compatible label filter expression\n */\n filterExpression?: string;\n\n /**\n * The default builder creates a Prometheus/Loki compatible filter expression,\n * this can be overridden to create a different expression based on the current filters.\n */\n expressionBuilder?: AdHocVariableExpressionBuilderFn;\n\n /**\n * Whether the filter supports new multi-value operators like =| and !=|\n */\n supportsMultiValueOperators?: boolean;\n\n /**\n * When querying the datasource for label names and values to determine keys and values\n * for this ad hoc filter, consider the queries in the scene and use them as a filter.\n * This queries filter can be used to ensure that only ad hoc filter options that would\n * impact the current queries are presented to the user.\n */\n useQueriesAsFilterForOptions?: boolean;\n\n /**\n * @internal state of the new filter being added\n */\n _wip?: AdHocFilterWithLabels;\n}\n\nexport type AdHocVariableExpressionBuilderFn = (filters: AdHocFilterWithLabels[]) => string;\n\nexport type getTagKeysProvider = (\n variable: AdHocFiltersVariable,\n currentKey: string | null\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type getTagValuesProvider = (\n variable: AdHocFiltersVariable,\n filter: AdHocFilterWithLabels\n) => Promise<{ replace?: boolean; values: GetTagResponse | MetricFindValue[] }>;\n\nexport type AdHocFiltersVariableCreateHelperArgs = AdHocFiltersVariableState;\n\nexport type OperatorDefinition = {\n value: string;\n description?: string;\n isMulti?: Boolean;\n};\n\nconst OPERATORS: OperatorDefinition[] = [\n {\n value: '=',\n },\n {\n value: '!=',\n },\n {\n value: '=|',\n description: 'Is one of. Use to filter on multiple values.',\n isMulti: true,\n },\n {\n value: '!=|',\n description: 'Is not one of. Use to exclude multiple values.',\n isMulti: true,\n },\n {\n value: '=~',\n description: 'Matches regex',\n },\n {\n value: '!~',\n description: 'Does not match regex',\n },\n {\n value: '<',\n },\n {\n value: '>',\n },\n];\n\nexport class AdHocFiltersVariable\n extends SceneObjectBase<AdHocFiltersVariableState>\n implements SceneVariable<AdHocFiltersVariableState>\n{\n static Component = AdHocFiltersVariableRenderer;\n\n private _scopedVars = { __sceneObject: wrapInSafeSerializableSceneObject(this) };\n private _dataSourceSrv = getDataSourceSrv();\n\n protected _urlSync = new AdHocFiltersVariableUrlSyncHandler(this);\n\n public constructor(state: Partial<AdHocFiltersVariableState>) {\n super({\n type: 'adhoc',\n name: state.name ?? 'Filters',\n filters: [],\n datasource: null,\n applyMode: 'auto',\n filterExpression: state.filterExpression ?? renderExpression(state.expressionBuilder, state.filters),\n ...state,\n });\n\n if (this.state.applyMode === 'auto') {\n patchGetAdhocFilters(this);\n }\n }\n\n public setState(update: Partial<AdHocFiltersVariableState>): void {\n let filterExpressionChanged = false;\n\n if (update.filters && update.filters !== this.state.filters && !update.filterExpression) {\n update.filterExpression = renderExpression(this.state.expressionBuilder, update.filters);\n filterExpressionChanged = update.filterExpression !== this.state.filterExpression;\n }\n\n super.setState(update);\n\n if (filterExpressionChanged) {\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n public getValue(): VariableValue | undefined {\n return this.state.filterExpression;\n }\n\n public _updateFilter(filter: AdHocFilterWithLabels, update: Partial<AdHocFilterWithLabels>) {\n const { filters, _wip } = this.state;\n\n if (filter === _wip) {\n // If we set value we are done with this \"work in progress\" filter and we can add it\n if ('value' in update && update['value'] !== '') {\n this.setState({ filters: [...filters, { ..._wip, ...update }], _wip: undefined });\n } else {\n this.setState({ _wip: { ...filter, ...update } });\n }\n return;\n }\n\n const updatedFilters = this.state.filters.map((f) => {\n return f === filter ? { ...f, ...update } : f;\n });\n\n this.setState({ filters: updatedFilters });\n }\n\n public _removeFilter(filter: AdHocFilterWithLabels) {\n if (filter === this.state._wip) {\n this.setState({ _wip: undefined });\n return;\n }\n\n this.setState({ filters: this.state.filters.filter((f) => f !== filter) });\n }\n\n public _removeLastFilter() {\n const filterToRemove = this.state.filters.at(-1);\n\n if (filterToRemove) {\n this._removeFilter(filterToRemove);\n }\n }\n\n /**\n * Get possible keys given current filters. Do not call from plugins directly\n */\n public async _getKeys(currentKey: string | null): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagKeysProvider?.(this, currentKey);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n if (this.state.defaultKeys) {\n return this.state.defaultKeys.map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n if (!ds || !ds.getTagKeys) {\n return [];\n }\n\n const otherFilters = this.state.filters.filter((f) => f.key !== currentKey).concat(this.state.baseFilters ?? []);\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n const response = await ds.getTagKeys({\n filters: otherFilters,\n queries,\n timeRange,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let keys = dataFromResponse(response);\n if (override) {\n keys = keys.concat(dataFromResponse(override.values));\n }\n\n const tagKeyRegexFilter = this.state.tagKeyRegexFilter;\n if (tagKeyRegexFilter) {\n // @ts-expect-error Remove when 11.1.x is released\n keys = keys.filter((f) => f.text.match(tagKeyRegexFilter));\n }\n\n return keys.map(toSelectableValue);\n }\n\n /**\n * Get possible key values for a specific key given current filters. Do not call from plugins directly\n */\n public async _getValuesFor(filter: AdHocFilterWithLabels): Promise<Array<SelectableValue<string>>> {\n const override = await this.state.getTagValuesProvider?.(this, filter);\n\n if (override && override.replace) {\n return dataFromResponse(override.values).map(toSelectableValue);\n }\n\n const ds = await this._dataSourceSrv.get(this.state.datasource, this._scopedVars);\n\n if (!ds || !ds.getTagValues) {\n return [];\n }\n\n // Filter out the current filter key from the list of all filters\n const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(this.state.baseFilters ?? []);\n\n const timeRange = sceneGraph.getTimeRange(this).state.value;\n const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : undefined;\n\n const response = await ds.getTagValues({\n key: filter.key,\n filters: otherFilters,\n timeRange, // @ts-expect-error TODO: remove this once 11.1.x is released\n queries,\n ...getEnrichedFiltersRequest(this),\n });\n\n if (responseHasError(response)) {\n // @ts-expect-error Remove when 11.1.x is released\n this.setState({ error: response.error.message });\n }\n\n let values = dataFromResponse(response);\n if (override) {\n values = values.concat(dataFromResponse(override.values));\n }\n\n return values.map(toSelectableValue);\n }\n\n public _addWip() {\n this.setState({\n _wip: { key: '', value: '', operator: '=', condition: '' },\n });\n }\n\n public _getOperators() {\n const filteredOperators = this.state.supportsMultiValueOperators\n ? OPERATORS\n : OPERATORS.filter((operator) => !operator.isMulti);\n return filteredOperators.map<SelectableValue<string>>(({ value, description }) => ({\n label: value,\n value,\n description,\n }));\n }\n}\n\nfunction renderExpression(\n builder: AdHocVariableExpressionBuilderFn | undefined,\n filters: AdHocFilterWithLabels[] | undefined\n) {\n return (builder ?? renderPrometheusLabelFilters)(filters ?? []);\n}\n\nexport function AdHocFiltersVariableRenderer({ model }: SceneComponentProps<AdHocFiltersVariable>) {\n const { filters, readOnly, addFilterButtonText } = model.useState();\n const styles = useStyles2(getStyles);\n\n if (!model.state.supportsMultiValueOperators && model.state.layout === 'combobox') {\n return <AdHocFiltersComboboxRenderer model={model} />;\n }\n\n return (\n <div className={styles.wrapper}>\n {filters.map((filter, index) => (\n <React.Fragment key={index}>\n <AdHocFilterRenderer filter={filter} model={model} />\n </React.Fragment>\n ))}\n\n {!readOnly && <AdHocFilterBuilder model={model} key=\"'builder\" addFilterButtonText={addFilterButtonText} />}\n </div>\n );\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n wrapper: css({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'flex-end',\n columnGap: theme.spacing(2),\n rowGap: theme.spacing(1),\n }),\n});\n\nexport function toSelectableValue(input: MetricFindValue): SelectableValue<string> {\n const { text, value } = input;\n const result: SelectableValue<string> = {\n label: text,\n value: String(value ?? text),\n };\n\n if ('group' in input) {\n result.group = input.group;\n }\n\n return result;\n}\n\nexport function isFilterComplete(filter: AdHocFilterWithLabels): boolean {\n return filter.key !== '' && filter.operator !== '' && filter.value !== '';\n}\n\nexport function isMultiValueOperator(operatorValue: string): boolean {\n const operator = OPERATORS.find((o) => o.value === operatorValue);\n if (!operator) {\n throw new Error('Unknown operator');\n }\n return Boolean(operator.isMulti);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MA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GAAA,KAAA,GAAS,IAAI,CAAA;AAAA,GAC7B,CAAA;AAEA,EAAA,IAAI,WAAW,KAAO,EAAA;AACpB,IAAA,MAAA,CAAO,QAAQ,KAAM,CAAA,KAAA,CAAA;AAAA,GACvB;AAEA,EAAO,OAAA,MAAA,CAAA;AACT,CAAA;AAEO,SAAS,iBAAiB,MAAwC,EAAA;AACvE,EAAA,OAAO,OAAO,GAAQ,KAAA,EAAA,IAAM,OAAO,QAAa,KAAA,EAAA,IAAM,OAAO,KAAU,KAAA,EAAA,CAAA;AACzE,CAAA;AAEO,SAAS,qBAAqB,aAAgC,EAAA;AACnE,EAAA,MAAM,WAAW,SAAU,CAAA,IAAA,CAAK,CAAC,CAAM,KAAA,CAAA,CAAE,UAAU,aAAa,CAAA,CAAA;AAChE,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,kBAAkB,CAAA,CAAA;AAAA,GACpC;AACA,EAAO,OAAA,OAAA,CAAQ,SAAS,OAAO,CAAA,CAAA;AACjC;;;;"}
@@ -21,7 +21,7 @@ function VariableValueInput({ model }) {
21
21
  id: key,
22
22
  placeholder: "Enter value",
23
23
  minWidth: 15,
24
- defaultValue: value,
24
+ value,
25
25
  loading,
26
26
  onBlur,
27
27
  onKeyDown
@@ -1 +1 @@
1
- {"version":3,"file":"VariableValueInput.js","sources":["../../../../src/variables/components/VariableValueInput.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\n\nimport { AutoSizeInput } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { TextBoxVariable } from '../variants/TextBoxVariable';\n\nexport function VariableValueInput({ model }: SceneComponentProps<TextBoxVariable>) {\n const { value, key, loading } = model.useState();\n\n const onBlur = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n model.setValue(e.currentTarget.value);\n },\n [model]\n );\n\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n model.setValue(e.currentTarget.value);\n }\n },\n [model]\n );\n\n return (\n <AutoSizeInput\n id={key}\n placeholder=\"Enter value\"\n minWidth={15}\n defaultValue={value}\n loading={loading}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n />\n );\n}\n"],"names":[],"mappings":";;;AAOgB,SAAA,kBAAA,CAAmB,EAAE,KAAA,EAA+C,EAAA;AAClF,EAAA,MAAM,EAAE,KAAO,EAAA,GAAA,EAAK,OAAQ,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AAE/C,EAAA,MAAM,MAAS,GAAA,WAAA;AAAA,IACb,CAAC,CAA2C,KAAA;AAC1C,MAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,KACtC;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,MAAM,SAAY,GAAA,WAAA;AAAA,IAChB,CAAC,CAA6C,KAAA;AAC5C,MAAI,IAAA,CAAA,CAAE,QAAQ,OAAS,EAAA;AACrB,QAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,OACtC;AAAA,KACF;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA;AAAA,IACC,EAAI,EAAA,GAAA;AAAA,IACJ,WAAY,EAAA,aAAA;AAAA,IACZ,QAAU,EAAA,EAAA;AAAA,IACV,YAAc,EAAA,KAAA;AAAA,IACd,OAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"VariableValueInput.js","sources":["../../../../src/variables/components/VariableValueInput.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\n\nimport { AutoSizeInput } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { TextBoxVariable } from '../variants/TextBoxVariable';\n\nexport function VariableValueInput({ model }: SceneComponentProps<TextBoxVariable>) {\n const { value, key, loading } = model.useState();\n\n const onBlur = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n model.setValue(e.currentTarget.value);\n },\n [model]\n );\n\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n model.setValue(e.currentTarget.value);\n }\n },\n [model]\n );\n\n return (\n <AutoSizeInput\n id={key}\n placeholder=\"Enter value\"\n minWidth={15}\n value={value}\n loading={loading}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n />\n );\n}\n"],"names":[],"mappings":";;;AAOgB,SAAA,kBAAA,CAAmB,EAAE,KAAA,EAA+C,EAAA;AAClF,EAAA,MAAM,EAAE,KAAO,EAAA,GAAA,EAAK,OAAQ,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AAE/C,EAAA,MAAM,MAAS,GAAA,WAAA;AAAA,IACb,CAAC,CAA2C,KAAA;AAC1C,MAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,KACtC;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,MAAM,SAAY,GAAA,WAAA;AAAA,IAChB,CAAC,CAA6C,KAAA;AAC5C,MAAI,IAAA,CAAA,CAAE,QAAQ,OAAS,EAAA;AACrB,QAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,OACtC;AAAA,KACF;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA;AAAA,IACC,EAAI,EAAA,GAAA;AAAA,IACJ,WAAY,EAAA,aAAA;AAAA,IACZ,QAAU,EAAA,EAAA;AAAA,IACV,KAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}