{"version":3,"file":"Combobox.cjs","sources":["../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import { cx } from '@emotion/css';\nimport { useVirtualizer, type Range } from '@tanstack/react-virtual';\nimport { useCombobox } from 'downshift';\nimport React, { ComponentProps, useCallback, useId, useMemo } from 'react';\n\nimport { t } from '@grafana/i18n';\n\nimport { useStyles2 } from '../../themes/ThemeContext';\nimport { Icon } from '../Icon/Icon';\nimport { AutoSizeInput } from '../Input/AutoSizeInput';\nimport { Input, Props as InputProps } from '../Input/Input';\nimport { Portal } from '../Portal/Portal';\n\nimport { ComboboxList } from './ComboboxList';\nimport { SuffixIcon } from './SuffixIcon';\nimport { itemToString } from './filter';\nimport { getComboboxStyles, MENU_OPTION_HEIGHT, MENU_OPTION_HEIGHT_DESCRIPTION } from './getComboboxStyles';\nimport { ComboboxOption } from './types';\nimport { useComboboxFloat } from './useComboboxFloat';\nimport { useOptions } from './useOptions';\nimport { isNewGroup } from './utils';\n\n// TODO: It would be great if ComboboxOption[\"label\"] was more generic so that if consumers do pass it in (for async),\n// then the onChange handler emits ComboboxOption with the label as non-undefined.\n\ninterface ComboboxStaticProps<T extends string | number>\n  extends Pick<\n    InputProps,\n    'placeholder' | 'autoFocus' | 'id' | 'aria-labelledby' | 'disabled' | 'loading' | 'invalid'\n  > {\n  /**\n   * Allows the user to set a value which is not in the list of options.\n   */\n  createCustomValue?: boolean;\n  /**\n   * Custom description text for the \"create custom value\" option.\n   * Defaults to \"Use custom value\".\n   */\n  customValueDescription?: string;\n  /**\n   * Custom container for rendering the dropdown menu via Portal\n   */\n  portalContainer?: HTMLElement;\n\n  /**\n   * An array of options, or a function that returns a promise resolving to an array of options.\n   * If a function, it will be called when the menu is opened and on keypress with the current search query.\n   */\n  options: Array<ComboboxOption<T>> | ((inputValue: string) => Promise<Array<ComboboxOption<T>>>);\n\n  /**\n   * Current selected value. Most consumers should pass a scalar value (string | number). However, sometimes with Async\n   * it may be better to pass in an Option with a label to display.\n   */\n  value?: T | ComboboxOption<T> | null;\n\n  /**\n   * Defaults to full width of container. Number is a multiple of the spacing unit. 'auto' will size the input to the content.\n   * */\n  width?: number | 'auto';\n\n  ['data-testid']?: string;\n\n  /**\n   * Called when the input loses focus.\n   */\n  onBlur?: () => void;\n\n  /**\n   * Icon to display at the start of the ComboBox input\n   */\n  prefixIcon?: ComponentProps<typeof Icon>['name'];\n}\n\ninterface ClearableProps<T extends string | number> {\n  /**\n   * An `X` appears in the UI, which clears the input and sets the value to `null`. Do not use if you have no `null` case.\n   */\n  isClearable: true;\n\n  /**\n   * onChange handler is called with the newly selected option.\n   */\n  onChange: (option: ComboboxOption<T> | null) => void;\n}\n\ninterface NotClearableProps<T extends string | number> {\n  /**\n   * An `X` appears in the UI, which clears the input and sets the value to `null`. Do not use if you have no `null` case.\n   */\n  isClearable?: false;\n\n  /**\n   * onChange handler is called with the newly selected option.\n   */\n  onChange: (option: ComboboxOption<T>) => void;\n}\n\nexport type ComboboxBaseProps<T extends string | number> = (ClearableProps<T> | NotClearableProps<T>) &\n  ComboboxStaticProps<T>;\n\nexport type AutoSizeConditionals =\n  | {\n      width: 'auto';\n      /**\n       * Needs to be set when width is 'auto' to prevent the input from shrinking too much\n       */\n      minWidth: number;\n      /**\n       * Recommended to set when width is 'auto' to prevent the input from growing too much.\n       */\n      maxWidth?: number;\n    }\n  | {\n      width?: number;\n      minWidth?: never;\n      maxWidth?: never;\n    };\n\nexport type ComboboxProps<T extends string | number> = ComboboxBaseProps<T> & AutoSizeConditionals;\n\nconst noop = () => {};\n\nexport const VIRTUAL_OVERSCAN_ITEMS = 4;\n\n/**\n * A performant and accessible combobox component that supports both synchronous and asynchronous options loading. It provides type-ahead filtering, keyboard navigation, and virtual scrolling for handling large datasets efficiently.\n * Replaces the Select component, and has better performance.\n *\n * https://developers.grafana.com/ui/latest/index.html?path=/docs/inputs-combobox--docs\n * @alpha\n */\nexport const Combobox = <T extends string | number>(props: ComboboxProps<T>) => {\n  const {\n    options: allOptions,\n    onChange,\n    value: valueProp,\n    placeholder: placeholderProp,\n    isClearable, // this should be default false, but TS can't infer the conditional type if you do\n    createCustomValue = false,\n    customValueDescription,\n    id,\n    width,\n    minWidth,\n    maxWidth,\n    'aria-labelledby': ariaLabelledBy,\n    'data-testid': dataTestId,\n    autoFocus,\n    onBlur,\n    disabled,\n    portalContainer,\n    invalid,\n    prefixIcon,\n  } = props;\n\n  // Value can be an actual scalar Value (string or number), or an Option (value + label), so\n  // get a consistent Value from it\n  const value = typeof valueProp === 'object' ? valueProp?.value : valueProp;\n  const baseId = useId().replace(/:/g, '--');\n\n  const {\n    options: filteredOptions,\n    groupStartIndices,\n    updateOptions,\n    asyncLoading,\n    asyncError,\n  } = useOptions(props.options, createCustomValue, customValueDescription);\n  const isAsync = typeof allOptions === 'function';\n\n  const selectedItemIndex = useMemo(() => {\n    if (isAsync) {\n      return null;\n    }\n\n    if (valueProp === undefined || valueProp === null) {\n      return null;\n    }\n\n    const index = allOptions.findIndex((option) => option.value === value);\n    if (index === -1) {\n      return null;\n    }\n\n    return index;\n  }, [valueProp, allOptions, value, isAsync]);\n\n  const selectedItem = useMemo(() => {\n    if (valueProp === undefined || valueProp === null) {\n      return null;\n    }\n\n    if (selectedItemIndex !== null && !isAsync) {\n      return allOptions[selectedItemIndex];\n    }\n\n    return typeof valueProp === 'object' ? valueProp : { value: valueProp, label: valueProp.toString() };\n  }, [selectedItemIndex, isAsync, valueProp, allOptions]);\n\n  const menuId = `${baseId}-downshift-menu`;\n  const labelId = `${baseId}-downshift-label`;\n\n  const styles = useStyles2(getComboboxStyles);\n\n  // Injects the group header for the first rendered item into the range to render.\n  // Accepts the range that useVirtualizer wants to render, and then returns indexes\n  // to actually render.\n  const rangeExtractor = useCallback(\n    (range: Range) => {\n      const startIndex = Math.max(0, range.startIndex - range.overscan);\n      const endIndex = Math.min(filteredOptions.length - 1, range.endIndex + range.overscan);\n      const rangeToReturn = Array.from({ length: endIndex - startIndex + 1 }, (_, i) => startIndex + i);\n\n      // If the first item doesn't have a group, no need to find a header for it\n      const firstDisplayedOption = filteredOptions[rangeToReturn[0]];\n      if (firstDisplayedOption?.group) {\n        const groupStartIndex = groupStartIndices.get(firstDisplayedOption.group);\n        if (groupStartIndex !== undefined && groupStartIndex < rangeToReturn[0]) {\n          rangeToReturn.unshift(groupStartIndex);\n        }\n      }\n\n      return rangeToReturn;\n    },\n    [filteredOptions, groupStartIndices]\n  );\n\n  const rowVirtualizer = useVirtualizer({\n    count: filteredOptions.length,\n    getScrollElement: () => scrollRef.current,\n    estimateSize: (index: number) => {\n      const firstGroupItem = isNewGroup(filteredOptions[index], index > 0 ? filteredOptions[index - 1] : undefined);\n      const hasDescription = 'description' in filteredOptions[index];\n      const hasGroup = 'group' in filteredOptions[index];\n\n      let itemHeight = MENU_OPTION_HEIGHT;\n      if (hasDescription) {\n        itemHeight = MENU_OPTION_HEIGHT_DESCRIPTION;\n      }\n      if (firstGroupItem && hasGroup) {\n        itemHeight += MENU_OPTION_HEIGHT;\n      }\n      return itemHeight;\n    },\n    overscan: VIRTUAL_OVERSCAN_ITEMS,\n    rangeExtractor,\n  });\n\n  const {\n    isOpen,\n    highlightedIndex,\n\n    getInputProps,\n    getMenuProps,\n    getItemProps,\n\n    selectItem,\n  } = useCombobox({\n    menuId,\n    labelId,\n    inputId: id,\n    items: filteredOptions,\n    itemToString,\n    selectedItem,\n\n    // Don't change downshift state in the onBlahChange handlers. Instead, use the stateReducer to make changes.\n    // Downshift calls change handlers on the render after so you can get sync/flickering issues if you change its state\n    // in them.\n    // Instead, stateReducer is called in the same tick as state changes, before that state is committed and rendered.\n\n    onSelectedItemChange: ({ selectedItem }) => {\n      // `selectedItem` type is `ComboboxOption<T> | null`\n      // It can be null when `selectItem()` is called with null, and we never do that unless `isClearable` is true.\n      // So, when `isClearable` is false, `selectedItem` is always non-null. However, the types don't reflect that,\n      // which is why the conditions are needed.\n      //\n      // this is an else if because TS can't infer the correct onChange types from\n      // (isClearable || selectedItem !== null)\n      if (isClearable) {\n        // onChange argument type allows null\n        onChange(selectedItem);\n      } else if (selectedItem !== null) {\n        // onChange argument type *does not* allow null\n        onChange(selectedItem);\n      }\n    },\n\n    defaultHighlightedIndex: selectedItemIndex ?? 0,\n\n    scrollIntoView: () => {},\n\n    onIsOpenChange: ({ isOpen, inputValue }) => {\n      if (isOpen && inputValue === '') {\n        updateOptions(inputValue);\n      }\n    },\n\n    onHighlightedIndexChange: ({ highlightedIndex, type }) => {\n      if (type !== useCombobox.stateChangeTypes.MenuMouseLeave) {\n        rowVirtualizer.scrollToIndex(highlightedIndex);\n      }\n    },\n    onStateChange: ({ inputValue: newInputValue, type, selectedItem: newSelectedItem }) => {\n      switch (type) {\n        case useCombobox.stateChangeTypes.InputChange:\n          updateOptions(newInputValue ?? '');\n\n          break;\n        default:\n          break;\n      }\n    },\n    stateReducer(state, actionAndChanges) {\n      let { changes } = actionAndChanges;\n      const menuBeingOpened = state.isOpen === false && changes.isOpen === true;\n      const menuBeingClosed = state.isOpen === true && changes.isOpen === false;\n\n      // Reset the input value when the menu is opened. If the menu is opened due to an input change\n      // then make sure we keep that.\n      // This will trigger onInputValueChange to load async options\n      if (menuBeingOpened && changes.inputValue === state.inputValue) {\n        changes = {\n          ...changes,\n          inputValue: '',\n        };\n      }\n\n      if (menuBeingClosed) {\n        // Flush the selected item to the input when the menu is closed\n        if (changes.selectedItem) {\n          changes = {\n            ...changes,\n            inputValue: itemToString(changes.selectedItem),\n          };\n        } else if (changes.inputValue !== '') {\n          // Otherwise if no selected value, clear any search from the input\n          changes = {\n            ...changes,\n            inputValue: '',\n          };\n        }\n      }\n\n      return changes;\n    },\n  });\n\n  const { inputRef, floatingRef, floatStyles, scrollRef } = useComboboxFloat(filteredOptions, isOpen);\n\n  const isAutoSize = width === 'auto';\n  const InputComponent = isAutoSize ? AutoSizeInput : Input;\n  const placeholder = (isOpen ? itemToString(selectedItem) : null) || placeholderProp;\n\n  const loading = props.loading || asyncLoading;\n\n  const inputSuffix = (\n    <>\n      {value !== undefined && value === selectedItem?.value && isClearable && (\n        <Icon\n          name=\"times\"\n          className={styles.clear}\n          title={t('combobox.clear.title', 'Clear value')}\n          tabIndex={0}\n          role=\"button\"\n          onClick={() => {\n            selectItem(null);\n          }}\n          onKeyDown={(e) => {\n            if (e.key === 'Enter' || e.key === ' ') {\n              selectItem(null);\n            }\n          }}\n        />\n      )}\n\n      <SuffixIcon isLoading={loading || false} isOpen={isOpen} />\n    </>\n  );\n\n  const { Wrapper, wrapperProps } = isAutoSize\n    ? {\n        Wrapper: 'div',\n        wrapperProps: { className: styles.adaptToParent },\n      }\n    : { Wrapper: React.Fragment };\n\n  return (\n    <Wrapper {...wrapperProps}>\n      <InputComponent\n        width={isAutoSize ? undefined : width}\n        {...(isAutoSize ? { minWidth, maxWidth } : {})}\n        autoFocus={autoFocus}\n        onBlur={onBlur}\n        prefix={prefixIcon && <Icon name={prefixIcon} />}\n        disabled={disabled}\n        invalid={invalid}\n        className={styles.input}\n        suffix={inputSuffix}\n        {...getInputProps({\n          ref: inputRef,\n          onChange: noop, // Empty onCall to avoid TS error https://github.com/downshift-js/downshift/issues/718\n          'aria-labelledby': ariaLabelledBy, // Label should be handled with the Field component\n          placeholder,\n          'data-testid': dataTestId,\n        })}\n      />\n      <Portal root={portalContainer}>\n        <div\n          className={cx(styles.menu, !isOpen && styles.menuClosed)}\n          style={{\n            ...floatStyles,\n            pointerEvents: 'auto', // Override container's pointer-events: none\n          }}\n          {...getMenuProps({\n            ref: floatingRef,\n            'aria-labelledby': ariaLabelledBy,\n          })}\n        >\n          {isOpen && (\n            <ComboboxList\n              loading={loading}\n              options={filteredOptions}\n              highlightedIndex={highlightedIndex}\n              selectedItems={selectedItem ? [selectedItem] : []}\n              scrollRef={scrollRef}\n              getItemProps={getItemProps}\n              error={asyncError}\n            />\n          )}\n        </div>\n      </Portal>\n    </Wrapper>\n  );\n};\n"],"names":["useId","useOptions","useMemo","useStyles2","getComboboxStyles","useCallback","useVirtualizer","isNewGroup","MENU_OPTION_HEIGHT","MENU_OPTION_HEIGHT_DESCRIPTION","useCombobox","itemToString","selectedItem","isOpen","highlightedIndex","useComboboxFloat","AutoSizeInput","Input","jsxs","Fragment","jsx","Icon","t","SuffixIcon","React","Portal","cx","ComboboxList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAM,OAAO,MAAM;AAAC,CAAA;AAEb,MAAM,sBAAA,GAAyB;AAS/B,MAAM,QAAA,GAAW,CAA4B,KAAA,KAA4B;AAC9E,EAAA,MAAM;AAAA,IACJ,OAAA,EAAS,UAAA;AAAA,IACT,QAAA;AAAA,IACA,KAAA,EAAO,SAAA;AAAA,IACP,WAAA,EAAa,eAAA;AAAA,IACb,WAAA;AAAA;AAAA,IACA,iBAAA,GAAoB,KAAA;AAAA,IACpB,sBAAA;AAAA,IACA,EAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,iBAAA,EAAmB,cAAA;AAAA,IACnB,aAAA,EAAe,UAAA;AAAA,IACf,SAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,eAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AAIJ,EAAA,MAAM,KAAA,GAAQ,OAAO,SAAA,KAAc,QAAA,GAAW,uCAAW,KAAA,GAAQ,SAAA;AACjE,EAAA,MAAM,MAAA,GAASA,WAAA,EAAM,CAAE,OAAA,CAAQ,MAAM,IAAI,CAAA;AAEzC,EAAA,MAAM;AAAA,IACJ,OAAA,EAAS,eAAA;AAAA,IACT,iBAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF,GAAIC,qBAAA,CAAW,KAAA,CAAM,OAAA,EAAS,mBAAmB,sBAAsB,CAAA;AACvE,EAAA,MAAM,OAAA,GAAU,OAAO,UAAA,KAAe,UAAA;AAEtC,EAAA,MAAM,iBAAA,GAAoBC,cAAQ,MAAM;AACtC,IAAA,IAAI,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